Skip to content

Commit e6f1181

Browse files
authored
Add Copilot Centralization Optimizer workflows (#39394)
1 parent cb89a18 commit e6f1181

8 files changed

Lines changed: 4301 additions & 1 deletion

.github/aw/actions-lock.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
"version": "v4.36.2",
151151
"sha": "8aad20d150bbac5944a9f9d289da16a4b0d87c1e"
152152
},
153+
"github/gh-aw-actions/setup@v0.79.6": {
154+
"repo": "github/gh-aw-actions/setup",
155+
"version": "v0.79.6",
156+
"sha": "5c2fe865bb4dc46e1450f6ee0d0541d759aea73a"
157+
},
153158
"github/gh-aw/actions/setup-cli@v0.79.8": {
154159
"repo": "github/gh-aw/actions/setup-cli",
155160
"version": "v0.79.8",

.github/workflows/copilot-centralization-drilldown.lock.yml

Lines changed: 1659 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
---
2+
name: Copilot Centralization Drilldown
3+
description: Expands one mined centralization candidate into a concrete draft workflow or reusable prompt template.
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
candidate_title:
8+
description: Short name for the candidate skill or repeated task
9+
required: true
10+
target_kind:
11+
description: workflow, shared_prompt, playbook, or auto
12+
required: false
13+
default: auto
14+
recommendation_kind:
15+
description: Recommendation from the optimizer
16+
required: false
17+
default: shared_prompt_or_chatops
18+
sample_prompt:
19+
description: Representative prompt text
20+
required: false
21+
evidence_summary:
22+
description: Compact summary of repeated behavior and expected value
23+
required: false
24+
candidate_json:
25+
description: Optional compact JSON object from the optimizer output
26+
required: false
27+
permissions:
28+
contents: read
29+
copilot-requests: write
30+
strict: true
31+
max-ai-credits: 120
32+
max-daily-ai-credits: 500
33+
safe-outputs:
34+
mentions: false
35+
allowed-github-references: []
36+
max-bot-mentions: 1
37+
create-issue:
38+
title-prefix: "[copilot-centralization-draft] "
39+
labels: [report, ai-optimization, workflow-design]
40+
expires: 30
41+
steps:
42+
- name: Normalize candidate input
43+
env:
44+
CANDIDATE_TITLE: ${{ inputs.candidate_title }}
45+
TARGET_KIND: ${{ inputs.target_kind }}
46+
RECOMMENDATION_KIND: ${{ inputs.recommendation_kind }}
47+
SAMPLE_PROMPT: ${{ inputs.sample_prompt }}
48+
EVIDENCE_SUMMARY: ${{ inputs.evidence_summary }}
49+
CANDIDATE_JSON: ${{ inputs.candidate_json }}
50+
run: |
51+
set -euo pipefail
52+
GH_AW_SAFE_OUTPUTS="${GH_AW_SAFE_OUTPUTS:-${RUNNER_TEMP:-/tmp}/gh-aw/safeoutputs/outputs.jsonl}"
53+
mkdir -p /tmp/gh-aw/data
54+
55+
if [ -n "${CANDIDATE_JSON}" ]; then
56+
printf '%s' "$CANDIDATE_JSON" | jq '.' > /tmp/gh-aw/data/candidate-raw.json
57+
else
58+
jq -n \
59+
--arg title "$CANDIDATE_TITLE" \
60+
--arg recommendation_kind "$RECOMMENDATION_KIND" \
61+
--arg sample_prompt "$SAMPLE_PROMPT" \
62+
--arg evidence_summary "$EVIDENCE_SUMMARY" \
63+
'{
64+
title: $title,
65+
recommendation_kind: $recommendation_kind,
66+
sample_prompt: (if $sample_prompt == "" then null else $sample_prompt end),
67+
evidence_summary: (if $evidence_summary == "" then null else $evidence_summary end)
68+
}' > /tmp/gh-aw/data/candidate-raw.json
69+
fi
70+
71+
candidate_title="$(jq -r '.title // empty' /tmp/gh-aw/data/candidate-raw.json)"
72+
sample_prompt="$(jq -r '.sample_prompt // empty' /tmp/gh-aw/data/candidate-raw.json)"
73+
evidence_summary="$(jq -r '.evidence_summary // empty' /tmp/gh-aw/data/candidate-raw.json)"
74+
75+
if [ -z "$candidate_title" ]; then
76+
printf '%s\n' '{"type":"noop","message":"No candidate title was provided for drilldown."}' >> "$GH_AW_SAFE_OUTPUTS"
77+
exit 0
78+
fi
79+
80+
slug="$(printf '%s' "$candidate_title" \
81+
| tr '[:upper:]' '[:lower:]' \
82+
| sed 's/[^a-z0-9]/-/g' \
83+
| sed 's/-\{2,\}/-/g' \
84+
| sed 's/^-//' \
85+
| sed 's/-$//' \
86+
| cut -c1-48)"
87+
88+
if [ -z "$slug" ]; then
89+
slug="candidate"
90+
fi
91+
92+
resolved_target_kind="$TARGET_KIND"
93+
if [ "$resolved_target_kind" = "" ] || [ "$resolved_target_kind" = "auto" ]; then
94+
case "$RECOMMENDATION_KIND" in
95+
continuous_workflow)
96+
resolved_target_kind="workflow"
97+
;;
98+
shared_prompt_or_chatops)
99+
resolved_target_kind="shared_prompt"
100+
;;
101+
keep_ad_hoc_but_standardize)
102+
resolved_target_kind="playbook"
103+
;;
104+
*)
105+
resolved_target_kind="workflow"
106+
;;
107+
esac
108+
fi
109+
110+
sample_len=${#sample_prompt}
111+
evidence_len=${#evidence_summary}
112+
candidate_strength="weak"
113+
if [ "$sample_len" -ge 24 ] || [ "$evidence_len" -ge 40 ] || [ -n "$CANDIDATE_JSON" ]; then
114+
candidate_strength="strong"
115+
fi
116+
117+
jq -n \
118+
--arg title "$candidate_title" \
119+
--arg slug "$slug" \
120+
--arg recommendation_kind "$RECOMMENDATION_KIND" \
121+
--arg resolved_target_kind "$resolved_target_kind" \
122+
--arg sample_prompt "$sample_prompt" \
123+
--arg evidence_summary "$evidence_summary" \
124+
--arg candidate_strength "$candidate_strength" \
125+
--slurpfile raw /tmp/gh-aw/data/candidate-raw.json '
126+
{
127+
title: $title,
128+
slug: $slug,
129+
recommendation_kind: $recommendation_kind,
130+
resolved_target_kind: $resolved_target_kind,
131+
candidate_strength: $candidate_strength,
132+
sample_prompt: (if $sample_prompt == "" then null else $sample_prompt end),
133+
evidence_summary: (if $evidence_summary == "" then null else $evidence_summary end),
134+
raw_candidate: $raw[0]
135+
}
136+
' > /tmp/gh-aw/data/candidate.json
137+
138+
jq -n \
139+
--arg resolved_target_kind "$resolved_target_kind" \
140+
--arg slug "$slug" '
141+
{
142+
target_path: (
143+
if $resolved_target_kind == "workflow" then ".github/workflows/" + $slug + ".md"
144+
elif $resolved_target_kind == "shared_prompt" then ".github/workflows/shared/" + $slug + ".md"
145+
else ".github/workflows/shared/" + $slug + "-playbook.md"
146+
end
147+
),
148+
trigger_hint: (
149+
if $resolved_target_kind == "workflow" then "Prefer workflow_dispatch first; choose schedule or event triggers only when repeated evidence justifies automation."
150+
elif $resolved_target_kind == "shared_prompt" then "Prefer a reusable prompt or shared workflow component before full automation."
151+
else "Keep this human-in-the-loop and produce a reusable playbook or prompt template."
152+
end
153+
),
154+
implementation_bias: "Prefer the smallest durable artifact that reduces repeated prompting without widening scope.",
155+
report_style: "Use issue sections with visible summary and one fenced draft block."
156+
}
157+
' > /tmp/gh-aw/data/derived-plan.json
158+
---
159+
160+
# Copilot Centralization Drilldown
161+
162+
Turn one mined centralization candidate into a concrete, reviewable draft.
163+
164+
Read these prepared files first:
165+
- `/tmp/gh-aw/data/candidate.json`
166+
- `/tmp/gh-aw/data/derived-plan.json`
167+
168+
Stay narrow. Do not perform broad repo exploration. Use the current repository's existing workflow style as the default convention.
169+
170+
If `candidate_strength` is `weak`, or the provided evidence is too vague to justify a concrete draft, call `noop` with a short explanation.
171+
172+
## Task
173+
174+
1. Decide the smallest useful deliverable:
175+
- a new gh-aw workflow draft
176+
- a reusable shared prompt/template draft
177+
- a reusable human playbook when automation is premature
178+
2. Produce exactly one primary draft aligned with `resolved_target_kind` unless the evidence clearly supports a better smaller artifact.
179+
3. Optimize for AI-credit savings by reducing repeated prompt construction, ambiguous setup work, or repeated context rebuilding.
180+
4. Keep the draft implementation-ready and short. Do not design a platform.
181+
182+
## Output
183+
184+
Use `create-issue`.
185+
186+
Structure the issue with these `###` sections:
187+
- `### Summary`
188+
- `### Pattern Fit`
189+
- `### Proposed Draft`
190+
- `### AI Credit Savings Rationale`
191+
- `### Inputs Still Needed`
192+
- `### References`
193+
194+
In `### Proposed Draft`:
195+
- include `Path: <target path>` on its own line before the draft
196+
- include exactly one fenced `md` code block containing the full proposed file content
197+
- if the best artifact is a workflow, produce a full gh-aw workflow markdown file with frontmatter and prompt body
198+
- if the best artifact is a shared prompt or playbook, produce the full markdown file content for that path
199+
200+
## Constraints
201+
202+
- Prefer `workflow_dispatch` for a first workflow draft unless the evidence strongly supports a scheduled or event-driven trigger.
203+
- Keep permissions read-only and route visible writes through safe outputs.
204+
- Reuse deterministic preprocessing or explicit `noop` guidance when that materially lowers token use.
205+
- Do not create more than one draft artifact in the issue.

0 commit comments

Comments
 (0)