Skip to content

Commit 38d6267

Browse files
chore: sync actions from [email protected] (#188)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 0520543 commit 38d6267

31 files changed

Lines changed: 994 additions & 295 deletions

‎setup/js/add_labels.cjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const main = createCountGatedHandler({
4444
handlerType: HANDLER_TYPE,
4545
setup: async (config, maxCount, isStaged) => {
4646
const { allowed: allowedLabels = [], blocked: blockedPatterns = [] } = config;
47+
const issueIntentEnabled = config.issue_intent === true;
4748
const requiredLabels = Array.isArray(config.required_labels) ? config.required_labels : [];
4849
const requiredTitlePrefix = config.required_title_prefix || "";
4950
const { defaultTargetRepo, allowedRepos } = resolveTargetRepoConfig(config);
@@ -190,7 +191,7 @@ const main = createCountGatedHandler({
190191
const labelsRequestPayload = uniqueLabels.map(name => {
191192
const labelSpec = requestedLabelSpecByLowerName.get(name.toLowerCase()) ?? { name };
192193
const hasIntentMetadata = Boolean(labelSpec.rationale || labelSpec.confidence || labelSpec.suggest);
193-
return hasIntentMetadata ? labelSpec : labelSpec.name;
194+
return issueIntentEnabled && hasIntentMetadata ? labelSpec : labelSpec.name;
194195
});
195196

196197
core.info(`Adding ${uniqueLabels.length} labels to ${contextType} #${itemNumber} in ${itemRepo}: ${JSON.stringify(labelsRequestPayload)}`);

‎setup/js/assign_agent_helpers.cjs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ async function getPullRequestDetails(owner, repo, pullNumber, githubClient = git
332332
* @param {Object} [githubClient] - Authenticated GitHub client (defaults to global github)
333333
* @param {{owner: string, repo: string, type: "issue"|"pull", number: number}|null} [taskContext] - Source issue/PR context for REST path
334334
* @param {string|null} [pullRequestRepoSlug] - Optional pull request repository slug (owner/repo) for REST path
335+
* @param {{rationale?: string, confidence?: "LOW"|"MEDIUM"|"HIGH", suggest?: boolean}} [intentMetadata] - Optional issue-intent metadata
336+
* @param {boolean} [useIssueIntent] - Whether to include issue-intent metadata/headers
335337
* @returns {Promise<boolean>} True if successful
336338
*/
337339
async function assignAgentToIssue(
@@ -346,7 +348,9 @@ async function assignAgentToIssue(
346348
baseBranch = null,
347349
githubClient = github,
348350
taskContext = null,
349-
pullRequestRepoSlug = null
351+
pullRequestRepoSlug = null,
352+
intentMetadata = {},
353+
useIssueIntent = true
350354
) {
351355
// SECURITY: pullRequestRepoSlug specifies a cross-repo target repository slug.
352356
// Callers MUST validate the corresponding repository slug against allowedRepos using
@@ -391,12 +395,16 @@ async function assignAgentToIssue(
391395

392396
try {
393397
core.info(`Assigning via issues assignees REST API with login: ${agentLogin}`);
394-
await githubClient.request("POST /repos/{owner}/{repo}/issues/{issue_number}/assignees", {
398+
const assignParams = {
395399
owner: targetOwner,
396400
repo: targetRepo,
397401
issue_number: issueNumber,
398402
assignees: [agentLogin],
399-
});
403+
};
404+
if (useIssueIntent && intentMetadata && Object.keys(intentMetadata).length > 0) {
405+
Object.assign(assignParams, intentMetadata);
406+
}
407+
await githubClient.request("POST /repos/{owner}/{repo}/issues/{issue_number}/assignees", assignParams);
400408
return true;
401409
} catch (error) {
402410
const errorMessage = getErrorMessage(error);

‎setup/js/assign_to_agent.cjs‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const { sleep } = require("./error_recovery.cjs");
1010
const { parseAllowedRepos, validateRepo, resolveTargetRepoConfig, resolveAndValidateRepo } = require("./repo_helpers.cjs");
1111
const { resolvePullRequestRepo } = require("./pr_helpers.cjs");
1212
const { sanitizeContent } = require("./sanitize_content.cjs");
13+
const { normalizeIssueIntentMetadata } = require("./issue_intents.cjs");
1314

1415
/**
1516
* Module-level state — populated by main(), read by the exported getters below.
@@ -64,6 +65,7 @@ async function main(config = {}) {
6465
const configuredBaseBranch = config["base-branch"] ? String(config["base-branch"]).trim() : null;
6566
const targetConfig = config.target ? String(config.target).trim() : "triggering";
6667
const ignoreIfError = config["ignore-if-error"] === true || config["ignore-if-error"] === "true";
68+
const issueIntentEnabled = config.issue_intent !== false;
6769
const allowedAgents = config.allowed
6870
? Array.isArray(config.allowed)
6971
? config.allowed.map(a => String(a).trim()).filter(Boolean)
@@ -87,6 +89,7 @@ async function main(config = {}) {
8789
if (configuredBaseBranch) core.info(`Configured base branch: ${configuredBaseBranch}`);
8890
core.info(`Target configuration: ${targetConfig}`);
8991
core.info(`Max count: ${maxCount}`);
92+
core.info(`Issue intent enabled: ${issueIntentEnabled}`);
9093
if (ignoreIfError) core.info("Ignore-if-error mode enabled: Will not fail if agent assignment encounters auth or availability errors");
9194
if (allowedAgents) core.info(`Allowed agents: ${allowedAgents.join(", ")}`);
9295
core.info(`Default target repo: ${defaultTargetRepo}`);
@@ -179,6 +182,7 @@ async function main(config = {}) {
179182
}
180183

181184
const agentName = message.agent ?? defaultAgent;
185+
const intentMetadata = issueIntentEnabled ? normalizeIssueIntentMetadata(message) : {};
182186
const model = defaultModel;
183187
const customAgent = defaultCustomAgent;
184188
const customInstructions = defaultCustomInstructions || null;
@@ -387,7 +391,22 @@ async function main(config = {}) {
387391
if (customInstructions) core.info(`Using custom instructions: ${customInstructions.substring(0, 100)}${customInstructions.length > 100 ? "..." : ""}`);
388392
if (effectiveBaseBranch) core.info(`Using base branch: ${effectiveBaseBranch}`);
389393

390-
const success = await assignAgentToIssue(assignableId, agentLogin, currentAssignees, agentName, allowedAgents, model, customAgent, customInstructions, effectiveBaseBranch, githubClient, taskContext, effectivePullRequestRepoSlug);
394+
const success = await assignAgentToIssue(
395+
assignableId,
396+
agentLogin,
397+
currentAssignees,
398+
agentName,
399+
allowedAgents,
400+
model,
401+
customAgent,
402+
customInstructions,
403+
effectiveBaseBranch,
404+
githubClient,
405+
taskContext,
406+
effectivePullRequestRepoSlug,
407+
intentMetadata,
408+
issueIntentEnabled
409+
);
391410
if (!success) throw new Error(`Failed to assign ${agentName} via REST`);
392411

393412
core.info(`Successfully assigned ${agentName} coding agent to ${type} #${number}`);

‎setup/js/assign_to_user.cjs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const { logStagedPreviewInfo } = require("./staged_preview.cjs");
1313
const { parseBoolTemplatable } = require("./templatable.cjs");
1414
const { createAuthenticatedGitHubClient } = require("./handler_auth.cjs");
1515
const { createCountGatedHandler } = require("./handler_scaffold.cjs");
16+
const { normalizeIssueIntentMetadata } = require("./issue_intents.cjs");
1617

1718
/** @type {string} Safe output type handled by this module */
1819
const HANDLER_TYPE = "assign_to_user";
@@ -29,14 +30,15 @@ const main = createCountGatedHandler({
2930
const allowedAssignees = config.allowed ?? [];
3031
const blockedAssignees = config.blocked ?? [];
3132
const unassignFirst = parseBoolTemplatable(config.unassign_first, false);
33+
const issueIntentEnabled = config.issue_intent !== false;
3234
const { defaultTargetRepo, allowedRepos } = resolveTargetRepoConfig(config);
3335
const githubClient = await createAuthenticatedGitHubClient(config);
3436
const requiredLabels = Array.isArray(config.required_labels) ? config.required_labels : [];
3537
const requiredTitlePrefix = config.required_title_prefix || "";
3638
if (requiredLabels.length > 0) core.info(`Required labels (all): ${requiredLabels.join(", ")}`);
3739
if (requiredTitlePrefix) core.info(`Required title prefix: ${requiredTitlePrefix}`);
3840

39-
core.info(`Assign to user configuration: max=${maxCount}, unassign_first=${unassignFirst}`);
41+
core.info(`Assign to user configuration: max=${maxCount}, unassign_first=${unassignFirst}, issue_intent=${issueIntentEnabled}`);
4042
if (allowedAssignees.length > 0) {
4143
core.info(`Allowed assignees: ${allowedAssignees.join(", ")}`);
4244
}
@@ -68,6 +70,7 @@ const main = createCountGatedHandler({
6870
core.info(`Target repository: ${itemRepo}`);
6971

7072
const assignItem = message;
73+
const intentMetadata = issueIntentEnabled ? normalizeIssueIntentMetadata(assignItem) : {};
7174

7275
// Determine issue number using shared helper
7376
const issueResult = resolveIssueNumber(assignItem);
@@ -147,12 +150,16 @@ const main = createCountGatedHandler({
147150
}
148151

149152
// Add assignees to the issue
150-
await githubClient.rest.issues.addAssignees({
153+
const addAssigneesParams = {
151154
owner: repoParts.owner,
152155
repo: repoParts.repo,
153156
issue_number: issueNumber,
154157
assignees: uniqueAssignees,
155-
});
158+
};
159+
if (issueIntentEnabled && Object.keys(intentMetadata).length > 0) {
160+
Object.assign(addAssigneesParams, intentMetadata);
161+
}
162+
await githubClient.rest.issues.addAssignees(addAssigneesParams);
156163

157164
core.info(`Successfully assigned ${uniqueAssignees.length} user(s) to issue #${issueNumber} in ${itemRepo}`);
158165

‎setup/js/claude_harness.cjs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const {
5151
} = require("./awf_reflect.cjs");
5252
const { emitMissingToolPermissionIssue, hasExpectedSafeOutputs, hasNoopInSafeOutputs } = require("./safeoutputs_cli.cjs");
5353
const { countPermissionDeniedIssues, hasNumerousPermissionDeniedIssues, extractDeniedCommands, buildMissingToolPermissionIssuePayload } = require("./permission_denied_helpers.cjs");
54-
const { detectNonRetryableHarnessGuard, buildSoftTimeoutGuard, emitSoftTimeoutSignal } = require("./harness_retry_guard.cjs");
54+
const { detectNonRetryableHarnessGuard, buildSoftTimeoutGuard, emitSoftTimeoutSignal, isAuthenticationFailedError } = require("./harness_retry_guard.cjs");
5555
const { MODEL_NOT_SUPPORTED_PATTERN: INVALID_MODEL_ERROR_PATTERN } = require("./detect_agent_errors.cjs");
5656

5757
// Pattern to detect Anthropic API overload errors (HTTP 529).
@@ -65,7 +65,6 @@ const OVERLOADED_ERROR_PATTERN = /overloaded_error|"overloaded"/i;
6565
// - embedded stream-json result fields (e.g. "api_error_status":429)
6666
// - human-readable message text ("rate limit")
6767
const RATE_LIMIT_ERROR_PATTERN = /rate_limit_error|429 Too Many Requests|"api_error_status"\s*:\s*429|request rejected \(429\)|rate limit/i;
68-
const AUTHENTICATION_FAILED_PATTERN = /Authentication failed(?:\s*\(Request ID:[^)]+\))?/i;
6968

7069
// Pattern to detect a clean max-turns exit from Claude Code.
7170
// Claude Code emits a JSON result object with "subtype":"error_max_turns" when the
@@ -149,15 +148,6 @@ function isRateLimitError(output) {
149148
return RATE_LIMIT_ERROR_PATTERN.test(output);
150149
}
151150

152-
/**
153-
* Determines if the collected output contains an authentication failed error.
154-
* @param {string} output - Collected stdout+stderr from the process
155-
* @returns {boolean}
156-
*/
157-
function isAuthenticationFailedError(output) {
158-
return AUTHENTICATION_FAILED_PATTERN.test(output);
159-
}
160-
161151
/**
162152
* Determines if the collected output signals a clean max-turns exit.
163153
* When Claude Code hits its turn limit it emits a result object with

‎setup/js/close_issue.cjs‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { ERR_NOT_FOUND } = require("./error_codes.cjs");
1111
const { createCloseEntityHandler, ISSUE_CONFIG } = require("./close_entity_helpers.cjs");
1212
const { loadTemporaryIdMapFromResolved, resolveRepoIssueTarget } = require("./temporary_id.cjs");
1313
const { getErrorMessage } = require("./error_helpers.cjs");
14+
const { normalizeIssueIntentMetadata } = require("./issue_intents.cjs");
1415

1516
/**
1617
* Parse a `duplicate_of` value into { owner, repo, issueNumber }.
@@ -154,17 +155,32 @@ async function addIssueComment(github, owner, repo, issueNumber, message) {
154155
* @param {string} owner - Repository owner
155156
* @param {string} repo - Repository name
156157
* @param {number} issueNumber - Issue number
157-
* @param {string} [stateReason] - The reason for closing: "COMPLETED", "NOT_PLANNED", or "DUPLICATE"
158+
* @param {string} stateReason - The reason for closing: "COMPLETED", "NOT_PLANNED", or "DUPLICATE"
158159
* @returns {Promise<{number: number, html_url: string, title: string, node_id: string}>} Issue details
159160
*/
160-
async function closeIssue(github, owner, repo, issueNumber, stateReason) {
161-
const { data: issue } = await github.rest.issues.update({
161+
async function closeIssue(github, owner, repo, issueNumber, stateReason, intentMetadata, useIssueIntent) {
162+
const baseParams = {
162163
owner,
163164
repo,
164165
issue_number: issueNumber,
165166
state: "closed",
166167
state_reason: (stateReason || "COMPLETED").toLowerCase(),
167-
});
168+
};
169+
170+
const hasIntentMetadata = Boolean(intentMetadata && Object.keys(intentMetadata).length > 0);
171+
if (useIssueIntent && hasIntentMetadata) {
172+
try {
173+
const { data: issue } = await github.request("PATCH /repos/{owner}/{repo}/issues/{issue_number}", {
174+
...baseParams,
175+
...intentMetadata,
176+
});
177+
return issue;
178+
} catch (error) {
179+
core.warning(`Issue-intent close path unavailable, falling back to legacy close path: ${getErrorMessage(error)}`);
180+
}
181+
}
182+
183+
const { data: issue } = await github.rest.issues.update(baseParams);
168184

169185
return issue;
170186
}
@@ -176,12 +192,13 @@ async function closeIssue(github, owner, repo, issueNumber, stateReason) {
176192
*/
177193
async function main(config = {}) {
178194
const configStateReason = config.state_reason || "COMPLETED";
195+
const issueIntentEnabled = config.issue_intent !== false;
179196
const requiredLabels = config.required_labels || [];
180197
const requiredTitlePrefix = config.required_title_prefix || "";
181198
const { defaultTargetRepo, allowedRepos } = resolveTargetRepoConfig(config);
182199
const githubClient = await createAuthenticatedGitHubClient(config);
183200

184-
core.info(`Close issue configuration: max=${config.max || 10}, state_reason=${configStateReason}`);
201+
core.info(`Close issue configuration: max=${config.max || 10}, state_reason=${configStateReason}, issue_intent=${issueIntentEnabled}`);
185202
if (requiredLabels.length > 0) {
186203
core.info(`Required labels: ${requiredLabels.join(", ")}`);
187204
}
@@ -265,9 +282,10 @@ async function main(config = {}) {
265282
closeEntity(github, owner, repo, entityNumber, item) {
266283
// Support item-level state_reason override, falling back to config-level default
267284
const stateReason = item.state_reason || configStateReason;
285+
const intentMetadata = issueIntentEnabled ? normalizeIssueIntentMetadata(item) : {};
268286
core.info(`Closing issue #${entityNumber} with state_reason=${stateReason}`);
269287

270-
const closePromise = closeIssue(github, owner, repo, entityNumber, stateReason);
288+
const closePromise = closeIssue(github, owner, repo, entityNumber, stateReason, intentMetadata, issueIntentEnabled);
271289

272290
// When duplicate_of is provided and state_reason is DUPLICATE, create the native duplicate relationship
273291
const stateReasonUpper = stateReason.toUpperCase();

‎setup/js/codex_harness.cjs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const {
5151
} = require("./awf_reflect.cjs");
5252
const { emitMissingToolPermissionIssue, hasExpectedSafeOutputs, hasNoopInSafeOutputs } = require("./safeoutputs_cli.cjs");
5353
const { countPermissionDeniedIssues, hasNumerousPermissionDeniedIssues, extractDeniedCommands, buildMissingToolPermissionIssuePayload } = require("./permission_denied_helpers.cjs");
54-
const { detectNonRetryableHarnessGuard, buildSoftTimeoutGuard, emitSoftTimeoutSignal } = require("./harness_retry_guard.cjs");
54+
const { detectNonRetryableHarnessGuard, buildSoftTimeoutGuard, emitSoftTimeoutSignal, isAuthenticationFailedError } = require("./harness_retry_guard.cjs");
5555
const { MODEL_NOT_SUPPORTED_PATTERN: INVALID_MODEL_ERROR_PATTERN } = require("./detect_agent_errors.cjs");
5656
const { resolveRetryConfig } = require("./harness_retry_config.cjs");
5757

@@ -73,7 +73,6 @@ const TOKEN_PER_MIN_RATE_LIMIT_PATTERN = /Rate limit reached for [^\s]+(?: in or
7373
// The backreference \1 requires the two numeric parts of "N/N" to be identical —
7474
// "5/5" matches (exhausted) but "1/5", "3/5", "4/5" do not (still retrying).
7575
const RECONNECT_EXHAUSTED_PATTERN = /Reconnecting\.\.\.\s+(\d+)\/\1\b/;
76-
const AUTHENTICATION_FAILED_PATTERN = /Authentication failed(?:\s*\(Request ID:[^)]+\))?/i;
7776

7877
// Pattern to detect a missing API key at startup — Codex emits this before making any API
7978
// calls when neither CODEX_API_KEY nor OPENAI_API_KEY is available in the environment.
@@ -115,15 +114,6 @@ function isTokenPerMinuteRateLimitError(output) {
115114
return TOKEN_PER_MIN_RATE_LIMIT_PATTERN.test(output);
116115
}
117116

118-
/**
119-
* Determines if the collected output contains an authentication failed error.
120-
* @param {string} output - Collected stdout+stderr from the process
121-
* @returns {boolean}
122-
*/
123-
function isAuthenticationFailedError(output) {
124-
return AUTHENTICATION_FAILED_PATTERN.test(output);
125-
}
126-
127117
/**
128118
* Determines if the collected output indicates a missing API key at startup.
129119
* Codex exits before producing any agent output in this case, so retrying is futile.

0 commit comments

Comments
 (0)