MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / runOpWithTemplate

Function runOpWithTemplate

scripts/web-env/shared.ts:254–313  ·  view source on GitHub ↗
(args: string[], template: string)

Source from the content-addressed store, hash-verified

252 });
253}
254
255function vercelAccessError(error: unknown): Error {
256 const details = error instanceof Error ? error.message.trim() : '';
257 return new Error(
258 [
259 'Could not verify Vercel access for the kilocode team.',
260 'Install workspace tools with `pnpm install --frozen-lockfile` in the checkout.',
261 `Run \`${VERCEL_COMMAND} login\` with an account that has access to the kilocode team.`,
262 `Verify access with \`${VERCEL_COMMAND} whoami --scope kilocode --format=json\`.`,
263 details ? `Vercel reported:\n${details}` : undefined,
264 ]
265 .filter(Boolean)
266 .join('\n')
267 );
268}
269
270function onePasswordAccessError(error: unknown): Error {
271 const details = error instanceof Error ? error.message.trim() : '';
272 return new Error(
273 [
274 `Could not verify 1Password access to the ${VAULT} vault.`,
275 ...onePasswordInstallInstructions(),
276 `Verify access with \`op account list --format=json\`, then \`op vault get "${VAULT}" --account ${ONE_PASSWORD_ACCOUNT_URL} --format=json\`.`,
277 'If verification says the vault is missing or forbidden, ask for access to that vault.',
278 details ? `1Password reported:\n${details}` : undefined,
279 ]
280 .filter(Boolean)
281 .join('\n')
282 );
283}
284
285export type VercelContexts = {
286 contexts: VercelContext[];
287 missingProjects: Project[];
288};
289
290class VercelApiError extends Error {
291 constructor(
292 operation: string,
293 readonly code: string | undefined,
294 message: string | undefined
295 ) {
296 super(`${operation} failed: ${code ?? 'unknown_error'}${message ? ` (${message})` : ''}.`);
297 }
298}
299
300function apiArgs(context: VercelContext, endpoint: string): string[] {
301 const separator = endpoint.includes('?') ? '&' : '?';
302 return ['api', `${endpoint}${separator}teamId=${context.orgId}`, '--raw'];
303}
304
305// `vercel api` can also exit 0 with a JSON error body, so check both.
306function apiResponse(output: string, operation: string): JsonRecord {
307 const response = parseJson(output, operation);
308 if (isRecord(response.error)) {
309 throw new VercelApiError(
310 operation,
311 stringValue(response.error, 'code'),

Callers 1

setVaultValueFunction · 0.85

Calls 8

captureFunction · 0.85
joinMethod · 0.80
failFunction · 0.70
toStringMethod · 0.65
endMethod · 0.65
resolveFunction · 0.50
onMethod · 0.45

Tested by

no test coverage detected