Skip to content

Commit fd0db5f

Browse files
committed
feat: replace gh-aw flock-action with Copilot coding agent
The gh-aw sandbox cannot connect the GitHub MCP server to api.github.com, causing every run to fail with fetch errors. Switch to the Copilot coding agent approach (copilot-swe-agent) which has native GitHub access and proven successful runs in nsip-example. - Add flock-action.yml workflow that assigns copilot-swe-agent - Add flock-action.instructions.md with full action dispatch - Add nsip-mcp.instructions.md with tool reference and glossary - Update copilot-instructions.md with NSIP/flock-action references - Fix .mcp.json to use `nsip mcp` (binary built by setup steps) - Remove gh-aw flock-action.md source and compiled lock file
1 parent 01ad87c commit fd0db5f

File tree

7 files changed

+352
-1402
lines changed

7 files changed

+352
-1402
lines changed

.github/copilot-instructions.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ cargo deny check # Supply chain audit
4242

4343
## NSIP MCP Server
4444

45-
The binary includes an MCP server (`nsip mcp`) for sheep genetic evaluation. Configure in `.vscode/mcp.json`. See `docs/MCP.md` for the full API reference and `docs/llm-guides/` for ready-to-use LLM instruction templates.
45+
The binary includes an MCP server (`nsip mcp`) for sheep genetic evaluation.
46+
Configure in `.mcp.json`. See `docs/MCP.md` for the full API reference and
47+
`docs/llm-guides/` for ready-to-use LLM instruction templates.
48+
49+
Available tools: `search`, `details`, `lineage`, `progeny`, `profile`,
50+
`breed_groups`, `trait_ranges`, `compare`, `rank`, `inbreeding_check`,
51+
`mating_recommendations`, `flock_summary`, `database_status`.
52+
53+
See `.github/instructions/nsip-mcp.instructions.md` for full tool reference,
54+
workflow recipes, and formatting rules.
55+
56+
## Flock Actions
57+
58+
Issues with the `flock-action` label request automated breeding analyses. Parse
59+
the issue form fields, call the appropriate MCP tools, and produce a report PR
60+
in `reports/`. See `.github/instructions/flock-action.instructions.md`.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
applyTo: "reports/**"
3+
---
4+
5+
# Flock Action Instructions
6+
7+
When assigned a `flock-action` issue, follow this workflow to produce a
8+
structured breeding report.
9+
10+
## 1. Parse the Issue
11+
12+
Extract these fields from the issue body:
13+
14+
| Field | Location | Required |
15+
|---|---|---|
16+
| Action | `action` dropdown | yes |
17+
| LPN IDs | `lpn_ids` textarea (one per line) | yes |
18+
| Trait Weights | `trait_weights` textarea (`TRAIT:weight` per line) | only for Rank |
19+
| Sort Trait | `sort_trait` input | only for Compare |
20+
| Notes | `notes` textarea | no |
21+
22+
## 2. Call MCP Tools by Action
23+
24+
### Mating Recommendations
25+
For each LPN ID (assumed to be ewes):
26+
1. Call `details` to get the animal's breed.
27+
2. Call `mating_recommendations` with the animal's LPN ID and breed ID.
28+
3. For each recommended mate, call `inbreeding_check`.
29+
30+
### Evaluate Flock
31+
1. Call `details` for every LPN ID.
32+
2. Extract the breed ID from the first animal.
33+
3. Call `trait_ranges` for that breed.
34+
4. For each animal, calculate breed-relative position per trait.
35+
36+
### Compare Animals
37+
1. Call `compare` with all LPN IDs.
38+
2. If a sort trait is provided, sort the results by that trait.
39+
3. Call `trait_ranges` to add breed context.
40+
41+
### Rank Animals
42+
1. Parse trait weights from the issue (format: `TRAIT:weight`).
43+
2. Call `details` for each LPN ID.
44+
3. Compute a weighted score: `score = sum(trait_value * weight * accuracy / 100)`.
45+
4. Sort animals by score descending.
46+
5. Call `trait_ranges` for breed context.
47+
48+
### Inbreeding Matrix
49+
1. For every unique pair of LPN IDs, call `inbreeding_check`.
50+
2. Build a matrix of COI values with traffic-light ratings.
51+
52+
### Flock Profile
53+
1. Call `details` for each LPN ID.
54+
2. Compute aggregate statistics: count, gender split, trait averages.
55+
3. Call `trait_ranges` for breed context.
56+
4. Compare flock averages against breed midpoints.
57+
58+
## 3. Produce Artifacts
59+
60+
Create output in `reports/{YYYY-MM-DD}-{action-slug}/` where:
61+
- `{YYYY-MM-DD}` is today's date
62+
- `{action-slug}` is the action in kebab-case (e.g., `mating-recommendations`)
63+
64+
### report.md
65+
66+
Formatted markdown with:
67+
- Header linking back to the issue (`Closes #N`)
68+
- Summary of the action and animals analyzed
69+
- Data tables with EBV values, accuracies, and breed-relative context
70+
- Recommendations or analysis conclusions
71+
- Trait glossary footnote for non-obvious abbreviations
72+
73+
### data.csv
74+
75+
Machine-readable export with columns appropriate to the action:
76+
- **Mating Recommendations**: `ewe_lpn,recommended_sire_lpn,rank_score,coi,predicted_bwt,predicted_wwt,...`
77+
- **Evaluate Flock**: `lpn_id,breed,gender,bwt,bwt_acc,wwt,wwt_acc,...`
78+
- **Compare Animals**: `lpn_id,trait,value,accuracy`
79+
- **Rank Animals**: `lpn_id,score,trait1_contribution,trait2_contribution,...`
80+
- **Inbreeding Matrix**: `sire_lpn,dam_lpn,coi,rating`
81+
- **Flock Profile**: `metric,value`
82+
83+
## 4. Open a Pull Request
84+
85+
Create a PR with:
86+
- **Title**: `[Flock Action] {Action Name} — {N} animals`
87+
- **Body**:
88+
- Summary of findings
89+
- Link to the issue: `Closes #{issue_number}`
90+
- List of artifacts produced
91+
- **Branch**: `flock-action/{issue_number}-{action-slug}`
92+
93+
## Formatting Rules
94+
95+
- Use markdown tables for all EBV data — never dump raw JSON.
96+
- Show accuracy alongside every EBV: `+9.6 (68%)`.
97+
- Use traffic-light indicators for COI: Green, Yellow, Red.
98+
- Include breed ranges for context when presenting individual values.
99+
- Round EBV values to 2 decimal places.
100+
- Use the trait's natural units (lbs, mm, lambs, eggs/g).
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
applyTo: "**/*-record.yml,**/BREEDING-EVENT-LOG*,reports/**"
3+
---
4+
5+
# NSIP MCP Agent Instructions
6+
7+
When working with breeding record issues, event logs, or livestock data queries, use
8+
the NSIP MCP tools described below. This document is the authoritative reference for
9+
agent-driven interactions with the NSIP Search API.
10+
11+
---
12+
13+
## What is the NSIP MCP Server?
14+
15+
The NSIP MCP server wraps the [National Sheep Improvement Program](https://nsip.org/)
16+
Search API as a Model Context Protocol service. It gives AI agents direct access to:
17+
18+
- **400,000+ sheep** with estimated breeding values (EBVs)
19+
- **Pedigree trees** spanning multiple generations
20+
- **Breed-level benchmarks** (trait ranges, averages)
21+
- **Breeding analytics** — inbreeding coefficients, trait ranking, mating recommendations
22+
23+
**Transport**: stdio only — started with `nsip mcp`
24+
25+
---
26+
27+
## Tool Reference
28+
29+
### search
30+
31+
Find animals matching filter criteria. Returns paginated results.
32+
33+
| Parameter | Type | Required | Default | Description |
34+
|---|---|---|---|---|
35+
| `breed_group_id` | integer | no | | Breed group ID |
36+
| `breed_id` | integer | no | | Breed ID |
37+
| `status` | string | no | | `"CURRENT"`, `"SOLD"`, or `"DEAD"` |
38+
| `gender` | string | no | | `"Male"`, `"Female"`, or `"Both"` |
39+
| `born_after` | string | no | | Animals born after this date (`YYYY-MM-DD`) |
40+
| `born_before` | string | no | | Animals born before this date (`YYYY-MM-DD`) |
41+
| `proven_only` | boolean | no | false | Only return proven animals |
42+
| `flock_id` | string | no | | Flock ID |
43+
| `sort_by` | string | no | | Trait abbreviation to sort by (e.g. `"WWT"`) |
44+
| `reverse` | boolean | no | false | Reverse the sort order |
45+
| `page` | integer | no | 0 | Page number (0-indexed) |
46+
| `page_size` | integer | no | 15 | Results per page (1-100) |
47+
48+
---
49+
50+
### details
51+
52+
Fetch full EBV data, breed, contact info, and status for one animal.
53+
54+
| Parameter | Type | Required | Description |
55+
|---|---|---|---|
56+
| `animal_id` | string | yes | LPN ID or registration number |
57+
58+
---
59+
60+
### lineage
61+
62+
Retrieve the pedigree (ancestry) tree — parents, grandparents, and deeper ancestors.
63+
64+
| Parameter | Type | Required | Description |
65+
|---|---|---|---|
66+
| `animal_id` | string | yes | LPN ID |
67+
68+
---
69+
70+
### progeny
71+
72+
List offspring for an animal with pagination.
73+
74+
| Parameter | Type | Required | Default | Description |
75+
|---|---|---|---|---|
76+
| `animal_id` | string | yes | | LPN ID |
77+
| `page` | integer | no | 0 | Page number (0-indexed) |
78+
| `page_size` | integer | no | 10 | Results per page |
79+
80+
---
81+
82+
### profile
83+
84+
All-in-one call that combines `details`, `lineage`, and `progeny` in a single request.
85+
86+
| Parameter | Type | Required | Description |
87+
|---|---|---|---|
88+
| `animal_id` | string | yes | LPN ID |
89+
90+
---
91+
92+
### breed_groups
93+
94+
List all breed groups and individual breeds in the NSIP database. No parameters.
95+
96+
---
97+
98+
### trait_ranges
99+
100+
Get the min/max EBV values across all animals within a breed.
101+
102+
| Parameter | Type | Required | Description |
103+
|---|---|---|---|
104+
| `breed_id` | integer | yes | Breed ID |
105+
106+
---
107+
108+
### compare
109+
110+
Side-by-side EBV comparison of 2-5 animals. Optionally filter to specific traits.
111+
112+
| Parameter | Type | Required | Description |
113+
|---|---|---|---|
114+
| `animal_ids` | array of strings | yes | LPN IDs (2-5 items) |
115+
| `traits` | string | no | Comma-separated trait filter (e.g. `"BWT,WWT,YWT"`) |
116+
117+
---
118+
119+
### rank
120+
121+
Rank animals within a breed by a weighted composite score.
122+
123+
| Parameter | Type | Required | Default | Description |
124+
|---|---|---|---|---|
125+
| `breed_id` | integer | yes | | Breed ID to search |
126+
| `weights` | object | yes | | Trait-to-weight map, e.g. `{"BWT": -1.0, "WWT": 2.0}` |
127+
| `gender` | string | no | | `"Male"`, `"Female"`, or `"Both"` |
128+
| `status` | string | no | | `"CURRENT"`, `"SOLD"`, `"DEAD"` |
129+
| `top_n` | integer | no | 10 | Number of top results to return |
130+
131+
---
132+
133+
### inbreeding_check
134+
135+
Calculate Wright's coefficient of inbreeding (COI) for a potential sire x dam mating.
136+
137+
| Parameter | Type | Required | Description |
138+
|---|---|---|---|
139+
| `sire_id` | string | yes | LPN ID of the sire (father) |
140+
| `dam_id` | string | yes | LPN ID of the dam (mother) |
141+
142+
**COI traffic-light thresholds:**
143+
144+
| Rating | COI | Recommendation |
145+
|---|---|---|
146+
| Green | < 6.25% | Safe — proceed |
147+
| Yellow | 6.25-12.5% | Caution — consider alternatives |
148+
| Red | > 12.5% | Avoid — high inbreeding depression risk |
149+
150+
---
151+
152+
### mating_recommendations
153+
154+
Find optimal mates for an animal.
155+
156+
| Parameter | Type | Required | Default | Description |
157+
|---|---|---|---|---|
158+
| `animal_id` | string | yes | | LPN ID of the animal to find mates for |
159+
| `breed_id` | integer | yes | | Breed ID to search for candidates |
160+
| `target_traits` | string | no | WWT, BWT, NLB | Comma-separated traits to optimize |
161+
| `max_results` | integer | no | 5 | Number of recommendations |
162+
163+
---
164+
165+
### flock_summary
166+
167+
Summarize a flock: animal count, gender breakdown, and average EBV traits.
168+
169+
| Parameter | Type | Required | Description |
170+
|---|---|---|---|
171+
| `flock_id` | string | yes | Flock ID |
172+
| `breed_id` | integer | no | Filter to a specific breed within the flock |
173+
174+
---
175+
176+
### database_status
177+
178+
Check when the NSIP database was last updated. No parameters.
179+
180+
---
181+
182+
## EBV Trait Glossary
183+
184+
| Abbreviation | Full Name | Unit | Selection |
185+
|---|---|---|---|
186+
| BWT | Birth Weight | lbs | Lower preferred |
187+
| WWT | Weaning Weight | lbs | Higher preferred |
188+
| PWWT | Post-Weaning Weight | lbs | Higher preferred |
189+
| YWT | Yearling Weight | lbs | Higher preferred |
190+
| FAT | Fat Depth | mm | Moderate preferred |
191+
| EMD | Eye Muscle Depth | mm | Higher preferred |
192+
| NLB | Number of Lambs Born | lambs | Higher (with caution) |
193+
| NWT | Number of Lambs Weaned | lambs | Higher preferred |
194+
| PWT | Pounds Weaned | lbs | Higher preferred |
195+
| DAG | Dag Score | score | Lower preferred |
196+
| WEC | Worm Egg Count | eggs/g | Lower preferred |
197+
| FEC | Faecal Egg Count | eggs/g | Lower preferred |
198+
199+
## Formatting Rules
200+
201+
1. **Always use tables** for EBV data — never dump raw JSON.
202+
2. **Show accuracy** alongside every EBV value: `+9.6 (68%)`.
203+
3. **Use the traffic light** for COI results (Green/Yellow/Red).
204+
4. **Include breed context** whenever possible via `trait_ranges`.
205+
5. **Caveat low accuracy**: Note if a key trait has accuracy below 40%.
206+
6. **Use the trait's natural units**: lbs for weights, mm for depth/fat, lambs for NLB/NWT.

0 commit comments

Comments
 (0)