11name : Plan Minion Task
22
33on :
4- # Trigger when minion-planning label is added
54 issues :
65 types : [labeled]
7-
8- # Trigger on /minion replan comment
9- issue_comment :
10- types : [created]
11-
12- # Manual trigger
136 workflow_dispatch :
147 inputs :
15- issue_number :
16- description : " Issue number to plan for "
8+ program :
9+ description : " Program .md file path "
1710 required : true
1811 type : string
1912
@@ -25,112 +18,41 @@ jobs:
2518 plan :
2619 if : >
2720 github.event_name == 'workflow_dispatch' ||
28- (github.event_name == 'issues' && github.event.label.name == 'minion-planning') ||
29- (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/minion replan'))
21+ (github.event_name == 'issues' && github.event.label.name == 'minion-planning')
3022 runs-on : ubuntu-latest
3123 timeout-minutes : 15
3224
3325 steps :
34- - name : Check authorization
35- env :
36- GH_TOKEN : ${{ secrets.GH_PAT }}
37- run : |
38- ORG=$(echo "${{ github.repository }}" | cut -d'/' -f1)
39- ROLE=$(gh api "orgs/${ORG}/memberships/${{ github.actor }}" --jq '.role' 2>/dev/null || echo "none")
40- if [ "$ROLE" != "admin" ]; then
41- echo "::error::Unauthorized: ${{ github.actor }} (role: ${ROLE}) is not an org admin"
42- exit 1
43- fi
44-
45- - name : Determine issue number
46- id : issue
47- run : |
48- if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
49- echo "number=${{ inputs.issue_number }}" >> "$GITHUB_OUTPUT"
50- else
51- echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
52- fi
26+ - uses : actions/checkout@v4
5327
54- - name : Acknowledge replan request
55- if : github.event_name == 'issue_comment'
56- env :
57- GH_TOKEN : ${{ secrets.GH_PAT }}
58- run : |
59- ISSUE_NUM="${{ steps.issue.outputs.number }}"
60- RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
61- gh issue comment "$ISSUE_NUM" --repo "${{ github.repository }}" \
62- --body "Minion re-planning triggered. [View workflow run](${RUN_URL})"
63-
64- # Checkout this repo (cli = principal)
65- - name : Checkout cli
66- uses : actions/checkout@v4
67- with :
68- path : cli
28+ - name : Install Claude Code
29+ run : npm install -g @anthropic-ai/claude-code
6930
70- - name : Install yq
31+ - name : Install minions
7132 run : |
72- sudo wget -qO /usr/local/bin/yq https:// github.com/mikefarah/yq/releases/ latest/download/yq_linux_amd64
73- sudo chmod +x /usr/local/ bin/yq
33+ go install github.com/partio-io/minions/cmd/minions@ latest
34+ echo "$(go env GOPATH)/ bin" >> "$GITHUB_PATH"
7435
75- - name : Checkout project repos
36+ - name : Determine program
37+ id : program
7638 env :
7739 GH_TOKEN : ${{ secrets.GH_PAT }}
7840 run : |
79- for ENTRY in $(yq -r '.repos[] | .full_name + ":" + .name' cli/.minions/project.yaml); do
80- FULL="${ENTRY%%:*}"
81- SHORT="${ENTRY##*:}"
82- if [ "$SHORT" = "cli" ]; then
83- continue
41+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
42+ echo "path=${{ inputs.program }}" >> "$GITHUB_OUTPUT"
43+ else
44+ ISSUE_NUM="${{ github.event.issue.number }}"
45+ ISSUE_BODY=$(gh issue view "$ISSUE_NUM" --repo "${{ github.repository }}" --json body -q '.body')
46+ PROGRAM_PATH=$(echo "$ISSUE_BODY" | grep -oP '(?<=<!-- program: ).*(?= -->)' || true)
47+ if [ -z "$PROGRAM_PATH" ]; then
48+ echo "::error::No program reference in issue #${ISSUE_NUM}"
49+ exit 1
8450 fi
85- gh repo clone "$FULL" "$SHORT" -- --depth=1
86- done
87-
88- - name : Configure git auth
89- env :
90- GH_TOKEN : ${{ secrets.GH_PAT }}
91- run : git config --global url."https://x-access-token:${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
92-
93- - name : Checkout minions
94- uses : actions/checkout@v4
95- with :
96- repository : partio-io/minions
97- path : minions
98- token : ${{ secrets.GH_PAT }}
99-
100- # Install toolchains
101- - name : Setup Go
102- uses : actions/setup-go@v5
103- with :
104- go-version : " 1.26"
105-
106- - name : Setup Node.js
107- uses : actions/setup-node@v4
108- with :
109- node-version : " 22"
110-
111- - name : Build minions
112- run : cd minions && make build
113-
114- - name : Install Claude Code
115- run : npm install -g @anthropic-ai/claude-code
51+ echo "path=${PROGRAM_PATH}" >> "$GITHUB_OUTPUT"
52+ fi
11653
117- # Run plan
118- - name : Generate plan
54+ - name : Run program with planner
11955 env :
12056 ANTHROPIC_API_KEY : ${{ secrets.ANTHROPIC_API_KEY }}
12157 GH_TOKEN : ${{ secrets.GH_PAT }}
122- WORKSPACE_ROOT : ${{ github.workspace }}
123- run : |
124- cd minions
125- ./minions plan --issue ${{ steps.issue.outputs.number }} --repo "${{ github.repository }}"
126-
127- # On failure: comment with logs link
128- - name : Report failure
129- if : failure()
130- env :
131- GH_TOKEN : ${{ secrets.GH_PAT }}
132- run : |
133- ISSUE_NUM="${{ steps.issue.outputs.number }}"
134- RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
135- gh issue comment "$ISSUE_NUM" --repo "${{ github.repository }}" \
136- --body "Minion planning failed. [View logs](${RUN_URL})"
58+ run : minions run ${{ steps.program.outputs.path }} --dry-run
0 commit comments