@clue-ai/cli 0.0.5 → 0.0.7
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/README.md +18 -7
- package/bin/clue-cli.mjs +898 -762
- package/commands/claude-code/clue-init.md +9 -2
- package/commands/codex/clue-init.md +9 -2
- package/package.json +1 -1
- package/src/ai-provider.mjs +147 -0
- package/src/command-spec.mjs +9 -7
- package/src/contracts.mjs +51 -16
- package/src/init-tool.mjs +158 -125
- package/src/lifecycle-init.mjs +180 -205
- package/src/public-schema.cjs +48 -1
- package/src/semantic-agent-runner.mjs +157 -0
- package/src/semantic-ai-config.mjs +17 -0
- package/src/semantic-ci.mjs +525 -204
- package/src/setup-check.mjs +399 -372
- package/src/setup-prepare.mjs +361 -147
- package/src/setup-tool.mjs +379 -229
package/src/lifecycle-init.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
3
|
+
import { callJsonAiProvider, resolveAiProviderConfig } from "./ai-provider.mjs";
|
|
3
4
|
import { findLifecycleGuardViolations } from "./lifecycle-guard.mjs";
|
|
4
5
|
import { listAllowedSourceFiles } from "./path-policy.mjs";
|
|
5
6
|
|
|
6
7
|
const API_NAMES = new Set([
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
"ClueInit",
|
|
9
|
+
"ClueIdentify",
|
|
10
|
+
"ClueSetAccount",
|
|
11
|
+
"ClueLogout",
|
|
11
12
|
]);
|
|
12
13
|
|
|
13
14
|
const SOURCE_EXTENSIONS = [".py", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
|
|
@@ -16,234 +17,208 @@ const MAX_FILE_CHARS = 12_000;
|
|
|
16
17
|
const MAX_TOTAL_CHARS = 360_000;
|
|
17
18
|
|
|
18
19
|
const nonEmpty = (value, field) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
21
|
+
throw new Error(`${field} is required`);
|
|
22
|
+
}
|
|
23
|
+
return value.trim();
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const safeRelativePath = (repoRoot, filePath) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const root = resolve(repoRoot);
|
|
28
|
+
const absolutePath = resolve(root, filePath);
|
|
29
|
+
const relativePath = relative(root, absolutePath);
|
|
30
|
+
if (relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
31
|
+
throw new Error(`edit path escapes repo root: ${filePath}`);
|
|
32
|
+
}
|
|
33
|
+
return { absolutePath, relativePath };
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const assertApiName = (apiName) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (!API_NAMES.has(apiName)) {
|
|
38
|
+
throw new Error(`unsupported lifecycle API: ${apiName}`);
|
|
39
|
+
}
|
|
40
|
+
return apiName;
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
const assertNoForbiddenInstrumentation = (replacement) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
if (replacement.includes("ClueTrack")) {
|
|
45
|
+
throw new Error("init tool must not add broad ClueTrack instrumentation");
|
|
46
|
+
}
|
|
47
|
+
if (/data-clue-(id|key)/i.test(replacement)) {
|
|
48
|
+
throw new Error("init tool must not add data-clue-id or data-clue-key");
|
|
49
|
+
}
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const assertLifecycleCallsAreGuarded = (replacement) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
const violations = findLifecycleGuardViolations(replacement);
|
|
54
|
+
if (violations.length > 0) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`Clue lifecycle calls must be failure-isolated with try/catch, try/except, or an explicit safe Clue helper: ${JSON.stringify(violations)}`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
58
59
|
};
|
|
59
60
|
|
|
60
61
|
const normalizeLifecycleInsertion = (input) => ({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
api_name: assertApiName(nonEmpty(input.api_name, "api_name")),
|
|
63
|
+
file_path: nonEmpty(input.file_path, "file_path"),
|
|
64
|
+
confidence: Math.max(0, Math.min(1, Number(input.confidence ?? 0))),
|
|
65
|
+
reason: nonEmpty(input.reason, "reason"),
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
const normalizePlan = (input) => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
69
|
+
if (!input || typeof input !== "object") {
|
|
70
|
+
throw new Error("AI lifecycle plan must be an object");
|
|
71
|
+
}
|
|
72
|
+
if (!Array.isArray(input.edits)) {
|
|
73
|
+
throw new Error("AI lifecycle plan must include edits");
|
|
74
|
+
}
|
|
75
|
+
const edits = input.edits.map((edit) => ({
|
|
76
|
+
file_path: nonEmpty(edit.file_path, "edit.file_path"),
|
|
77
|
+
find: nonEmpty(edit.find, "edit.find"),
|
|
78
|
+
replace: nonEmpty(edit.replace, "edit.replace"),
|
|
79
|
+
}));
|
|
80
|
+
const lifecycleInsertions = Array.isArray(input.lifecycle_insertions)
|
|
81
|
+
? input.lifecycle_insertions.map(normalizeLifecycleInsertion)
|
|
82
|
+
: [];
|
|
83
|
+
return {
|
|
84
|
+
edits,
|
|
85
|
+
lifecycleInsertions,
|
|
86
|
+
warnings: Array.isArray(input.warnings)
|
|
87
|
+
? input.warnings
|
|
88
|
+
.filter((warning) => typeof warning === "string" && warning.trim())
|
|
89
|
+
.map((warning) => warning.trim())
|
|
90
|
+
: [],
|
|
91
|
+
};
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
export const applyLifecyclePlan = async ({ repoRoot, plan: rawPlan }) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
const plan = normalizePlan(rawPlan);
|
|
96
|
+
for (const edit of plan.edits) {
|
|
97
|
+
const { absolutePath } = safeRelativePath(repoRoot, edit.file_path);
|
|
98
|
+
assertNoForbiddenInstrumentation(edit.replace);
|
|
99
|
+
const current = await readFile(absolutePath, "utf8");
|
|
100
|
+
const occurrences = current.split(edit.find).length - 1;
|
|
101
|
+
if (occurrences !== 1) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`edit.find must match exactly once in ${edit.file_path}; matched ${occurrences}`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
assertLifecycleCallsAreGuarded(edit.replace);
|
|
107
|
+
await writeFile(
|
|
108
|
+
absolutePath,
|
|
109
|
+
current.replace(edit.find, edit.replace),
|
|
110
|
+
"utf8",
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
lifecycleInsertions: plan.lifecycleInsertions,
|
|
115
|
+
warnings: plan.warnings,
|
|
116
|
+
};
|
|
116
117
|
};
|
|
117
118
|
|
|
118
119
|
const readContextFiles = async ({ repoRoot, request }) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
120
|
+
const files = await listAllowedSourceFiles({
|
|
121
|
+
repoRoot,
|
|
122
|
+
allowedSourcePaths: request.allowed_source_paths,
|
|
123
|
+
excludedSourcePaths: request.excluded_source_paths,
|
|
124
|
+
extensions: SOURCE_EXTENSIONS,
|
|
125
|
+
});
|
|
126
|
+
const context = [];
|
|
127
|
+
let totalChars = 0;
|
|
128
|
+
for (const absolutePath of files.slice(0, MAX_CONTEXT_FILES)) {
|
|
129
|
+
const text = await readFile(absolutePath, "utf8");
|
|
130
|
+
const snippet = text.slice(0, MAX_FILE_CHARS);
|
|
131
|
+
totalChars += snippet.length;
|
|
132
|
+
if (totalChars > MAX_TOTAL_CHARS) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
context.push({
|
|
136
|
+
file_path: relative(resolve(repoRoot), absolutePath),
|
|
137
|
+
source: snippet,
|
|
138
|
+
truncated: text.length > snippet.length,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return context;
|
|
141
142
|
};
|
|
142
143
|
|
|
143
144
|
const buildLifecyclePrompt = ({ request, files }) =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
145
|
+
JSON.stringify({
|
|
146
|
+
task: "Add Clue SDK lifecycle API calls to this repository using exact text replacements.",
|
|
147
|
+
rules: [
|
|
148
|
+
"Return JSON only.",
|
|
149
|
+
"Use only exact replacements. Each find string must be copied exactly from source.",
|
|
150
|
+
"Add ClueInit, ClueIdentify, ClueSetAccount, and ClueLogout where repository code has clear lifecycle points.",
|
|
151
|
+
"Every Clue lifecycle call must be failure-isolated. If Clue fails, the host service must continue without throwing, rejecting, or blocking login/API behavior.",
|
|
152
|
+
"Use a small safe Clue helper, local try/catch/try/except wrapper, or direct .catch handler around Clue lifecycle calls.",
|
|
153
|
+
"Never await a Clue lifecycle call in a way that can block login, logout, account selection, request handling, page rendering, or API responses.",
|
|
154
|
+
"Find all clear login success paths and add ClueIdentify to every one of them. Do not stop after the first login flow.",
|
|
155
|
+
"Find all clear account, workspace, organization, or tenant resolution paths and add ClueSetAccount to every one of them.",
|
|
156
|
+
"Find all clear logout or session reset paths and add ClueLogout to every one of them.",
|
|
157
|
+
"Inspect backend lifecycle points as carefully as frontend lifecycle points. Backend login/session/account code is especially important.",
|
|
158
|
+
"For FastAPI backends, add the clue-fastapi-sdk dependency when missing, import clue_init_fastapi plus ClueIdentify/ClueSetAccount/ClueLogout where needed, and initialize the SDK at FastAPI app creation.",
|
|
159
|
+
"For Django backends, add the clue-django-sdk dependency when missing, import the Django SDK lifecycle helpers where needed, and initialize the SDK in the Django integration point.",
|
|
160
|
+
"For other backend frameworks, use the matching Clue backend SDK if one exists; if no backend SDK exists, report a blocker instead of silently frontend-only setup.",
|
|
161
|
+
"Do not add broad ClueTrack instrumentation.",
|
|
162
|
+
"Do not add data-clue-id, data-clue-key, or similar DOM tags.",
|
|
163
|
+
"Do not create route semantics files or layer files.",
|
|
164
|
+
"Do not copy project keys, API keys, service secrets, or environment-specific values into code.",
|
|
165
|
+
"Do not send raw email, raw person names, tokens, workspace names, organization names, or tenant names as lifecycle traits unless the repository already has an explicit Clue privacy policy allowing them.",
|
|
166
|
+
"Prefer stable ids and non-PII booleans/counts for ClueIdentify and ClueSetAccount traits.",
|
|
167
|
+
"Use environment variable names for Clue configuration values.",
|
|
168
|
+
"For Python/FastAPI code, read CLUE_PROJECT_KEY, CLUE_ENVIRONMENT, CLUE_API_KEY, and CLUE_INGEST_ENDPOINT from environment variables.",
|
|
169
|
+
"For browser code, read CLUE_PROJECT_KEY, CLUE_ENVIRONMENT, and CLUE_INGEST_ENDPOINT from environment variables through the target framework's safe client config mechanism. Do not hard-code a Next.js-only prefix.",
|
|
170
|
+
"Prefer minimal edits that engineers can review in one PR.",
|
|
171
|
+
"If a lifecycle point is unclear, skip that edit and include a warning.",
|
|
172
|
+
],
|
|
173
|
+
repository_context: {
|
|
174
|
+
target_tool: request.target_tool,
|
|
175
|
+
framework: request.framework,
|
|
176
|
+
project_key_env: "CLUE_PROJECT_KEY",
|
|
177
|
+
browser_project_key_env: "CLUE_PROJECT_KEY",
|
|
178
|
+
environment_env: "CLUE_ENVIRONMENT",
|
|
179
|
+
browser_environment_env: "CLUE_ENVIRONMENT",
|
|
180
|
+
clue_api_base_url_env: "CLUE_API_BASE_URL",
|
|
181
|
+
clue_ingest_endpoint_env: "CLUE_INGEST_ENDPOINT",
|
|
182
|
+
browser_ingest_endpoint_env: "CLUE_INGEST_ENDPOINT",
|
|
183
|
+
service_key: request.service_key,
|
|
184
|
+
},
|
|
185
|
+
output_shape: {
|
|
186
|
+
edits: [
|
|
187
|
+
{
|
|
188
|
+
file_path: "app/main.py",
|
|
189
|
+
find: "exact original text",
|
|
190
|
+
replace: "exact replacement text",
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
lifecycle_insertions: [
|
|
194
|
+
{
|
|
195
|
+
api_name: "ClueInit",
|
|
196
|
+
file_path: "app/main.py",
|
|
197
|
+
confidence: 0.8,
|
|
198
|
+
reason: "SDK initialized where FastAPI app is created.",
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
warnings: ["short engineer review note"],
|
|
202
|
+
},
|
|
203
|
+
files,
|
|
204
|
+
});
|
|
204
205
|
|
|
205
206
|
export const planLifecycleInsertions = async ({ repoRoot, request, env }) => {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
authorization: `Bearer ${apiKey}`,
|
|
224
|
-
},
|
|
225
|
-
body: JSON.stringify({
|
|
226
|
-
model,
|
|
227
|
-
messages: [
|
|
228
|
-
{
|
|
229
|
-
role: "system",
|
|
230
|
-
content:
|
|
231
|
-
"You are a safe code-edit planner for Clue SDK initialization. Return schema-valid JSON only.",
|
|
232
|
-
},
|
|
233
|
-
{ role: "user", content: buildLifecyclePrompt({ request, files }) },
|
|
234
|
-
],
|
|
235
|
-
response_format: { type: "json_object" },
|
|
236
|
-
}),
|
|
237
|
-
});
|
|
238
|
-
if (!response.ok) {
|
|
239
|
-
throw new Error(
|
|
240
|
-
`AI provider failed during lifecycle planning: ${response.status}`,
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
const body = await response.json();
|
|
244
|
-
const content = body?.choices?.[0]?.message?.content;
|
|
245
|
-
if (typeof content !== "string" || content.trim() === "") {
|
|
246
|
-
throw new Error("AI provider returned empty lifecycle plan");
|
|
247
|
-
}
|
|
248
|
-
return JSON.parse(content);
|
|
207
|
+
const apiKey = env.CLUE_AI_PROVIDER_API_KEY;
|
|
208
|
+
if (!apiKey) {
|
|
209
|
+
throw new Error(
|
|
210
|
+
"CLUE_AI_PROVIDER_API_KEY is required for lifecycle API insertion",
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
const files = await readContextFiles({ repoRoot, request });
|
|
214
|
+
return callJsonAiProvider({
|
|
215
|
+
config: resolveAiProviderConfig({ env, apiKey }),
|
|
216
|
+
system:
|
|
217
|
+
"You are a safe code-edit planner for Clue SDK initialization. Return schema-valid JSON only.",
|
|
218
|
+
user: buildLifecyclePrompt({ request, files }),
|
|
219
|
+
toolName: "return_lifecycle_plan",
|
|
220
|
+
toolDescription: "Return the Clue SDK lifecycle insertion plan.",
|
|
221
|
+
failureMessage: "AI provider failed during lifecycle planning",
|
|
222
|
+
emptyMessage: "AI provider returned empty lifecycle plan",
|
|
223
|
+
});
|
|
249
224
|
};
|
package/src/public-schema.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const clueInitToolTargetSchema = zod_1.z.enum(["codex", "claude_code"]);
|
|
|
7
7
|
const clueInitToolFrameworkSchema = nonEmptyStringSchema;
|
|
8
8
|
const clueInitToolRequiredSecretSchema = zod_1.z.enum([
|
|
9
9
|
"CLUE_API_KEY",
|
|
10
|
-
"
|
|
10
|
+
"CLUE_AI_PROVIDER_API_KEY",
|
|
11
11
|
]);
|
|
12
12
|
const clueInitToolRequiredSecretsSchema = zod_1.z
|
|
13
13
|
.array(clueInitToolRequiredSecretSchema)
|
|
@@ -22,6 +22,29 @@ const clueInitToolRequiredSecretsSchema = zod_1.z
|
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
.transform((value) => Array.from(new Set(value)));
|
|
25
|
+
const clueInitToolRequiredVariableSchema = zod_1.z.enum([
|
|
26
|
+
"CLUE_AI_PROVIDER",
|
|
27
|
+
"CLUE_AI_MODEL",
|
|
28
|
+
"CLUE_PROJECT_KEY",
|
|
29
|
+
"CLUE_ENVIRONMENT",
|
|
30
|
+
"CLUE_API_BASE_URL",
|
|
31
|
+
]);
|
|
32
|
+
const clueInitToolRequiredVariablesSchema = zod_1.z
|
|
33
|
+
.array(clueInitToolRequiredVariableSchema)
|
|
34
|
+
.superRefine((value, context) => {
|
|
35
|
+
for (const variable of [
|
|
36
|
+
"CLUE_AI_PROVIDER",
|
|
37
|
+
"CLUE_AI_MODEL",
|
|
38
|
+
]) {
|
|
39
|
+
if (!value.includes(variable)) {
|
|
40
|
+
context.addIssue({
|
|
41
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
42
|
+
message: `${variable} is required`,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
.transform((value) => Array.from(new Set(value)));
|
|
25
48
|
const clueInitToolRequestSchema = zod_1.z.object({
|
|
26
49
|
target_tool: clueInitToolTargetSchema,
|
|
27
50
|
project_key: nonEmptyStringSchema,
|
|
@@ -48,6 +71,7 @@ const clueInitToolReportSchema = zod_1.z.object({
|
|
|
48
71
|
ci_workflow_path: nonEmptyStringSchema,
|
|
49
72
|
ci_workflow_added: zod_1.z.literal(true),
|
|
50
73
|
required_secrets: clueInitToolRequiredSecretsSchema,
|
|
74
|
+
required_variables: clueInitToolRequiredVariablesSchema,
|
|
51
75
|
lifecycle_insertions: zod_1.z.array(clueInitToolLifecycleInsertionSchema),
|
|
52
76
|
semantic_generation_timing: zod_1.z.literal("after_merge_ci"),
|
|
53
77
|
semantic_preview_generated: zod_1.z.literal(false),
|
|
@@ -211,6 +235,27 @@ const semanticSnapshotAnalysisSummarySchema = zod_1.z
|
|
|
211
235
|
.default(0),
|
|
212
236
|
})
|
|
213
237
|
.strict();
|
|
238
|
+
const semanticSnapshotGenerationContractSchema = zod_1.z
|
|
239
|
+
.object({
|
|
240
|
+
schema_version: zod_1.z.number().int().positive(),
|
|
241
|
+
analyzer_version: nonEmptyStringSchema,
|
|
242
|
+
route_prompt_contract_version: nonEmptyStringSchema,
|
|
243
|
+
reuse_prompt_contract_version: nonEmptyStringSchema,
|
|
244
|
+
selector_prompt_contract_version: nonEmptyStringSchema,
|
|
245
|
+
privacy_sanitizer_version: nonEmptyStringSchema,
|
|
246
|
+
})
|
|
247
|
+
.strict();
|
|
248
|
+
const semanticSnapshotAiRuntimeSchema = zod_1.z
|
|
249
|
+
.object({
|
|
250
|
+
mode: zod_1.z.enum(["client_ci"]),
|
|
251
|
+
provider: nonEmptyStringSchema,
|
|
252
|
+
model: nonEmptyStringSchema,
|
|
253
|
+
model_source: zod_1.z.literal("customer_ci_secret"),
|
|
254
|
+
runner_version: nonEmptyStringSchema,
|
|
255
|
+
role_ids: zod_1.z.array(nonEmptyStringSchema).min(1),
|
|
256
|
+
temperature: zod_1.z.literal(0),
|
|
257
|
+
})
|
|
258
|
+
.strict();
|
|
214
259
|
const semanticCandidateSchema = zod_1.z
|
|
215
260
|
.object({
|
|
216
261
|
label: nonEmptyStringSchema,
|
|
@@ -460,6 +505,8 @@ const semanticSnapshotRequestSchema = zod_1.z
|
|
|
460
505
|
idempotency_key: nonEmptyStringSchema,
|
|
461
506
|
schema_version: zod_1.z.number().int().positive().default(1),
|
|
462
507
|
semantic_snapshot_version: nonEmptyStringSchema.optional(),
|
|
508
|
+
generation_contract: semanticSnapshotGenerationContractSchema.optional(),
|
|
509
|
+
ai_runtime: semanticSnapshotAiRuntimeSchema.optional(),
|
|
463
510
|
generated_at: zod_1.z.string().datetime({ offset: true }),
|
|
464
511
|
repository: semanticSnapshotRepositorySchema,
|
|
465
512
|
service: semanticSnapshotServiceSchema,
|