Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/scaffold/fullsend-repo/scripts/post-triage-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ MOCK_BIN="${TMPDIR}/bin"
mkdir -p "${MOCK_BIN}"
cat > "${MOCK_BIN}/gh" <<MOCKEOF
#!/usr/bin/env bash
# When querying the repo labels list, return a set of known test labels so that
# the label-existence guard in post-triage.sh allows them through.
if [[ "\$1" == "api" ]] && [[ "\$2" == *"/labels" ]] && [[ "\$*" == *"--paginate"* ]] && [[ "\$*" != *"-f "* ]] && [[ "\$*" != *"-X "* ]]; then
# Return labels used by the test fixtures, one per line (--jq '.[].name').
printf '%s\n' "area/api" "area/cli" "priority/high" "component/parser"
exit 0
fi
echo "gh \$*" >> "${GH_LOG}"
MOCKEOF
chmod +x "${MOCK_BIN}/gh"
Expand Down Expand Up @@ -264,6 +271,10 @@ run_test "label-actions-multiple-second-label" \
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady.","label_actions":{"reason":"Multiple labels apply.","actions":[{"action":"add","label":"area/api"},{"action":"add","label":"priority/high"}]}}' \
"gh api repos/test-org/test-repo/issues/42/labels -f labels[]=priority/high --silent"

run_test_stdout "label-actions-nonexistent-label-skipped" \
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady.","label_actions":{"reason":"Agent recommended a label that does not exist.","actions":[{"action":"add","label":"bug"}]}}' \
"::warning::Skipping label 'bug' -- does not exist in repo (will not auto-create)"

run_test_stdout "label-actions-invalid-characters-refused" \
'{"action":"sufficient","reasoning":"all clear","clarity_scores":{"symptom":0.9,"cause":0.85,"reproduction":0.9,"impact":0.8,"overall":0.87},"triage_summary":{"title":"Fix crash","severity":"high","category":"bug","problem":"Crash","root_cause_hypothesis":"Buffer overflow","reproduction_steps":["step 1"],"environment":"Linux","impact":"All users","recommended_fix":"Fix buffer","proposed_test_case":"test_crash"},"comment":"## Triage Summary\n\nReady.","label_actions":{"reason":"Injection attempt.","actions":[{"action":"add","label":"label;injection"}]}}' \
"::warning::Refused label 'label;injection' -- contains invalid characters"
Expand Down
15 changes: 15 additions & 0 deletions internal/scaffold/fullsend-repo/scripts/post-triage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ if [[ "${HAS_LABEL_ACTIONS}" == "true" ]]; then

echo "Processing ${LABEL_COUNT} label action(s)..."

# Fetch existing repo labels once so we can reject labels that don't exist.
# This prevents the agent from accidentally creating labels the org removed.
EXISTING_LABELS=$(gh api "repos/${REPO}/labels" --paginate --jq '.[].name' 2>/dev/null || true)

label_exists() {
local label="$1"
# Use grep with fixed-string and line-match to avoid regex issues with
# label names that contain special characters (e.g., "c++").
echo "${EXISTING_LABELS}" | grep -qFx "${label}"
}

LABELS_APPLIED=0
for i in $(seq 0 $((LABEL_COUNT - 1))); do
LA_ACTION=$(jq -r ".label_actions.actions[${i}].action" "${RESULT_FILE}")
Expand All @@ -208,6 +219,10 @@ if [[ "${HAS_LABEL_ACTIONS}" == "true" ]]; then

case "${LA_ACTION}" in
add)
if ! label_exists "${LA_LABEL}"; then
echo "::warning::Skipping label '${LA_LABEL}' -- does not exist in repo (will not auto-create)"
continue
fi
echo "Adding label '${LA_LABEL}'..."
add_label "${LA_LABEL}"
LABELS_APPLIED=$((LABELS_APPLIED + 1))
Expand Down
21 changes: 19 additions & 2 deletions internal/scaffold/fullsend-repo/skills/issue-labels/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,24 @@ gh label list --repo OWNER/REPO --json name,description --limit 100
If the repo has no non-control labels, skip labeling entirely -- do not emit
`label_actions`.

## Step 2: Research labeling conventions
## Step 2: Check for GitHub issue types

GitHub issue types (Bug, Feature, Task, etc.) classify issues at a higher level
than labels. If the repo uses issue types, do **not** recommend labels that
duplicate the issue type — e.g., do not add `bug` or `type/bug` when the issue
already has the Bug type.

Query the current issue to check for an issue type:
```
gh issue view NUMBER --repo OWNER/REPO --json type
```

If the `.type` field is non-null, the repo uses issue types. In that case:
- Do not recommend labels whose names match or overlap with the issue type
(e.g., `bug`, `type/bug`, `enhancement`, `feature`, `type/feature`).
- Area, priority, component, and other non-type labels are still appropriate.

## Step 3: Research labeling conventions

Spawn a sub-agent to investigate how labels have been applied to recent issues.
The sub-agent should:
Expand All @@ -49,7 +66,7 @@ The sub-agent should:
Do not dump raw issue data into the parent context. Only use the sub-agent's
summary to inform your recommendations.

## Step 3: Recommend labels
## Step 4: Recommend labels

Based on the issue content, the available labels, and the observed conventions:

Expand Down
Loading