@catladder/cli 0.0.0-main-5bdbbbe0 → 0.0.0-main-f29db9e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/catenv/index.js +492 -18
- package/dist/bundles/cli/index.js +656 -18
- package/dist/cli/src/apps/cli/commands/project/setup/index.js +2 -0
- package/dist/cli/src/apps/cli/commands/project/setup/index.js.map +1 -1
- package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.d.ts +2 -0
- package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js +155 -0
- package/dist/cli/src/apps/cli/commands/project/setup/setupAgents.js.map +1 -0
- package/dist/cli/src/config/getProjectConfig.js +4 -1
- package/dist/cli/src/config/getProjectConfig.js.map +1 -1
- package/dist/pipeline/src/bash/bashEscape.d.ts +2 -0
- package/dist/pipeline/src/bash/bashEscape.js +5 -1
- package/dist/pipeline/src/bash/bashEscape.js.map +1 -1
- package/dist/pipeline/src/pipeline/agent/createAgentContext.d.ts +6 -0
- package/dist/pipeline/src/pipeline/agent/createAgentContext.js +19 -0
- package/dist/pipeline/src/pipeline/agent/createAgentContext.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/createAgentEventJob.d.ts +2 -0
- package/dist/pipeline/src/pipeline/agent/createAgentEventJob.js +37 -0
- package/dist/pipeline/src/pipeline/agent/createAgentEventJob.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.d.ts +2 -0
- package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.js +34 -0
- package/dist/pipeline/src/pipeline/agent/createAgentReviewJob.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.d.ts +2 -0
- package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.js +10 -0
- package/dist/pipeline/src/pipeline/agent/createJobsForAgentContext.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/prompts.d.ts +6 -0
- package/dist/pipeline/src/pipeline/agent/prompts.js +221 -0
- package/dist/pipeline/src/pipeline/agent/prompts.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/shared.d.ts +6 -0
- package/dist/pipeline/src/pipeline/agent/shared.js +30 -0
- package/dist/pipeline/src/pipeline/agent/shared.js.map +1 -0
- package/dist/pipeline/src/pipeline/agent/utils.d.ts +3 -0
- package/dist/pipeline/src/pipeline/agent/utils.js +14 -0
- package/dist/pipeline/src/pipeline/agent/utils.js.map +1 -0
- package/dist/pipeline/src/pipeline/createAllJobs.d.ts +5 -1
- package/dist/pipeline/src/pipeline/createAllJobs.js +10 -1
- package/dist/pipeline/src/pipeline/createAllJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/createJobsForComponent.js.map +1 -1
- package/dist/pipeline/src/pipeline/createMainPipeline.js +13 -4
- package/dist/pipeline/src/pipeline/createMainPipeline.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.d.ts +3 -3
- package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.js +18 -9
- package/dist/pipeline/src/pipeline/gitlab/createGitlabJobs.js.map +1 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js +8 -1
- package/dist/pipeline/src/pipeline/gitlab/createGitlabPipeline.js.map +1 -1
- package/dist/pipeline/src/rules/index.d.ts +1 -0
- package/dist/pipeline/src/rules/index.js +8 -1
- package/dist/pipeline/src/rules/index.js.map +1 -1
- package/dist/pipeline/src/types/agent.d.ts +7 -0
- package/dist/pipeline/src/types/agent.js +3 -0
- package/dist/pipeline/src/types/agent.js.map +1 -0
- package/dist/pipeline/src/types/config.d.ts +2 -0
- package/dist/pipeline/src/types/config.js.map +1 -1
- package/dist/pipeline/src/types/context.d.ts +7 -0
- package/dist/pipeline/src/types/context.js.map +1 -1
- package/dist/pipeline/src/types/index.d.ts +1 -0
- package/dist/pipeline/src/types/index.js +1 -0
- package/dist/pipeline/src/types/index.js.map +1 -1
- package/dist/pipeline/src/types/jobs.d.ts +5 -1
- package/dist/pipeline/src/types/jobs.js +1 -0
- package/dist/pipeline/src/types/jobs.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/apps/cli/commands/project/setup/index.ts +2 -0
- package/src/apps/cli/commands/project/setup/setupAgents.ts +319 -0
- package/src/config/getProjectConfig.ts +8 -3
|
@@ -1984,6 +1984,7 @@ const getProjectConfig_1 = __nccwpck_require__(12145);
|
|
|
1984
1984
|
const setupAccessTokens_1 = __nccwpck_require__(84195);
|
|
1985
1985
|
const setupContext_1 = __nccwpck_require__(44310);
|
|
1986
1986
|
const setupTopic_1 = __nccwpck_require__(84290);
|
|
1987
|
+
const setupAgents_1 = __nccwpck_require__(19287);
|
|
1987
1988
|
const setupProject = async (instance, onlyComponents) => {
|
|
1988
1989
|
const allContext = await (0, getProjectConfig_1.getAllPipelineContexts)(onlyComponents);
|
|
1989
1990
|
instance.log("will setup those contexts:");
|
|
@@ -1995,6 +1996,7 @@ const setupProject = async (instance, onlyComponents) => {
|
|
|
1995
1996
|
}
|
|
1996
1997
|
await (0, setupAccessTokens_1.setupAccessTokens)(instance);
|
|
1997
1998
|
await (0, setupTopic_1.setupTopic)(instance);
|
|
1999
|
+
await (0, setupAgents_1.setupAgents)(instance);
|
|
1998
2000
|
instance.log("");
|
|
1999
2001
|
instance.log("gitlab is ready! 🥂");
|
|
2000
2002
|
instance.log("\n");
|
|
@@ -2059,6 +2061,168 @@ exports.setupAccessTokens = setupAccessTokens;
|
|
|
2059
2061
|
|
|
2060
2062
|
/***/ }),
|
|
2061
2063
|
|
|
2064
|
+
/***/ 19287:
|
|
2065
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2066
|
+
|
|
2067
|
+
"use strict";
|
|
2068
|
+
|
|
2069
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2070
|
+
exports.setupAgents = void 0;
|
|
2071
|
+
const gitlab_1 = __nccwpck_require__(12927);
|
|
2072
|
+
const getProjectConfig_1 = __nccwpck_require__(12145);
|
|
2073
|
+
const gitProjectInformation_1 = __nccwpck_require__(78329);
|
|
2074
|
+
const listTriggerTokens = async (instance, projectId) => {
|
|
2075
|
+
return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/triggers`);
|
|
2076
|
+
};
|
|
2077
|
+
const deleteTriggerToken = async (instance, projectId, triggerId) => {
|
|
2078
|
+
await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/triggers/${triggerId}`, undefined, "DELETE");
|
|
2079
|
+
};
|
|
2080
|
+
const createTriggerToken = async (instance, projectId, description) => {
|
|
2081
|
+
return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/triggers`, { description }, "POST");
|
|
2082
|
+
};
|
|
2083
|
+
const listWebhooks = async (instance, projectId) => {
|
|
2084
|
+
return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/hooks`);
|
|
2085
|
+
};
|
|
2086
|
+
const createWebhook = async (instance, projectId, webhookData) => {
|
|
2087
|
+
return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/hooks`, webhookData, "POST");
|
|
2088
|
+
};
|
|
2089
|
+
const updateWebhook = async (instance, projectId, hookId, webhookData) => {
|
|
2090
|
+
return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/hooks/${hookId}`, webhookData, "PUT");
|
|
2091
|
+
};
|
|
2092
|
+
const setupAgentWebhook = async (instance, projectId, agentName, triggerToken) => {
|
|
2093
|
+
const webhookName = `cl_agent_${agentName}_webhook`;
|
|
2094
|
+
const { gitRemoteHost } = await (0, gitProjectInformation_1.getGitRemoteHostAndPath)();
|
|
2095
|
+
const webhookUrl = `https://${gitRemoteHost}/api/v4/projects/${projectId}/ref/main/trigger/pipeline?token=${triggerToken}`;
|
|
2096
|
+
instance.log(`Setting up webhook for agent: ${agentName}`);
|
|
2097
|
+
// List existing webhooks
|
|
2098
|
+
const existingWebhooks = await listWebhooks(instance, projectId);
|
|
2099
|
+
// Find existing webhook by name
|
|
2100
|
+
const existingWebhook = existingWebhooks.find((webhook) => webhook.name === webhookName);
|
|
2101
|
+
// Custom webhook template from the user's specification
|
|
2102
|
+
const customWebhookTemplate = JSON.stringify({
|
|
2103
|
+
variables: {
|
|
2104
|
+
ASSIGNEE_USER_ID: "{{object_attributes.assignee_id}}",
|
|
2105
|
+
OBJECT_DESCRIPTION: "{{object_attributes.description}}",
|
|
2106
|
+
},
|
|
2107
|
+
payload: {
|
|
2108
|
+
object_kind: "{{object_kind}}",
|
|
2109
|
+
event_type: "{{event_type}}",
|
|
2110
|
+
user_id: "{{user.id}}",
|
|
2111
|
+
user_name: "{{user.name}}",
|
|
2112
|
+
user_username: "{{user.username}}",
|
|
2113
|
+
user_avatar_url: "{{user.avatar_url}}",
|
|
2114
|
+
user_email: "{{user.email}}",
|
|
2115
|
+
project_id: "{{project.id}}",
|
|
2116
|
+
project_name: "{{project.name}}",
|
|
2117
|
+
project_web_url: "{{project.web_url}}",
|
|
2118
|
+
project_namespace: "{{project.namespace}}",
|
|
2119
|
+
project_path_with_namespace: "{{project.path_with_namespace}}",
|
|
2120
|
+
object_attributes_id: "{{object_attributes.id}}",
|
|
2121
|
+
object_attributes_iid: "{{object_attributes.iid}}",
|
|
2122
|
+
object_attributes_title: "{{object_attributes.title}}",
|
|
2123
|
+
object_attributes_description: "{{object_attributes.description}}",
|
|
2124
|
+
object_attributes_state: "{{object_attributes.state}}",
|
|
2125
|
+
object_attributes_created_at: "{{object_attributes.created_at}}",
|
|
2126
|
+
object_attributes_updated_at: "{{object_attributes.updated_at}}",
|
|
2127
|
+
object_attributes_url: "{{object_attributes.url}}",
|
|
2128
|
+
object_attributes_action: "{{object_attributes.action}}",
|
|
2129
|
+
object_attributes_noteable_type: "{{object_attributes.noteable_type}}",
|
|
2130
|
+
merge_request_id: "{{merge_request.id}}",
|
|
2131
|
+
merge_request_iid: "{{merge_request.iid}}",
|
|
2132
|
+
merge_request_title: "{{merge_request.title}}",
|
|
2133
|
+
merge_request_source_branch: "{{merge_request.source_branch}}",
|
|
2134
|
+
merge_request_time_estimate: "{{merge_request.time_estimate}}",
|
|
2135
|
+
//merge_request_description: "{{merge_request.description}}",
|
|
2136
|
+
merge_request_merge_status: "{{merge_request.merge_status}}",
|
|
2137
|
+
merge_request_last_commit_title: "{{merge_request.last_commit.title}}",
|
|
2138
|
+
merge_request_last_commit_message: "{{merge_request.last_commit.message}}",
|
|
2139
|
+
merge_request_last_commit_author_name: "{{merge_request.last_commit.author.name}}",
|
|
2140
|
+
merge_request_last_commit_author_email: "{{merge_request.last_commit.author.email}}",
|
|
2141
|
+
},
|
|
2142
|
+
});
|
|
2143
|
+
const webhookData = {
|
|
2144
|
+
url: webhookUrl,
|
|
2145
|
+
name: webhookName,
|
|
2146
|
+
description: `Agent webhook for ${agentName} - triggers pipeline with custom payload`,
|
|
2147
|
+
issues_events: true,
|
|
2148
|
+
confidential_issues_events: false,
|
|
2149
|
+
merge_requests_events: false,
|
|
2150
|
+
note_events: true,
|
|
2151
|
+
confidential_note_events: false,
|
|
2152
|
+
custom_webhook_template: customWebhookTemplate,
|
|
2153
|
+
};
|
|
2154
|
+
let webhook;
|
|
2155
|
+
if (existingWebhook) {
|
|
2156
|
+
instance.log(`Updating existing webhook: ${webhookName} (ID: ${existingWebhook.id})`);
|
|
2157
|
+
webhook = await updateWebhook(instance, projectId, existingWebhook.id, webhookData);
|
|
2158
|
+
instance.log(`✅ Updated webhook: ${webhook.name}`);
|
|
2159
|
+
}
|
|
2160
|
+
else {
|
|
2161
|
+
instance.log(`Creating new webhook: ${webhookName}`);
|
|
2162
|
+
webhook = await createWebhook(instance, projectId, webhookData);
|
|
2163
|
+
instance.log(`✅ Created webhook: ${webhook.name}`);
|
|
2164
|
+
}
|
|
2165
|
+
instance.log(` Webhook ID: ${webhook.id}`);
|
|
2166
|
+
instance.log(` Webhook URL: ${webhook.url}`);
|
|
2167
|
+
return webhook;
|
|
2168
|
+
};
|
|
2169
|
+
const setupAgentTriggerToken = async (instance, projectId, agentName) => {
|
|
2170
|
+
const tokenName = `cl_agent_${agentName}`;
|
|
2171
|
+
instance.log(`Setting up trigger token for agent: ${agentName}`);
|
|
2172
|
+
// List existing trigger tokens
|
|
2173
|
+
const existingTokens = await listTriggerTokens(instance, projectId);
|
|
2174
|
+
// Find and delete existing cl_agent_<agentName> tokens
|
|
2175
|
+
const existingAgentTokens = existingTokens.filter((token) => token.description.startsWith(`cl_agent_${agentName}`));
|
|
2176
|
+
for (const token of existingAgentTokens) {
|
|
2177
|
+
instance.log(`Deleting existing trigger token: ${token.description} (ID: ${token.id})`);
|
|
2178
|
+
await deleteTriggerToken(instance, projectId, token.id);
|
|
2179
|
+
}
|
|
2180
|
+
// Create new trigger token
|
|
2181
|
+
const description = `${tokenName} - Agent trigger token for ${agentName}`;
|
|
2182
|
+
const newToken = await createTriggerToken(instance, projectId, description);
|
|
2183
|
+
instance.log(`✅ Created new trigger token: ${newToken.description}`);
|
|
2184
|
+
instance.log(` Token ID: ${newToken.id}`);
|
|
2185
|
+
instance.log(` Token: ${newToken.token}`);
|
|
2186
|
+
return newToken;
|
|
2187
|
+
};
|
|
2188
|
+
const setupAgent = async (instance, agentName, agentConfig) => {
|
|
2189
|
+
const { id: projectId } = await (0, gitlab_1.getProjectInfo)(instance);
|
|
2190
|
+
instance.log(`🤖 Setting up agent: ${agentName}`);
|
|
2191
|
+
// Setup trigger token for this agent
|
|
2192
|
+
const triggerToken = await setupAgentTriggerToken(instance, projectId, agentName);
|
|
2193
|
+
// Setup webhook for this agent
|
|
2194
|
+
await setupAgentWebhook(instance, projectId, agentName, triggerToken.token);
|
|
2195
|
+
instance.log(`✅ Agent ${agentName} setup complete!`);
|
|
2196
|
+
};
|
|
2197
|
+
const setupAgents = async (instance) => {
|
|
2198
|
+
var _a;
|
|
2199
|
+
const config = await (0, getProjectConfig_1.getProjectConfig)();
|
|
2200
|
+
instance.log("");
|
|
2201
|
+
instance.log("🤖 Setting up agents...");
|
|
2202
|
+
const agents = (_a = config.agents) !== null && _a !== void 0 ? _a : {};
|
|
2203
|
+
const agentEntries = Object.entries(agents);
|
|
2204
|
+
if (agentEntries.length === 0) {
|
|
2205
|
+
instance.log("No agents configured in project config");
|
|
2206
|
+
return;
|
|
2207
|
+
}
|
|
2208
|
+
for (const [agentName, agentConfig] of agentEntries) {
|
|
2209
|
+
if (agentConfig.type === "claude" && agentConfig) {
|
|
2210
|
+
await setupAgent(instance, agentName, agentConfig);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
instance.log("✅ All agents setup complete!");
|
|
2214
|
+
instance.log("");
|
|
2215
|
+
instance.log("🔧 Manual setup required:");
|
|
2216
|
+
instance.log("Please configure these environment variables in GitLab CI/CD:");
|
|
2217
|
+
instance.log(" Go to Settings > CI/CD > Variables and add:");
|
|
2218
|
+
instance.log(" - ANTHROPIC_API_KEY (your Anthropic API key, mark as Protected & Masked)");
|
|
2219
|
+
instance.log(" - AGENT_GITLAB_PERSONAL_ACCESS_TOKEN (token from agent.claude user, mark as Protected & Masked)");
|
|
2220
|
+
};
|
|
2221
|
+
exports.setupAgents = setupAgents;
|
|
2222
|
+
//# sourceMappingURL=setupAgents.js.map
|
|
2223
|
+
|
|
2224
|
+
/***/ }),
|
|
2225
|
+
|
|
2062
2226
|
/***/ 1082:
|
|
2063
2227
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2064
2228
|
|
|
@@ -2608,7 +2772,7 @@ const getAllComponentsWithAllEnvsFlat = async () => {
|
|
|
2608
2772
|
if (!config) {
|
|
2609
2773
|
return [];
|
|
2610
2774
|
}
|
|
2611
|
-
return
|
|
2775
|
+
return getAllComponentsWithAllEnvsFlatFromConfig(config);
|
|
2612
2776
|
};
|
|
2613
2777
|
exports.getAllComponentsWithAllEnvsFlat = getAllComponentsWithAllEnvsFlat;
|
|
2614
2778
|
const getAllComponentsWithAllEnvsHierarchical = async () => {
|
|
@@ -2685,6 +2849,9 @@ const getJobOnlyEnvVarsResolved = async (vorpal, env, componentName) => {
|
|
|
2685
2849
|
]);
|
|
2686
2850
|
};
|
|
2687
2851
|
exports.getJobOnlyEnvVarsResolved = getJobOnlyEnvVarsResolved;
|
|
2852
|
+
function getAllComponentsWithAllEnvsFlatFromConfig(config) {
|
|
2853
|
+
return Object.keys(config.components).flatMap((componentName) => (0, pipeline_1.getAllEnvs)(config, componentName).map((env) => ({ env, componentName })));
|
|
2854
|
+
}
|
|
2688
2855
|
//# sourceMappingURL=getProjectConfig.js.map
|
|
2689
2856
|
|
|
2690
2857
|
/***/ }),
|
|
@@ -3932,7 +4099,7 @@ exports.joinBashExpressions = joinBashExpressions;
|
|
|
3932
4099
|
"use strict";
|
|
3933
4100
|
|
|
3934
4101
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3935
|
-
exports.escapeForDotEnv = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
|
|
4102
|
+
exports.escapeForDotEnv = exports.escapeNewlines = exports.escapeBackTicks = exports.escapeSingleQuotes = exports.escapeDoubleQuotes = exports.escapeBashExpression = exports.escapeString = exports.bashEscape = void 0;
|
|
3936
4103
|
const globalScriptFunctions_1 = __nccwpck_require__(12912);
|
|
3937
4104
|
const VariableValueContainingReferences_1 = __nccwpck_require__(84474);
|
|
3938
4105
|
const BashExpression_1 = __nccwpck_require__(42376);
|
|
@@ -3973,6 +4140,10 @@ const escapeDoubleQuotes = (value) => value === null || value === void 0 ? void
|
|
|
3973
4140
|
exports.escapeDoubleQuotes = escapeDoubleQuotes;
|
|
3974
4141
|
const escapeSingleQuotes = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/'/g, "\\'");
|
|
3975
4142
|
exports.escapeSingleQuotes = escapeSingleQuotes;
|
|
4143
|
+
const escapeBackTicks = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/`/g, "\\`");
|
|
4144
|
+
exports.escapeBackTicks = escapeBackTicks;
|
|
4145
|
+
const escapeNewlines = (value) => value === null || value === void 0 ? void 0 : value.toString().replace(/\n/g, "\\n");
|
|
4146
|
+
exports.escapeNewlines = escapeNewlines;
|
|
3976
4147
|
/**
|
|
3977
4148
|
*
|
|
3978
4149
|
* escape env vars for .env files.
|
|
@@ -8897,6 +9068,420 @@ __exportStar(__nccwpck_require__(22990), exports);
|
|
|
8897
9068
|
|
|
8898
9069
|
/***/ }),
|
|
8899
9070
|
|
|
9071
|
+
/***/ 32636:
|
|
9072
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
9073
|
+
|
|
9074
|
+
"use strict";
|
|
9075
|
+
|
|
9076
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9077
|
+
exports.createAgentContext = void 0;
|
|
9078
|
+
const createAgentContext = async (ctx) => {
|
|
9079
|
+
var _a;
|
|
9080
|
+
const agentConfig = (_a = ctx.config.agents) === null || _a === void 0 ? void 0 : _a[ctx.agentName];
|
|
9081
|
+
if (!agentConfig) {
|
|
9082
|
+
throw new Error(`Agent ${ctx.agentName} not found in config`);
|
|
9083
|
+
}
|
|
9084
|
+
return {
|
|
9085
|
+
type: "agent",
|
|
9086
|
+
name: ctx.agentName,
|
|
9087
|
+
//env: ctx.env,
|
|
9088
|
+
fullConfig: ctx.config,
|
|
9089
|
+
agentConfig: agentConfig,
|
|
9090
|
+
};
|
|
9091
|
+
};
|
|
9092
|
+
exports.createAgentContext = createAgentContext;
|
|
9093
|
+
//# sourceMappingURL=createAgentContext.js.map
|
|
9094
|
+
|
|
9095
|
+
/***/ }),
|
|
9096
|
+
|
|
9097
|
+
/***/ 99404:
|
|
9098
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9099
|
+
|
|
9100
|
+
"use strict";
|
|
9101
|
+
|
|
9102
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9103
|
+
exports.createAgentEventJob = void 0;
|
|
9104
|
+
const prompts_1 = __nccwpck_require__(88698);
|
|
9105
|
+
const shared_1 = __nccwpck_require__(10732);
|
|
9106
|
+
const utils_1 = __nccwpck_require__(89133);
|
|
9107
|
+
const createAgentEventJob = (context) => {
|
|
9108
|
+
const baseJob = (0, shared_1.createBaseAgentJob)(context);
|
|
9109
|
+
// unfortunatly, we need to manage both, because the "@mention"-feature only works with the username
|
|
9110
|
+
const agentUserId = (0, utils_1.getAgentUserId)(context);
|
|
9111
|
+
const agentUserName = (0, utils_1.getAgentUserName)(context);
|
|
9112
|
+
return {
|
|
9113
|
+
interruptible: false, // do not cancel this job if it is running. Otherwise a commit to main will cancel it
|
|
9114
|
+
...baseJob,
|
|
9115
|
+
variables: {
|
|
9116
|
+
...baseJob.variables,
|
|
9117
|
+
},
|
|
9118
|
+
name: context.name + "-agent-event",
|
|
9119
|
+
rules: [
|
|
9120
|
+
{
|
|
9121
|
+
if: `$CI_PIPELINE_SOURCE == "trigger" && ($ASSIGNEE_USER_ID == ${agentUserId} || $OBJECT_DESCRIPTION =~ /@${agentUserName}/)`,
|
|
9122
|
+
when: "always",
|
|
9123
|
+
},
|
|
9124
|
+
{
|
|
9125
|
+
when: "never",
|
|
9126
|
+
},
|
|
9127
|
+
],
|
|
9128
|
+
script: [
|
|
9129
|
+
...shared_1.baseSetupScript,
|
|
9130
|
+
...(0, shared_1.callClaude)({
|
|
9131
|
+
prompt: (0, prompts_1.getEventPrompt)({ agentUserName: agentUserName }),
|
|
9132
|
+
}),
|
|
9133
|
+
],
|
|
9134
|
+
};
|
|
9135
|
+
};
|
|
9136
|
+
exports.createAgentEventJob = createAgentEventJob;
|
|
9137
|
+
//# sourceMappingURL=createAgentEventJob.js.map
|
|
9138
|
+
|
|
9139
|
+
/***/ }),
|
|
9140
|
+
|
|
9141
|
+
/***/ 28672:
|
|
9142
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9143
|
+
|
|
9144
|
+
"use strict";
|
|
9145
|
+
|
|
9146
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9147
|
+
exports.createAgentReviewJob = void 0;
|
|
9148
|
+
const rules_1 = __nccwpck_require__(47551);
|
|
9149
|
+
const prompts_1 = __nccwpck_require__(88698);
|
|
9150
|
+
const shared_1 = __nccwpck_require__(10732);
|
|
9151
|
+
const utils_1 = __nccwpck_require__(89133);
|
|
9152
|
+
const createAgentReviewJob = (context) => {
|
|
9153
|
+
const baseJob = (0, shared_1.createBaseAgentJob)(context);
|
|
9154
|
+
const agentUserName = (0, utils_1.getAgentUserName)(context);
|
|
9155
|
+
return {
|
|
9156
|
+
...baseJob,
|
|
9157
|
+
name: context.name + "-agent-review",
|
|
9158
|
+
rules: [
|
|
9159
|
+
{
|
|
9160
|
+
...rules_1.RULE_IS_MERGE_REQUEST,
|
|
9161
|
+
when: "always",
|
|
9162
|
+
},
|
|
9163
|
+
{
|
|
9164
|
+
when: "never",
|
|
9165
|
+
},
|
|
9166
|
+
],
|
|
9167
|
+
script: [
|
|
9168
|
+
...shared_1.baseSetupScript,
|
|
9169
|
+
...(0, shared_1.callClaude)({
|
|
9170
|
+
prompt: (0, prompts_1.getMergeRequestPrompt)({
|
|
9171
|
+
agentUserName: agentUserName,
|
|
9172
|
+
}),
|
|
9173
|
+
}),
|
|
9174
|
+
],
|
|
9175
|
+
};
|
|
9176
|
+
};
|
|
9177
|
+
exports.createAgentReviewJob = createAgentReviewJob;
|
|
9178
|
+
//# sourceMappingURL=createAgentReviewJob.js.map
|
|
9179
|
+
|
|
9180
|
+
/***/ }),
|
|
9181
|
+
|
|
9182
|
+
/***/ 71455:
|
|
9183
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9184
|
+
|
|
9185
|
+
"use strict";
|
|
9186
|
+
|
|
9187
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9188
|
+
exports.createJobsForAgentContext = void 0;
|
|
9189
|
+
const createAgentEventJob_1 = __nccwpck_require__(99404);
|
|
9190
|
+
const createAgentReviewJob_1 = __nccwpck_require__(28672);
|
|
9191
|
+
const createJobsForAgentContext = (context) => {
|
|
9192
|
+
return [(0, createAgentEventJob_1.createAgentEventJob)(context), (0, createAgentReviewJob_1.createAgentReviewJob)(context)];
|
|
9193
|
+
};
|
|
9194
|
+
exports.createJobsForAgentContext = createJobsForAgentContext;
|
|
9195
|
+
//# sourceMappingURL=createJobsForAgentContext.js.map
|
|
9196
|
+
|
|
9197
|
+
/***/ }),
|
|
9198
|
+
|
|
9199
|
+
/***/ 88698:
|
|
9200
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
9201
|
+
|
|
9202
|
+
"use strict";
|
|
9203
|
+
|
|
9204
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9205
|
+
exports.getMergeRequestPrompt = exports.getEventPrompt = void 0;
|
|
9206
|
+
const header = () => `
|
|
9207
|
+
Project ID: $CI_PROJECT_ID
|
|
9208
|
+
GitLab Host: $CI_SERVER_URL
|
|
9209
|
+
`;
|
|
9210
|
+
const identity = ({ agentUserName }) => `
|
|
9211
|
+
## Identity
|
|
9212
|
+
- Your GitLab username is "${agentUserName}".
|
|
9213
|
+
`;
|
|
9214
|
+
const goldenRules = ({ agentUserName }) => `
|
|
9215
|
+
## Golden Rules
|
|
9216
|
+
- Use the \`gitlab-mcp\` tool for ALL GitLab actions. If a needed action is missing, use GitLab REST/GraphQL API directly as a fallback.
|
|
9217
|
+
- NEVER mention yourself ("@${agentUserName}").
|
|
9218
|
+
- NEVER push to main/default or any protected branch. Always create a new branch and open a Merge Request (MR).
|
|
9219
|
+
- Do not create an MR for a **closed** issue.
|
|
9220
|
+
- Keep actions minimal and idempotent. Avoid duplicate comments or duplicate MRs.
|
|
9221
|
+
- Use ONE stable \`source_branch\` per run; do not regenerate its name later.
|
|
9222
|
+
`;
|
|
9223
|
+
const commentGuidelines = () => `
|
|
9224
|
+
## Comment Guidelines (flexible, not verbatim)
|
|
9225
|
+
- Keep tone professional, friendly, and concise.
|
|
9226
|
+
- Always @-mention the human author when replying; never mention yourself.
|
|
9227
|
+
- Acknowledgements: confirm you saw the request and you’ll handle it.
|
|
9228
|
+
- MR updates: acknowledge feedback and say you’ll apply/have applied the change.
|
|
9229
|
+
- Q&A: answer directly first; add context/links only if useful.
|
|
9230
|
+
- Avoid repeating identical boilerplate across comments.
|
|
9231
|
+
`;
|
|
9232
|
+
const mcpAndApi = () => `
|
|
9233
|
+
## Tools & API (MCP-first, REST/GraphQL fallback)
|
|
9234
|
+
Use these \`gitlab-mcp\` capabilities when available (names illustrative—match the actual tool schema):
|
|
9235
|
+
|
|
9236
|
+
- **Comments**
|
|
9237
|
+
- \`gitlab-mcp.comment.create({ project_id: $CI_PROJECT_ID, target: "issue"|"mr", iid, body })\`
|
|
9238
|
+
|
|
9239
|
+
- **Branch**
|
|
9240
|
+
- \`gitlab-mcp.branch.create({ project_id: $CI_PROJECT_ID, from: "<default_branch>", name: "<source_branch>" })\`
|
|
9241
|
+
|
|
9242
|
+
- **Commits & push**
|
|
9243
|
+
- \`gitlab-mcp.commit.push({ project_id: $CI_PROJECT_ID, branch: "<source_branch>", message, files: [{ path, content | patch }] })\`
|
|
9244
|
+
|
|
9245
|
+
- **Merge Requests**
|
|
9246
|
+
- \`gitlab-mcp.merge_request.create({ project_id: $CI_PROJECT_ID, source_branch, target_branch: "<default_branch>", title, description, assign_to_self: true })\`
|
|
9247
|
+
- \`gitlab-mcp.merge_request.update({ project_id: $CI_PROJECT_ID, mr_iid, ... })\`
|
|
9248
|
+
- \`gitlab-mcp.merge_request.rebase({ project_id: $CI_PROJECT_ID, mr_iid, onto: "<default_branch>" })\`
|
|
9249
|
+
|
|
9250
|
+
- **Read/verify**
|
|
9251
|
+
- \`gitlab-mcp.project.get({ project_id: $CI_PROJECT_ID })\` → default branch
|
|
9252
|
+
- \`gitlab-mcp.repo.compare({ project_id: $CI_PROJECT_ID, from: "<default_branch>", to: "<source_branch>" })\`
|
|
9253
|
+
- \`gitlab-mcp.repo.branch.get({ project_id: $CI_PROJECT_ID, name: "<source_branch>" })\`
|
|
9254
|
+
- \`gitlab-mcp.repo.commits.list({ project_id: $CI_PROJECT_ID, ref_name: "<source_branch>", per_page: 1 })\`
|
|
9255
|
+
|
|
9256
|
+
### Fallback: Direct GitLab API
|
|
9257
|
+
If MCP lacks an operation, call GitLab’s REST/GraphQL API directly.
|
|
9258
|
+
|
|
9259
|
+
- **Authentication**
|
|
9260
|
+
Use the environment variable \`GITLAB_PERSONAL_ACCESS_TOKEN\`.
|
|
9261
|
+
Send it in the HTTP header:
|
|
9262
|
+
\`\`\`
|
|
9263
|
+
Private-Token: $GITLAB_PERSONAL_ACCESS_TOKEN
|
|
9264
|
+
\`\`\`
|
|
9265
|
+
|
|
9266
|
+
- **Host & project variables**
|
|
9267
|
+
- API base URL: \`$CI_SERVER_URL/api/v4\`
|
|
9268
|
+
- Project ID: \`$CI_PROJECT_ID\`
|
|
9269
|
+
|
|
9270
|
+
- **Examples**
|
|
9271
|
+
- Get project (default branch):
|
|
9272
|
+
\`GET $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID\`
|
|
9273
|
+
- Get/create branch:
|
|
9274
|
+
\`GET|POST $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/repository/branches\`
|
|
9275
|
+
- Compare refs:
|
|
9276
|
+
\`GET $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/repository/compare?from=<default>&to=<source>\`
|
|
9277
|
+
- List commits:
|
|
9278
|
+
\`GET $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/repository/commits?ref_name=<branch>&per_page=1\`
|
|
9279
|
+
- Create comment on issue/MR:
|
|
9280
|
+
\`POST $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/issues/:iid/notes\`
|
|
9281
|
+
\`POST $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/:iid/notes\`
|
|
9282
|
+
- Create MR:
|
|
9283
|
+
\`POST $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests\`
|
|
9284
|
+
- Get MR changes:
|
|
9285
|
+
\`GET $CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/merge_requests/:iid/changes\`
|
|
9286
|
+
`;
|
|
9287
|
+
const outputDiscipline = ({ agentUserName }) => `
|
|
9288
|
+
## Output Discipline
|
|
9289
|
+
- Prefer \`gitlab-mcp\` tool calls. If unavailable, output direct API requests (endpoint, method, headers, JSON body).
|
|
9290
|
+
- Keep comments concise and professional.
|
|
9291
|
+
- Never include "@${agentUserName}" in any body.
|
|
9292
|
+
`;
|
|
9293
|
+
// --- Event-specific sections ---
|
|
9294
|
+
const eventSelfParse = () => `
|
|
9295
|
+
## Self-Parse the Raw Payload (no preprocessing available)
|
|
9296
|
+
From \`event_json\`, extract:
|
|
9297
|
+
- kind: "issue" | "merge_request" | "note"
|
|
9298
|
+
- target + iid from URL:
|
|
9299
|
+
- \`/-/issues/<n>\` → target="issue", iid=<n>
|
|
9300
|
+
- \`/-/merge_requests/<n>\` → target="mr", iid=<n>
|
|
9301
|
+
- note_id if present (\`#note_<id>\`)
|
|
9302
|
+
- description/body text, state, author \`user_username\`, timestamps
|
|
9303
|
+
- project id/path; detect default branch via tool/API when needed
|
|
9304
|
+
|
|
9305
|
+
If any key is missing, choose the safest minimal action or briefly explain via a comment.
|
|
9306
|
+
`;
|
|
9307
|
+
const eventWorkflow = () => `
|
|
9308
|
+
## High-Reliability Workflow (sequence + postconditions)
|
|
9309
|
+
Follow this order for any change work:
|
|
9310
|
+
|
|
9311
|
+
1) **Acknowledge** with a short comment on the issue/MR thread.
|
|
9312
|
+
2) **Discover default branch** (e.g., "main") via MCP or API.
|
|
9313
|
+
3) **Create a working branch** from default (stable name, e.g., \`fix/issue-<iid>-<slug>\` or \`feat/issue-<iid>-<slug>\`).
|
|
9314
|
+
4) **Write changes → commit → push to remote branch.**
|
|
9315
|
+
5) **Verify push landed**:
|
|
9316
|
+
- Fetch latest commit on \`source_branch\`; record its short SHA.
|
|
9317
|
+
- Compare default vs \`source_branch\` and ensure \`diffs.length > 0\`.
|
|
9318
|
+
6) **Create or update MR** ONLY if there is a non-empty diff.
|
|
9319
|
+
- Include \`Closes #<issue_iid>\` in MR description when applicable.
|
|
9320
|
+
- Assign yourself to the MR.
|
|
9321
|
+
7) **Follow-up comment** with branch name, commit short SHA, files changed count, and MR link.
|
|
9322
|
+
8) **If verification fails**:
|
|
9323
|
+
- Do NOT create the MR.
|
|
9324
|
+
- Comment the exact failure and retry once with a fresh branch name. If still failing, comment and stop.
|
|
9325
|
+
|
|
9326
|
+
For Q&A-only (no code changes), just post a concise, helpful answer on the same issue/MR.
|
|
9327
|
+
`;
|
|
9328
|
+
// --- MR-specific sections ---
|
|
9329
|
+
const mrScope = ({ agentUserName }) => `
|
|
9330
|
+
## Identity & Scope
|
|
9331
|
+
- Your GitLab username is "${agentUserName}".
|
|
9332
|
+
- This prompt runs in the context of ONE MR (no webhook).
|
|
9333
|
+
- You may review, comment, rebase, and push updates **to the MR's source branch**.
|
|
9334
|
+
- You must **never merge** the MR yourself.
|
|
9335
|
+
`;
|
|
9336
|
+
const mrWorkflow = () => `
|
|
9337
|
+
## High-Reliability Review Workflow
|
|
9338
|
+
Follow this sequence with verification at each step:
|
|
9339
|
+
|
|
9340
|
+
1) **Collect context**
|
|
9341
|
+
- Get MR metadata (source_branch, target_branch, state, draft/WIP).
|
|
9342
|
+
- Fetch the full changeset/diffs and open discussions (notes, threads, unresolved discussions).
|
|
9343
|
+
- Read existing reviews/comments to avoid duplication.
|
|
9344
|
+
- (Optional) Fetch recent CI pipeline(s) for this MR SHA/branch).
|
|
9345
|
+
|
|
9346
|
+
2) **Code review**
|
|
9347
|
+
- Identify required changes (bugs, tests, style, security, perf, docs).
|
|
9348
|
+
- If no meaningful changes are needed:
|
|
9349
|
+
- Post a concise review comment summarizing findings.
|
|
9350
|
+
- Ask for review by a **recent active human contributor** (not you).
|
|
9351
|
+
|
|
9352
|
+
3) **If changes are needed**
|
|
9353
|
+
- Post a short acknowledgment comment on the MR.
|
|
9354
|
+
- **Rebase** the MR onto the target/default branch (resolve trivial conflicts).
|
|
9355
|
+
- Implement minimal, safe changes; keep commits small and clear.
|
|
9356
|
+
- **Push** to the MR's **source_branch**.
|
|
9357
|
+
- **Verify push landed** (latest commit short SHA; compare target vs source shows diffs > 0).
|
|
9358
|
+
- Comment summarizing what changed and why.
|
|
9359
|
+
|
|
9360
|
+
4) **CI pipeline**
|
|
9361
|
+
- Check pipeline status for the new commit on the MR branch.
|
|
9362
|
+
- Retry/re-run if allowed on flaky failures; fix minimal issues; push again if needed.
|
|
9363
|
+
- If still failing, comment with failure summary and next steps.
|
|
9364
|
+
|
|
9365
|
+
5) **Assign human reviewer if ready**
|
|
9366
|
+
- If discussions are resolved and CI is passing (or running), request review from a recent active human contributor (not you).
|
|
9367
|
+
|
|
9368
|
+
6) **Stdout summary**
|
|
9369
|
+
- Print concise summary: commits pushed (short SHAs), files changed count, discussions resolved/left, CI status, and requested reviewers.
|
|
9370
|
+
`;
|
|
9371
|
+
const fallbackApiAuth = () => `
|
|
9372
|
+
## Fallback API Auth (if MCP lacks a method)
|
|
9373
|
+
- Base URL: \`$CI_SERVER_URL/api/v4\`
|
|
9374
|
+
- Project: \`$CI_PROJECT_ID\`
|
|
9375
|
+
- Header: \`Private-Token: $GITLAB_PERSONAL_ACCESS_TOKEN\`
|
|
9376
|
+
`;
|
|
9377
|
+
// ---------- Public builders ----------
|
|
9378
|
+
const getEventPrompt = ({ agentUserName }) => `
|
|
9379
|
+
You are a GitLab assistant bot. You receive ONE raw GitLab webhook JSON payload.
|
|
9380
|
+
|
|
9381
|
+
${header()}
|
|
9382
|
+
---
|
|
9383
|
+
event_json:
|
|
9384
|
+
$(cat $TRIGGER_PAYLOAD)
|
|
9385
|
+
---
|
|
9386
|
+
|
|
9387
|
+
${identity({ agentUserName })}
|
|
9388
|
+
${goldenRules({ agentUserName })}
|
|
9389
|
+
${eventSelfParse()}
|
|
9390
|
+
${eventWorkflow()}
|
|
9391
|
+
${commentGuidelines()}
|
|
9392
|
+
${mcpAndApi()}
|
|
9393
|
+
${outputDiscipline({ agentUserName })}
|
|
9394
|
+
`;
|
|
9395
|
+
exports.getEventPrompt = getEventPrompt;
|
|
9396
|
+
const getMergeRequestPrompt = ({ agentUserName }) => `
|
|
9397
|
+
You are a GitLab assistant bot reviewing and updating a single Merge Request (MR).
|
|
9398
|
+
|
|
9399
|
+
${header()}
|
|
9400
|
+
---
|
|
9401
|
+
merge_request_iid: $CI_MERGE_REQUEST_IID
|
|
9402
|
+
title: $CI_MERGE_REQUEST_TITLE
|
|
9403
|
+
description: $CI_MERGE_REQUEST_DESCRIPTION
|
|
9404
|
+
---
|
|
9405
|
+
|
|
9406
|
+
${mrScope({ agentUserName })}
|
|
9407
|
+
${goldenRules({ agentUserName })}
|
|
9408
|
+
${mrWorkflow()}
|
|
9409
|
+
${commentGuidelines()}
|
|
9410
|
+
${mcpAndApi()}
|
|
9411
|
+
${fallbackApiAuth()}
|
|
9412
|
+
## Output Discipline (MR)
|
|
9413
|
+
- Prefer \`gitlab-mcp\` tool calls; if unavailable, provide explicit REST calls (method, url, headers, body).
|
|
9414
|
+
- At the end, print a **plain-text** summary to STDOUT including:
|
|
9415
|
+
- \`source_branch\` and \`target_branch\`
|
|
9416
|
+
- commits pushed (short SHAs)
|
|
9417
|
+
- number of files changed
|
|
9418
|
+
- CI status/result
|
|
9419
|
+
- reviewers requested (if any)
|
|
9420
|
+
- Do **not** merge the MR yourself under any circumstance.
|
|
9421
|
+
`;
|
|
9422
|
+
exports.getMergeRequestPrompt = getMergeRequestPrompt;
|
|
9423
|
+
//# sourceMappingURL=prompts.js.map
|
|
9424
|
+
|
|
9425
|
+
/***/ }),
|
|
9426
|
+
|
|
9427
|
+
/***/ 10732:
|
|
9428
|
+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
9429
|
+
|
|
9430
|
+
"use strict";
|
|
9431
|
+
|
|
9432
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9433
|
+
exports.callClaude = exports.baseSetupScript = exports.createBaseAgentJob = void 0;
|
|
9434
|
+
const bashEscape_1 = __nccwpck_require__(12463);
|
|
9435
|
+
const createBaseAgentJob = (context) => ({
|
|
9436
|
+
stage: "agents",
|
|
9437
|
+
envMode: "none",
|
|
9438
|
+
image: "node:24-alpine3.21",
|
|
9439
|
+
variables: {
|
|
9440
|
+
MAX_MCP_OUTPUT_TOKENS: "75000",
|
|
9441
|
+
GITLAB_PERSONAL_ACCESS_TOKEN: "$AGENT_GITLAB_PERSONAL_ACCESS_TOKEN", // TODO: we don't have global secret keys to configure yet
|
|
9442
|
+
GITLAB_API_URL: "$CI_API_V4_URL",
|
|
9443
|
+
},
|
|
9444
|
+
});
|
|
9445
|
+
exports.createBaseAgentJob = createBaseAgentJob;
|
|
9446
|
+
exports.baseSetupScript = [
|
|
9447
|
+
"apk update",
|
|
9448
|
+
"apk add --no-cache git curl bash",
|
|
9449
|
+
"npm install -g @anthropic-ai/claude-code",
|
|
9450
|
+
"claude mcp add gitlab --env GITLAB_PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN --env GITLAB_API_URL=$GITLAB_API_URL -- npx -y @zereight/mcp-gitlab",
|
|
9451
|
+
];
|
|
9452
|
+
const callClaude = ({ prompt }) => {
|
|
9453
|
+
return [
|
|
9454
|
+
`export PROMPT="${(0, bashEscape_1.escapeNewlines)((0, bashEscape_1.escapeDoubleQuotes)((0, bashEscape_1.escapeBackTicks)(prompt)))}"`,
|
|
9455
|
+
//'echo "$PROMPT"',
|
|
9456
|
+
`claude -p "$PROMPT" --permission-mode acceptEdits --allowedTools "Bash(*) Read(*) Edit(*) Write(*) mcp__gitlab" --verbose --debug`,
|
|
9457
|
+
];
|
|
9458
|
+
};
|
|
9459
|
+
exports.callClaude = callClaude;
|
|
9460
|
+
//# sourceMappingURL=shared.js.map
|
|
9461
|
+
|
|
9462
|
+
/***/ }),
|
|
9463
|
+
|
|
9464
|
+
/***/ 89133:
|
|
9465
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
9466
|
+
|
|
9467
|
+
"use strict";
|
|
9468
|
+
|
|
9469
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9470
|
+
exports.getAgentUserId = exports.getAgentUserName = void 0;
|
|
9471
|
+
const getAgentUserName = (context) => {
|
|
9472
|
+
var _a, _b;
|
|
9473
|
+
return (_b = (_a = context.agentConfig.agentUser) === null || _a === void 0 ? void 0 : _a.username) !== null && _b !== void 0 ? _b : "agent.claude";
|
|
9474
|
+
};
|
|
9475
|
+
exports.getAgentUserName = getAgentUserName;
|
|
9476
|
+
const getAgentUserId = (context) => {
|
|
9477
|
+
var _a, _b;
|
|
9478
|
+
return (_b = (_a = context.agentConfig.agentUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : "$DEFAULT_AGENT_USER_ID";
|
|
9479
|
+
};
|
|
9480
|
+
exports.getAgentUserId = getAgentUserId;
|
|
9481
|
+
//# sourceMappingURL=utils.js.map
|
|
9482
|
+
|
|
9483
|
+
/***/ }),
|
|
9484
|
+
|
|
8900
9485
|
/***/ 73579:
|
|
8901
9486
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
8902
9487
|
|
|
@@ -8909,8 +9494,10 @@ const createWorkspaceContext_1 = __nccwpck_require__(76558);
|
|
|
8909
9494
|
const types_1 = __nccwpck_require__(11853);
|
|
8910
9495
|
const createJobsForComponent_1 = __nccwpck_require__(92321);
|
|
8911
9496
|
const createJobsForWorkspace_1 = __nccwpck_require__(70803);
|
|
9497
|
+
const createJobsForAgentContext_1 = __nccwpck_require__(71455);
|
|
9498
|
+
const createAgentContext_1 = __nccwpck_require__(32636);
|
|
8912
9499
|
const createAllJobs = async ({ config, trigger, pipelineType, }) => {
|
|
8913
|
-
var _a;
|
|
9500
|
+
var _a, _b;
|
|
8914
9501
|
const allComponentsContext = await (0, createAllComponentsContext_1.createAllComponentsContext)({
|
|
8915
9502
|
config,
|
|
8916
9503
|
trigger,
|
|
@@ -8942,6 +9529,13 @@ const createAllJobs = async ({ config, trigger, pipelineType, }) => {
|
|
|
8942
9529
|
jobs: (0, createJobsForComponent_1.createJobsForComponentContext)(context),
|
|
8943
9530
|
};
|
|
8944
9531
|
}),
|
|
9532
|
+
agents: await Promise.all(Object.keys((_b = config.agents) !== null && _b !== void 0 ? _b : {}).map(async (agentName) => {
|
|
9533
|
+
const context = await (0, createAgentContext_1.createAgentContext)({ agentName, config });
|
|
9534
|
+
return {
|
|
9535
|
+
context,
|
|
9536
|
+
jobs: (0, createJobsForAgentContext_1.createJobsForAgentContext)(context),
|
|
9537
|
+
};
|
|
9538
|
+
})).then((f) => f.flat()),
|
|
8945
9539
|
};
|
|
8946
9540
|
};
|
|
8947
9541
|
exports.createAllJobs = createAllJobs;
|
|
@@ -9046,7 +9640,12 @@ const createMainPipeline = async (pipelineType, config) => {
|
|
|
9046
9640
|
const bIndex = componentNames.findIndex((c) => c === b.context.name);
|
|
9047
9641
|
return aIndex - bIndex;
|
|
9048
9642
|
});
|
|
9049
|
-
const
|
|
9643
|
+
const allGlobalJobs = allJobsPerTrigger.filter((j) => { var _a; return ((_a = j.context) === null || _a === void 0 ? void 0 : _a.type) === "agent"; });
|
|
9644
|
+
const allJobs = [
|
|
9645
|
+
...allWorkspaceJobs,
|
|
9646
|
+
...allComponentJobs,
|
|
9647
|
+
...allGlobalJobs,
|
|
9648
|
+
].reduce((acc, { gitlabJob, name, context }) => {
|
|
9050
9649
|
var _a, _b;
|
|
9051
9650
|
// merge jobs, if a job is already there, merge the rules
|
|
9052
9651
|
// this is currently needed because of envMode: "none", which creates the same job for all triggers, so it can appear multiple times
|
|
@@ -9085,12 +9684,16 @@ function getGitlabRulesForTrigger(trigger) {
|
|
|
9085
9684
|
// taggedRelease: on tag
|
|
9086
9685
|
switch (trigger) {
|
|
9087
9686
|
case "mainBranch":
|
|
9088
|
-
return [
|
|
9687
|
+
return [
|
|
9688
|
+
rules_1.RULE_NEVER_ON_AGENT_TRIGGER,
|
|
9689
|
+
rules_1.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT,
|
|
9690
|
+
];
|
|
9089
9691
|
case "mr":
|
|
9090
|
-
return [rules_1.RULE_IS_MERGE_REQUEST];
|
|
9692
|
+
return [rules_1.RULE_NEVER_ON_AGENT_TRIGGER, rules_1.RULE_IS_MERGE_REQUEST];
|
|
9091
9693
|
case "taggedRelease":
|
|
9092
|
-
return [rules_1.RULE_IS_TAGGED_RELEASE];
|
|
9694
|
+
return [rules_1.RULE_NEVER_ON_AGENT_TRIGGER, rules_1.RULE_IS_TAGGED_RELEASE];
|
|
9093
9695
|
}
|
|
9696
|
+
throw new Error(`${trigger} is not supported`);
|
|
9094
9697
|
}
|
|
9095
9698
|
//# sourceMappingURL=createMainPipeline.js.map
|
|
9096
9699
|
|
|
@@ -9228,7 +9831,7 @@ const BashExpression_1 = __nccwpck_require__(42376);
|
|
|
9228
9831
|
exports.GITLAB_ENVIRONMENT_URL_VARIABLE = "CL_GITLAB_ENVIRONMENT_URL";
|
|
9229
9832
|
const getFullJobName = ({ type, name, baseName, allJobs, env, }) => {
|
|
9230
9833
|
const shouldAddIcon = allJobs.workspaces.length > 0;
|
|
9231
|
-
const icon = type === "component" ? "🔹" : "🔸";
|
|
9834
|
+
const icon = type === "component" ? "🔹" : type === "agent" ? "🤖" : "🔸";
|
|
9232
9835
|
const prefix = shouldAddIcon ? icon + " " : "";
|
|
9233
9836
|
if (env) {
|
|
9234
9837
|
return `${prefix}${baseName} ${name} | ${env} `;
|
|
@@ -9271,13 +9874,15 @@ const getJobName = (need) => (0, lodash_1.isObject)(need) ? need.job : need;
|
|
|
9271
9874
|
const makeGitlabJob = (context, job, allJobs, baseRules) => {
|
|
9272
9875
|
var _a, _b;
|
|
9273
9876
|
const { environment, envMode, needsStages, name, needs, jobTags, script, variables, runnerVariables, when, ...rest } = job;
|
|
9274
|
-
const stage = envMode === "stagePerEnv"
|
|
9877
|
+
const stage = envMode === "stagePerEnv" && context.type !== "agent"
|
|
9878
|
+
? `${job.stage} ${context.env}`
|
|
9879
|
+
: job.stage;
|
|
9275
9880
|
const deduplicatedGitlabNeeds = getGitlabNeeds(context, job, allJobs);
|
|
9276
9881
|
const fullJobName = getFullJobName({
|
|
9277
9882
|
type: context.type,
|
|
9278
9883
|
name,
|
|
9279
9884
|
baseName: context.name,
|
|
9280
|
-
env: envMode !== "none" ? context.env : undefined,
|
|
9885
|
+
env: envMode !== "none" && context.type !== "agent" ? context.env : undefined,
|
|
9281
9886
|
allJobs,
|
|
9282
9887
|
});
|
|
9283
9888
|
// backwards compatibility, some may still use KUBERNETES_CPU_REQUEST, KUBERNETES_MEMORY_REQUEST, etc. in variables.
|
|
@@ -9310,6 +9915,8 @@ const makeGitlabJob = (context, job, allJobs, baseRules) => {
|
|
|
9310
9915
|
: []),
|
|
9311
9916
|
];
|
|
9312
9917
|
const gitlabJob = {
|
|
9918
|
+
retry: defaults_1.BASE_RETRY,
|
|
9919
|
+
interruptible: true,
|
|
9313
9920
|
...rest,
|
|
9314
9921
|
rules: rules.length > 0 ? rules : undefined,
|
|
9315
9922
|
variables: {
|
|
@@ -9321,8 +9928,6 @@ const makeGitlabJob = (context, job, allJobs, baseRules) => {
|
|
|
9321
9928
|
stage,
|
|
9322
9929
|
// sort in a predictable manner for snapshot tests
|
|
9323
9930
|
needs: deduplicatedGitlabNeeds,
|
|
9324
|
-
retry: defaults_1.BASE_RETRY,
|
|
9325
|
-
interruptible: true,
|
|
9326
9931
|
};
|
|
9327
9932
|
const modified = addGitlabEnvironment(context, environment, gitlabJob, allJobs);
|
|
9328
9933
|
return [fullJobName, (0, removeUndefined_1.removeUndefined)(modified)];
|
|
@@ -9334,7 +9939,7 @@ const addGitlabEnvironment = (context, catladderJobEnvironment, job, allJobs) =>
|
|
|
9334
9939
|
return job;
|
|
9335
9940
|
}
|
|
9336
9941
|
if (context.type !== "component") {
|
|
9337
|
-
// don't add enviornment for workspace jobs atm.
|
|
9942
|
+
// don't add enviornment for workspace and agent jobs atm.
|
|
9338
9943
|
return job;
|
|
9339
9944
|
}
|
|
9340
9945
|
const { env, name, environment } = context;
|
|
@@ -9376,7 +9981,11 @@ const addGitlabEnvironment = (context, catladderJobEnvironment, job, allJobs) =>
|
|
|
9376
9981
|
};
|
|
9377
9982
|
const createGitlabJobs = async (allJobs, baseRules) => {
|
|
9378
9983
|
// TODO: add workspace jobs
|
|
9379
|
-
return [
|
|
9984
|
+
return [
|
|
9985
|
+
...allJobs.workspaces,
|
|
9986
|
+
...allJobs.components,
|
|
9987
|
+
...allJobs.agents,
|
|
9988
|
+
].flatMap(({ context, jobs }) => {
|
|
9380
9989
|
return jobs.map((job) => {
|
|
9381
9990
|
const [fullJobName, gitlabJob] = (0, exports.makeGitlabJob)(context, job, allJobs, baseRules);
|
|
9382
9991
|
return {
|
|
@@ -9389,10 +9998,13 @@ const createGitlabJobs = async (allJobs, baseRules) => {
|
|
|
9389
9998
|
};
|
|
9390
9999
|
exports.createGitlabJobs = createGitlabJobs;
|
|
9391
10000
|
function getGitlabNeeds(context, job, allJobs) {
|
|
10001
|
+
var _a;
|
|
9392
10002
|
const needs = context.type === "workspace"
|
|
9393
10003
|
? getGitlabNeedsForWorkspaceJob(context, job, allJobs)
|
|
9394
|
-
:
|
|
9395
|
-
|
|
10004
|
+
: context.type === "agent"
|
|
10005
|
+
? ((_a = job.needs) !== null && _a !== void 0 ? _a : null)
|
|
10006
|
+
: getGitlabNeedsForComponentJob(context, job, allJobs);
|
|
10007
|
+
return needs ? deduplicateNeeds(needs) : undefined;
|
|
9396
10008
|
}
|
|
9397
10009
|
function deduplicateNeeds(needs) {
|
|
9398
10010
|
return needs
|
|
@@ -9514,6 +10126,13 @@ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...
|
|
|
9514
10126
|
workflow: {
|
|
9515
10127
|
name: "$PIPELINE_ICON $PIPELINE_NAME",
|
|
9516
10128
|
rules: [
|
|
10129
|
+
{
|
|
10130
|
+
if: '$CI_PIPELINE_SOURCE == "trigger"',
|
|
10131
|
+
variables: {
|
|
10132
|
+
PIPELINE_ICON: "🤖",
|
|
10133
|
+
PIPELINE_NAME: "Thinking...",
|
|
10134
|
+
},
|
|
10135
|
+
},
|
|
9517
10136
|
{
|
|
9518
10137
|
if: rules_1.RULE_IS_MERGE_REQUEST.if,
|
|
9519
10138
|
variables: {
|
|
@@ -9532,7 +10151,7 @@ const createGitlabPipelineWithDefaults = ({ image, variables, before_script, ...
|
|
|
9532
10151
|
if: rules_1.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT.if,
|
|
9533
10152
|
variables: {
|
|
9534
10153
|
PIPELINE_ICON: "🐱🔨",
|
|
9535
|
-
PIPELINE_NAME: "Main
|
|
10154
|
+
PIPELINE_NAME: "Main",
|
|
9536
10155
|
},
|
|
9537
10156
|
},
|
|
9538
10157
|
{
|
|
@@ -9812,7 +10431,7 @@ exports.getWorkspaceDependencies = getWorkspaceDependencies;
|
|
|
9812
10431
|
"use strict";
|
|
9813
10432
|
|
|
9814
10433
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9815
|
-
exports.RULES_MANUAL_RELEASE = exports.RULES_RELEASE = exports.RULE_CONDITION_HOTFIX_BRANCH = exports.RULE_IS_TAGGED_RELEASE = exports.RULE_IS_MERGE_REQUEST = exports.RULE_NEVER_ON_SCHEDULE = exports.RULE_NEVER_ON_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH = exports.RULE_CONDITION_NOT_RELEASE_COMMIT = exports.RULE_CONDITION_RELEASE_COMMIT = exports.RULE_CONDITION_MAIN_BRANCH = void 0;
|
|
10434
|
+
exports.RULES_MANUAL_RELEASE = exports.RULES_RELEASE = exports.RULE_CONDITION_HOTFIX_BRANCH = exports.RULE_IS_TAGGED_RELEASE = exports.RULE_IS_MERGE_REQUEST = exports.RULE_NEVER_ON_SCHEDULE = exports.RULE_NEVER_ON_AGENT_TRIGGER = exports.RULE_NEVER_ON_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH_AND_NOT_RELEASE_COMMIT = exports.RULE_IS_MAIN_BRANCH = exports.RULE_CONDITION_NOT_RELEASE_COMMIT = exports.RULE_CONDITION_RELEASE_COMMIT = exports.RULE_CONDITION_MAIN_BRANCH = void 0;
|
|
9816
10435
|
exports.RULE_CONDITION_MAIN_BRANCH = "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH";
|
|
9817
10436
|
exports.RULE_CONDITION_RELEASE_COMMIT = "$CI_COMMIT_MESSAGE =~ /^chore\\(release\\).*/";
|
|
9818
10437
|
exports.RULE_CONDITION_NOT_RELEASE_COMMIT = "$CI_COMMIT_MESSAGE !~ /^chore\\(release\\).*/";
|
|
@@ -9826,6 +10445,11 @@ exports.RULE_NEVER_ON_RELEASE_COMMIT = {
|
|
|
9826
10445
|
if: exports.RULE_CONDITION_RELEASE_COMMIT,
|
|
9827
10446
|
when: "never",
|
|
9828
10447
|
};
|
|
10448
|
+
// currently, we consider all triggered pipelines as agent triggers
|
|
10449
|
+
exports.RULE_NEVER_ON_AGENT_TRIGGER = {
|
|
10450
|
+
if: '$CI_PIPELINE_SOURCE == "trigger"',
|
|
10451
|
+
when: "never",
|
|
10452
|
+
};
|
|
9829
10453
|
exports.RULE_NEVER_ON_SCHEDULE = {
|
|
9830
10454
|
if: '$CI_PIPELINE_SOURCE == "schedule"',
|
|
9831
10455
|
when: "never",
|
|
@@ -9839,6 +10463,7 @@ exports.RULE_IS_TAGGED_RELEASE = {
|
|
|
9839
10463
|
exports.RULE_CONDITION_HOTFIX_BRANCH = "$CI_COMMIT_BRANCH =~ /^[0-9]+.([0-9]+|x).x$/";
|
|
9840
10464
|
exports.RULES_RELEASE = [
|
|
9841
10465
|
exports.RULE_NEVER_ON_RELEASE_COMMIT,
|
|
10466
|
+
exports.RULE_NEVER_ON_AGENT_TRIGGER,
|
|
9842
10467
|
exports.RULE_NEVER_ON_SCHEDULE,
|
|
9843
10468
|
{
|
|
9844
10469
|
if: exports.RULE_CONDITION_MAIN_BRANCH + ' && $AUTO_RELEASE == "true"',
|
|
@@ -9855,6 +10480,7 @@ exports.RULES_RELEASE = [
|
|
|
9855
10480
|
];
|
|
9856
10481
|
exports.RULES_MANUAL_RELEASE = [
|
|
9857
10482
|
exports.RULE_NEVER_ON_RELEASE_COMMIT,
|
|
10483
|
+
exports.RULE_NEVER_ON_AGENT_TRIGGER,
|
|
9858
10484
|
exports.RULE_NEVER_ON_SCHEDULE,
|
|
9859
10485
|
{
|
|
9860
10486
|
if: exports.RULE_CONDITION_MAIN_BRANCH,
|
|
@@ -9883,6 +10509,16 @@ exports.getRunnerImage = getRunnerImage;
|
|
|
9883
10509
|
|
|
9884
10510
|
/***/ }),
|
|
9885
10511
|
|
|
10512
|
+
/***/ 69632:
|
|
10513
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
10514
|
+
|
|
10515
|
+
"use strict";
|
|
10516
|
+
|
|
10517
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
10518
|
+
//# sourceMappingURL=agent.js.map
|
|
10519
|
+
|
|
10520
|
+
/***/ }),
|
|
10521
|
+
|
|
9886
10522
|
/***/ 47770:
|
|
9887
10523
|
/***/ ((__unused_webpack_module, exports) => {
|
|
9888
10524
|
|
|
@@ -9990,6 +10626,7 @@ __exportStar(__nccwpck_require__(61724), exports);
|
|
|
9990
10626
|
__exportStar(__nccwpck_require__(28207), exports);
|
|
9991
10627
|
__exportStar(__nccwpck_require__(32074), exports);
|
|
9992
10628
|
__exportStar(__nccwpck_require__(17432), exports);
|
|
10629
|
+
__exportStar(__nccwpck_require__(69632), exports);
|
|
9993
10630
|
//# sourceMappingURL=index.js.map
|
|
9994
10631
|
|
|
9995
10632
|
/***/ }),
|
|
@@ -10017,6 +10654,7 @@ exports.BASE_STAGES = [
|
|
|
10017
10654
|
"build",
|
|
10018
10655
|
"deploy",
|
|
10019
10656
|
"verify",
|
|
10657
|
+
"agents",
|
|
10020
10658
|
"rollback",
|
|
10021
10659
|
"stop",
|
|
10022
10660
|
];
|