gxy-tool-bot 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. gxy_tool_bot-0.1.0/.gitignore +30 -0
  2. gxy_tool_bot-0.1.0/DEVELOPMENT.md +104 -0
  3. gxy_tool_bot-0.1.0/LICENSE +21 -0
  4. gxy_tool_bot-0.1.0/PKG-INFO +177 -0
  5. gxy_tool_bot-0.1.0/README.md +157 -0
  6. gxy_tool_bot-0.1.0/examples/issue-template-tool-request.yml +45 -0
  7. gxy_tool_bot-0.1.0/gxy_tool_bot/__init__.py +3 -0
  8. gxy_tool_bot-0.1.0/gxy_tool_bot/address_feedback.py +305 -0
  9. gxy_tool_bot-0.1.0/gxy_tool_bot/agent_loop.py +307 -0
  10. gxy_tool_bot-0.1.0/gxy_tool_bot/api_client.py +144 -0
  11. gxy_tool_bot-0.1.0/gxy_tool_bot/cli.py +315 -0
  12. gxy_tool_bot-0.1.0/gxy_tool_bot/config.py +107 -0
  13. gxy_tool_bot-0.1.0/gxy_tool_bot/exemplars.py +84 -0
  14. gxy_tool_bot-0.1.0/gxy_tool_bot/generator.py +812 -0
  15. gxy_tool_bot-0.1.0/gxy_tool_bot/github_client.py +303 -0
  16. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/__init__.py +30 -0
  17. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/bioconda.py +62 -0
  18. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/biotools.py +78 -0
  19. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/doi.py +74 -0
  20. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/fetch.py +135 -0
  21. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/github.py +70 -0
  22. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/pubmed.py +85 -0
  23. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/toolshed.py +74 -0
  24. gxy_tool_bot-0.1.0/gxy_tool_bot/lookups/web.py +81 -0
  25. gxy_tool_bot-0.1.0/gxy_tool_bot/planemo_utils.py +66 -0
  26. gxy_tool_bot-0.1.0/gxy_tool_bot/planner.py +412 -0
  27. gxy_tool_bot-0.1.0/gxy_tool_bot/retry.py +46 -0
  28. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/_conventions.txt +24 -0
  29. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/feedback_system.txt +35 -0
  30. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/generator_system.txt +37 -0
  31. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/generator_user.txt +11 -0
  32. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/planner_system.txt +77 -0
  33. gxy_tool_bot-0.1.0/gxy_tool_bot/templates/planner_user.txt +20 -0
  34. gxy_tool_bot-0.1.0/gxy_tool_bot/validation.py +445 -0
  35. gxy_tool_bot-0.1.0/pyproject.toml +43 -0
  36. gxy_tool_bot-0.1.0/review.md +180 -0
  37. gxy_tool_bot-0.1.0/tests/__init__.py +0 -0
  38. gxy_tool_bot-0.1.0/tests/test_address_feedback.py +282 -0
  39. gxy_tool_bot-0.1.0/tests/test_agent_loop.py +493 -0
  40. gxy_tool_bot-0.1.0/tests/test_api_client.py +315 -0
  41. gxy_tool_bot-0.1.0/tests/test_config.py +155 -0
  42. gxy_tool_bot-0.1.0/tests/test_fetch.py +40 -0
  43. gxy_tool_bot-0.1.0/tests/test_generator.py +1185 -0
  44. gxy_tool_bot-0.1.0/tests/test_planner.py +57 -0
  45. gxy_tool_bot-0.1.0/tests/test_retry.py +89 -0
  46. gxy_tool_bot-0.1.0/tests/test_toolshed.py +114 -0
  47. gxy_tool_bot-0.1.0/workflows/on-pr-feedback.yml +127 -0
  48. gxy_tool_bot-0.1.0/workflows/on-ready-to-implement.yml +162 -0
  49. gxy_tool_bot-0.1.0/workflows/on-tool-request.yml +47 -0
@@ -0,0 +1,30 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ *.egg
7
+ dist/
8
+ build/
9
+ .eggs/
10
+
11
+ # Virtual environments
12
+ .conda/
13
+ .env
14
+
15
+ # IDE
16
+ .vscode/
17
+ .idea/
18
+
19
+ # OS
20
+ .DS_Store
21
+ Thumbs.db
22
+
23
+ # Test artifacts
24
+ .pytest_cache/
25
+ test-output/
26
+ site-output/
27
+ generated/
28
+
29
+ # Exemplar cache
30
+ gxy-exemplars-*/
@@ -0,0 +1,104 @@
1
+ # Developer Guide
2
+
3
+ This guide helps developers find their way around the codebase when adding new
4
+ conventions, validation checks, or prompt changes.
5
+
6
+ ## Key Files
7
+
8
+ ### Prompts (system + user templates)
9
+
10
+ | File | Used by | Purpose |
11
+ |------|---------|---------|
12
+ | `gxy_tool_bot/templates/generator_system.txt` | Generation flow | System prompt — tells the agent how to write Galaxy tool XML, IUC conventions, available tools |
13
+ | `gxy_tool_bot/templates/generator_user.txt` | Generation flow | User prompt — contains the plan, exemplar tools, and instructions |
14
+ | `gxy_tool_bot/templates/feedback_system.txt` | Feedback flow | System prompt — tells the agent how to fix existing tools based on CI/reviewer feedback |
15
+ | `gxy_tool_bot/templates/_conventions.txt` | Both flows | Shared IUC conventions included via Jinja2 `{% include %}` in both system prompts. Update this file once to change a convention in both flows. |
16
+ | `gxy_tool_bot/address_feedback.py` (`_build_feedback_user_prompt`) | Feedback flow | User prompt — built dynamically from PR comments, CI artifacts, and file listing |
17
+
18
+ ### Validation
19
+
20
+ | File | Purpose |
21
+ |------|---------|
22
+ | `gxy_tool_bot/validation.py` | `ValidationResult`, `validate_generated_files`, and `run_agent_with_validation` — all validation logic lives here |
23
+ | `gxy_tool_bot/generator.py` | `FileWriter`, `GeneratedFile`, `GeneratedTool`, tool definitions, and the `generate_tool` entry point |
24
+ | `gxy_tool_bot/address_feedback.py` | Feedback collection, prompt building, and the `address_feedback` entry point |
25
+
26
+ ### Agent loop
27
+
28
+ | File | Purpose |
29
+ |------|---------|
30
+ | `gxy_tool_bot/agent_loop.py` | Core agent loop — handles tool calls, message history, iteration limits |
31
+
32
+ ## When to Put Things Where
33
+
34
+ There are three places a convention can live. The goal is a concise prompt that
35
+ gets the agent writing quickly, with validation as a safety net — and letting
36
+ planemo CI catch the rest.
37
+
38
+ ### 1. System prompts (proactive guidance)
39
+
40
+ **Use when:** The convention can't be tested by inspecting files, or requires
41
+ judgment/context the agent needs before writing.
42
+
43
+ **Files:** `templates/generator_system.txt`, `templates/feedback_system.txt`
44
+ (usually add to both).
45
+
46
+ **Examples:** "use `galaxy_slots` for threading", "make asserts strong and
47
+ specific", "use `mv` instead of `cp`".
48
+
49
+ **Keep concise** — every line costs tokens on every LLM call. Prefer getting
50
+ the agent to write something and iterate rather than bogging it down with
51
+ exhaustive rules upfront.
52
+
53
+ ### 2. Validation checks (structural safety net)
54
+
55
+ **Use when:** The convention can be detected by inspecting the generated files
56
+ (XML structure, attribute patterns, missing test data, etc.).
57
+
58
+ **File:** `gxy_tool_bot/validation.py` → `validate_generated_files`
59
+
60
+ **Each check must produce a clear error message** telling the agent exactly
61
+ what to fix. These run after the agent writes, so they don't bloat the prompt
62
+ but still catch mistakes on retry.
63
+
64
+ **Examples:** "don't use the bare default output label", "missing
65
+ `expect_num_outputs` on `<test>`", "Cheetah in `<xml>` macros".
66
+
67
+ ### 3. Neither (let planemo CI catch it)
68
+
69
+ **Use when:** Planemo already checks it explicitly (e.g. XML well-formedness,
70
+ shed metadata, duplicated output labels).
71
+
72
+ The CI workflow reports these failures and the feedback flow picks them up on
73
+ the next iteration. Only add a check to validation or the prompt if the bot is
74
+ **consistently** making that specific mistake, wasting tokens and maintainer time
75
+ on retries that a simple upfront rule would prevent.
76
+
77
+ ### Quick reference
78
+
79
+ | Tier | Where | When | Token cost |
80
+ |------|-------|------|------------|
81
+ | Prompt | `templates/*_system.txt` | Can't test by inspection; needs judgment | Every LLM call |
82
+ | Validation | `validation.py` | Can inspect files; clear fix message | Only on retry |
83
+ | Neither | Planemo CI | Planemo already checks it | Zero |
84
+
85
+ ### Adding a new tool for the agent
86
+
87
+ Add the tool definition to `_build_tool_definitions` in `gxy_tool_bot/generator.py`.
88
+ If the tool has a handler method, add it to the `FileWriter` class (for file-related
89
+ tools) or as a standalone function.
90
+
91
+ ### Modifying the feedback prompt
92
+
93
+ The feedback user prompt is built dynamically in `_build_feedback_user_prompt`
94
+ in `gxy_tool_bot/address_feedback.py`. The system prompt is in
95
+ `templates/feedback_system.txt`.
96
+
97
+ ## Running Tests
98
+
99
+ ```bash
100
+ conda run -n gxy-tool-bot python -m pytest tests/ -v
101
+ ```
102
+
103
+ Validation tests are in `tests/test_generator.py` (they test
104
+ `validate_generated_files` from `gxy_tool_bot/validation.py`).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Danielle Callan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: gxy-tool-bot
3
+ Version: 0.1.0
4
+ Summary: Agentic bot that generates Galaxy tool wrappers from user requests
5
+ Author: gxy-tool-bot contributors
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.12
9
+ Requires-Dist: beautifulsoup4>=4.12
10
+ Requires-Dist: click>=8.1
11
+ Requires-Dist: httpx>=0.27
12
+ Requires-Dist: jinja2>=3.1
13
+ Requires-Dist: pyyaml>=6.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest-mock>=3.12; extra == 'dev'
16
+ Requires-Dist: pytest>=8.0; extra == 'dev'
17
+ Requires-Dist: respx>=0.21; extra == 'dev'
18
+ Requires-Dist: ruff>=0.5; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # gxy-tool-bot
22
+
23
+ Because once upon a time Björn said to Danielle: Wouldn't an Agentic Galaxy Tool Bot be cool? :smile:
24
+
25
+ So this is an agentic bot that generates [Galaxy](https://galaxyproject.org/) tool wrappers from user requests, powered by LLM APIs and orchestrated through GitHub Actions.
26
+
27
+ ## Overview
28
+
29
+ `gxy-tool-bot` is a Python library + companion GitHub Actions workflows that automate the creation of Galaxy tool wrappers. It is **not a tool repo itself** — it's a library consumed by repos that house Galaxy tools.
30
+
31
+ ## Current Status
32
+
33
+ This repository is under active development. The bot can plan tool wrappers, generate XML/macros/test data, and open PRs automatically. It has been tested end-to-end on real tool requests. Expect rough edges and iterate on configuration as needed.
34
+
35
+ ## How it works
36
+
37
+ 1. **Request:** Users file a GitHub issue using the "Tool Request" issue template (structured fields for tool name, description, links, contact).
38
+ 2. **Plan:** The `tool-request` label triggers a workflow. An agent researches the tool (bioconda, GitHub, publications, web) and posts a plan as an issue comment with a `plan-ready` label.
39
+ 3. **Review:** A maintainer reviews the plan and adds the `ready-to-implement` label.
40
+ 4. **Generate:** An agent generates the tool XML, macros, and test data, then opens a PR with a `pr-opened` label on the issue. If the agent gives up or crashes, a `generation-failed` label is applied instead. If generation completes but validation finds issues, the PR is still created with the validation errors noted in the description — apply the `address-feedback` label to have the bot attempt fixes.
41
+
42
+ ## Setup (for consuming repos)
43
+
44
+ ### 1. Install the bot
45
+
46
+ The bot can be installed from PyPI or directly from GitHub:
47
+
48
+ ```bash
49
+ pip install gxy-tool-bot # from PyPI
50
+ pip install git+https://github.com/d-callan/gxy-tool-bot.git # latest from GitHub
51
+ ```
52
+
53
+ ### 2. Create a config file
54
+
55
+ Create `.gxy-tool-bot.yml` in the repo root:
56
+
57
+ ```yaml
58
+ api:
59
+ base_url: https://openrouter.ai/api/v1 # or https://api.openai.com/v1
60
+ model: z-ai/glm-5.2 # or gpt-4o, etc.
61
+ fallback_models: # optional; tried in order if primary fails
62
+ - deepseek-ai/deepseek-r1
63
+ - gpt-4o
64
+ max_tool_iterations: 25
65
+ temperature_plan: 0.4
66
+ temperature_generate: 0.2
67
+ max_context_chars: 100000
68
+ max_validation_retries: 3
69
+ read_timeout: 600 # seconds; increase for slow models
70
+
71
+ exemplars:
72
+ - url: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/bcftools_view.xml
73
+ macros: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/macros.xml
74
+ shed_yml: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/.shed.yml
75
+ - url: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/seqtk_seq.xml
76
+ macros: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/macros.xml
77
+ shed_yml: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/.shed.yml
78
+
79
+ # repo is optional — falls back to GITHUB_REPOSITORY env var (set automatically in GitHub Actions)
80
+ repo: your-org/your-repo
81
+
82
+ allowed_maintainers:
83
+ - your-github-handle
84
+ ```
85
+
86
+ ### 3. Create GitHub labels
87
+
88
+ Create these labels in the repo (Settings → Labels):
89
+
90
+ | Label | Color | Purpose |
91
+ |-------|-------|---------|
92
+ | `tool-request` | `#0075ca` | Applied automatically by issue template; triggers planning |
93
+ | `plan-ready` | `#a2eeef` | Applied by bot after plan is posted |
94
+ | `ready-to-implement` | `#0e8a16` | Applied by maintainer to approve plan; triggers generation |
95
+ | `pr-opened` | `#1d76db` | Applied by bot after PR is created |
96
+ | `generation-failed` | `#b60205` | Applied by bot if generation or planning fails |
97
+ | `retry-plan` | `#fbca04` | Applied by user/maintainer to re-trigger planning after a failure |
98
+ | `retry-generate` | `#fbca04` | Applied by user/maintainer to re-trigger generation after a failure |
99
+ | `address-feedback` | `#5319e7` | Applied to a PR to have the bot address review comments and CI failures |
100
+
101
+ ### 4. Add the issue template
102
+
103
+ Copy `examples/issue-template-tool-request.yml` from this repo into your repo's `.github/ISSUE_TEMPLATE/tool-request.yml`. The template auto-applies the `tool-request` label so the planning workflow triggers automatically.
104
+
105
+ ### 5. Add workflow files
106
+
107
+ Copy the workflow templates from the [`workflows/`](workflows/) directory in this repo into your repo's `.github/workflows/`:
108
+
109
+ - **`on-tool-request.yml`** → `.github/workflows/gxy-on-tool-request.yml` — triggers on new issues with `tool-request` label or when `retry-plan` label is added; runs the planner
110
+ - **`on-ready-to-implement.yml`** → `.github/workflows/gxy-on-ready-to-implement.yml` — triggers when `ready-to-implement` or `retry-generate` label is added; runs the generator and opens a PR
111
+ - **`on-pr-feedback.yml`** → `.github/workflows/gxy-on-pr-feedback.yml` — triggers when `address-feedback` label is added to a PR; reads review comments and CI failures, pushes fixes as new commits
112
+
113
+ > **CI artifact assumption:** The feedback workflow fetches CI failure details from GitHub Actions artifacts. This assumes the CI workflow uploads failure reports as artifacts (e.g. lint reports as `.txt` files, planemo test results as `.json`), following the same conventions as the [tools-iuc](https://github.com/galaxyproject/tools-iuc) repo's `pr.yaml` workflow. If your repo uses a different CI setup that doesn't upload artifacts on failure, the bot will not be able to include CI failure details in its feedback context.
114
+
115
+ > **Validation flag file:** When generation or feedback addressing completes but validation finds issues, the CLI writes a `.validation-failed` flag file to `GITHUB_WORKSPACE` (a built-in GitHub Actions env var). The workflows check for this file to post a comment on the PR noting that validation issues exist. The file is cleaned up after use and is never committed.
116
+
117
+ Both workflows install the bot from PyPI (pinned to a specific version):
118
+
119
+ ```yaml
120
+ - run: pip install gxy-tool-bot==0.1.0
121
+ ```
122
+
123
+ ### 6. Add repo secrets
124
+
125
+ Go to Settings → Secrets and variables → Actions → New repository secret:
126
+
127
+ | Secret | Value | Used by |
128
+ |--------|-------|---------|
129
+ | `GXY_TOOL_BOT_API_KEY` | Your LLM API key (e.g. OpenRouter key) | Plan + generate workflows |
130
+
131
+ The `GITHUB_TOKEN` (automatically provided by GitHub Actions) is used for issue comments, labels, and PR creation — no extra secret needed.
132
+
133
+ ### 7. Enable Issues
134
+
135
+ If the repo is a fork, Issues may be disabled by default. Enable them under Settings → General → Features → check "Issues".
136
+
137
+ ### 8. Enable Actions
138
+
139
+ Make sure Actions are enabled: Settings → Actions → General → "Allow all actions and reusable workflows".
140
+
141
+ ### 9. Test it
142
+
143
+ 1. Go to Issues → New Issue → "Tool Request" template
144
+ 2. Fill in the fields and submit
145
+ 3. Check the Actions tab — the planning workflow should run
146
+ 4. After the plan is posted, add the `ready-to-implement` label
147
+ 5. The generation workflow should run and open a PR
148
+
149
+ ## Philosophy & Design Decisions
150
+
151
+ ### Run in GitHub Actions, not a black box
152
+
153
+ The bot runs entirely in GitHub Actions. This keeps agent traces, plans, generated files, and CI results publicly inspectable. Every run produces logs and artifacts you can review after the fact — to diagnose why a specific tool was written a certain way, or to identify patterns to improve the bot. The Actions logs capture tool calls, context size per iteration, and validation results; combined with file-based artifacts (generated files, test data) and summary comments posted to issues and PRs, this provides enough transparency to understand what the bot did and why.
154
+
155
+ ### Validate files, don't over-prompt
156
+
157
+ Best practices don't go in the system prompt — they go in a [validation loop](gxy_tool_bot/validation.py) that inspects generated files for common mistakes (missing test data, bare output labels, Cheetah in macros, etc.) and instructs the agent to fix them in a retry loop. This keeps prompts concise (every line costs tokens on every LLM call) and prevents unnecessary bloat that might distract or confuse the agent, while still catching errors structurally. See [DEVELOPMENT.md](DEVELOPMENT.md) for the full tiered guidance on where to put conventions.
158
+
159
+ ### Incremental feedback, not infinite loops
160
+
161
+ The validation loop only runs a limited number of times before forcing the result back to human hands — a commit is pushed to a PR that a maintainer can review and provide further direction on. The maintainer adds the `address-feedback` label to trigger another loop with CI failures and review comments incorporated. This keeps the bot autonomous for the common case but avoids burning tokens indefinitely on a problem it can't solve alone.
162
+
163
+ ### Let planemo CI catch the rest
164
+
165
+ Things planemo already checks (XML well-formedness, shed metadata, duplicated output labels) are deliberately not duplicated in validation. The CI workflow reports these failures and the feedback flow picks them up on the next iteration. Only add a validation check if the bot is consistently making a specific mistake that wastes tokens and maintainer time.
166
+
167
+ ### Give the agent a way out
168
+
169
+ The agent has a `give_up` tool that lets it stop and explain why it can't proceed — open assumptions, unresolved questions, or fundamental issues with the request. A tool request might produce a recommendation not to make a tool rather than a plan to make one. A feedback request might result in push back with no commit until something the agent flags is resolved. This prevents forcing the agent into action when it doesn't have enough information, which would produce low-quality output. Better to surface the problem to a human than to generate a confident but wrong tool wrapper.
170
+
171
+ ## Development
172
+
173
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for guidance on the codebase structure, where to add new conventions (prompts vs. validation vs. let CI catch it), and how the generation and feedback flows are organized.
174
+
175
+ ## License
176
+
177
+ MIT
@@ -0,0 +1,157 @@
1
+ # gxy-tool-bot
2
+
3
+ Because once upon a time Björn said to Danielle: Wouldn't an Agentic Galaxy Tool Bot be cool? :smile:
4
+
5
+ So this is an agentic bot that generates [Galaxy](https://galaxyproject.org/) tool wrappers from user requests, powered by LLM APIs and orchestrated through GitHub Actions.
6
+
7
+ ## Overview
8
+
9
+ `gxy-tool-bot` is a Python library + companion GitHub Actions workflows that automate the creation of Galaxy tool wrappers. It is **not a tool repo itself** — it's a library consumed by repos that house Galaxy tools.
10
+
11
+ ## Current Status
12
+
13
+ This repository is under active development. The bot can plan tool wrappers, generate XML/macros/test data, and open PRs automatically. It has been tested end-to-end on real tool requests. Expect rough edges and iterate on configuration as needed.
14
+
15
+ ## How it works
16
+
17
+ 1. **Request:** Users file a GitHub issue using the "Tool Request" issue template (structured fields for tool name, description, links, contact).
18
+ 2. **Plan:** The `tool-request` label triggers a workflow. An agent researches the tool (bioconda, GitHub, publications, web) and posts a plan as an issue comment with a `plan-ready` label.
19
+ 3. **Review:** A maintainer reviews the plan and adds the `ready-to-implement` label.
20
+ 4. **Generate:** An agent generates the tool XML, macros, and test data, then opens a PR with a `pr-opened` label on the issue. If the agent gives up or crashes, a `generation-failed` label is applied instead. If generation completes but validation finds issues, the PR is still created with the validation errors noted in the description — apply the `address-feedback` label to have the bot attempt fixes.
21
+
22
+ ## Setup (for consuming repos)
23
+
24
+ ### 1. Install the bot
25
+
26
+ The bot can be installed from PyPI or directly from GitHub:
27
+
28
+ ```bash
29
+ pip install gxy-tool-bot # from PyPI
30
+ pip install git+https://github.com/d-callan/gxy-tool-bot.git # latest from GitHub
31
+ ```
32
+
33
+ ### 2. Create a config file
34
+
35
+ Create `.gxy-tool-bot.yml` in the repo root:
36
+
37
+ ```yaml
38
+ api:
39
+ base_url: https://openrouter.ai/api/v1 # or https://api.openai.com/v1
40
+ model: z-ai/glm-5.2 # or gpt-4o, etc.
41
+ fallback_models: # optional; tried in order if primary fails
42
+ - deepseek-ai/deepseek-r1
43
+ - gpt-4o
44
+ max_tool_iterations: 25
45
+ temperature_plan: 0.4
46
+ temperature_generate: 0.2
47
+ max_context_chars: 100000
48
+ max_validation_retries: 3
49
+ read_timeout: 600 # seconds; increase for slow models
50
+
51
+ exemplars:
52
+ - url: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/bcftools_view.xml
53
+ macros: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/macros.xml
54
+ shed_yml: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/bcftools/.shed.yml
55
+ - url: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/seqtk_seq.xml
56
+ macros: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/macros.xml
57
+ shed_yml: https://raw.githubusercontent.com/galaxyproject/tools-iuc/main/tools/seqtk/.shed.yml
58
+
59
+ # repo is optional — falls back to GITHUB_REPOSITORY env var (set automatically in GitHub Actions)
60
+ repo: your-org/your-repo
61
+
62
+ allowed_maintainers:
63
+ - your-github-handle
64
+ ```
65
+
66
+ ### 3. Create GitHub labels
67
+
68
+ Create these labels in the repo (Settings → Labels):
69
+
70
+ | Label | Color | Purpose |
71
+ |-------|-------|---------|
72
+ | `tool-request` | `#0075ca` | Applied automatically by issue template; triggers planning |
73
+ | `plan-ready` | `#a2eeef` | Applied by bot after plan is posted |
74
+ | `ready-to-implement` | `#0e8a16` | Applied by maintainer to approve plan; triggers generation |
75
+ | `pr-opened` | `#1d76db` | Applied by bot after PR is created |
76
+ | `generation-failed` | `#b60205` | Applied by bot if generation or planning fails |
77
+ | `retry-plan` | `#fbca04` | Applied by user/maintainer to re-trigger planning after a failure |
78
+ | `retry-generate` | `#fbca04` | Applied by user/maintainer to re-trigger generation after a failure |
79
+ | `address-feedback` | `#5319e7` | Applied to a PR to have the bot address review comments and CI failures |
80
+
81
+ ### 4. Add the issue template
82
+
83
+ Copy `examples/issue-template-tool-request.yml` from this repo into your repo's `.github/ISSUE_TEMPLATE/tool-request.yml`. The template auto-applies the `tool-request` label so the planning workflow triggers automatically.
84
+
85
+ ### 5. Add workflow files
86
+
87
+ Copy the workflow templates from the [`workflows/`](workflows/) directory in this repo into your repo's `.github/workflows/`:
88
+
89
+ - **`on-tool-request.yml`** → `.github/workflows/gxy-on-tool-request.yml` — triggers on new issues with `tool-request` label or when `retry-plan` label is added; runs the planner
90
+ - **`on-ready-to-implement.yml`** → `.github/workflows/gxy-on-ready-to-implement.yml` — triggers when `ready-to-implement` or `retry-generate` label is added; runs the generator and opens a PR
91
+ - **`on-pr-feedback.yml`** → `.github/workflows/gxy-on-pr-feedback.yml` — triggers when `address-feedback` label is added to a PR; reads review comments and CI failures, pushes fixes as new commits
92
+
93
+ > **CI artifact assumption:** The feedback workflow fetches CI failure details from GitHub Actions artifacts. This assumes the CI workflow uploads failure reports as artifacts (e.g. lint reports as `.txt` files, planemo test results as `.json`), following the same conventions as the [tools-iuc](https://github.com/galaxyproject/tools-iuc) repo's `pr.yaml` workflow. If your repo uses a different CI setup that doesn't upload artifacts on failure, the bot will not be able to include CI failure details in its feedback context.
94
+
95
+ > **Validation flag file:** When generation or feedback addressing completes but validation finds issues, the CLI writes a `.validation-failed` flag file to `GITHUB_WORKSPACE` (a built-in GitHub Actions env var). The workflows check for this file to post a comment on the PR noting that validation issues exist. The file is cleaned up after use and is never committed.
96
+
97
+ Both workflows install the bot from PyPI (pinned to a specific version):
98
+
99
+ ```yaml
100
+ - run: pip install gxy-tool-bot==0.1.0
101
+ ```
102
+
103
+ ### 6. Add repo secrets
104
+
105
+ Go to Settings → Secrets and variables → Actions → New repository secret:
106
+
107
+ | Secret | Value | Used by |
108
+ |--------|-------|---------|
109
+ | `GXY_TOOL_BOT_API_KEY` | Your LLM API key (e.g. OpenRouter key) | Plan + generate workflows |
110
+
111
+ The `GITHUB_TOKEN` (automatically provided by GitHub Actions) is used for issue comments, labels, and PR creation — no extra secret needed.
112
+
113
+ ### 7. Enable Issues
114
+
115
+ If the repo is a fork, Issues may be disabled by default. Enable them under Settings → General → Features → check "Issues".
116
+
117
+ ### 8. Enable Actions
118
+
119
+ Make sure Actions are enabled: Settings → Actions → General → "Allow all actions and reusable workflows".
120
+
121
+ ### 9. Test it
122
+
123
+ 1. Go to Issues → New Issue → "Tool Request" template
124
+ 2. Fill in the fields and submit
125
+ 3. Check the Actions tab — the planning workflow should run
126
+ 4. After the plan is posted, add the `ready-to-implement` label
127
+ 5. The generation workflow should run and open a PR
128
+
129
+ ## Philosophy & Design Decisions
130
+
131
+ ### Run in GitHub Actions, not a black box
132
+
133
+ The bot runs entirely in GitHub Actions. This keeps agent traces, plans, generated files, and CI results publicly inspectable. Every run produces logs and artifacts you can review after the fact — to diagnose why a specific tool was written a certain way, or to identify patterns to improve the bot. The Actions logs capture tool calls, context size per iteration, and validation results; combined with file-based artifacts (generated files, test data) and summary comments posted to issues and PRs, this provides enough transparency to understand what the bot did and why.
134
+
135
+ ### Validate files, don't over-prompt
136
+
137
+ Best practices don't go in the system prompt — they go in a [validation loop](gxy_tool_bot/validation.py) that inspects generated files for common mistakes (missing test data, bare output labels, Cheetah in macros, etc.) and instructs the agent to fix them in a retry loop. This keeps prompts concise (every line costs tokens on every LLM call) and prevents unnecessary bloat that might distract or confuse the agent, while still catching errors structurally. See [DEVELOPMENT.md](DEVELOPMENT.md) for the full tiered guidance on where to put conventions.
138
+
139
+ ### Incremental feedback, not infinite loops
140
+
141
+ The validation loop only runs a limited number of times before forcing the result back to human hands — a commit is pushed to a PR that a maintainer can review and provide further direction on. The maintainer adds the `address-feedback` label to trigger another loop with CI failures and review comments incorporated. This keeps the bot autonomous for the common case but avoids burning tokens indefinitely on a problem it can't solve alone.
142
+
143
+ ### Let planemo CI catch the rest
144
+
145
+ Things planemo already checks (XML well-formedness, shed metadata, duplicated output labels) are deliberately not duplicated in validation. The CI workflow reports these failures and the feedback flow picks them up on the next iteration. Only add a validation check if the bot is consistently making a specific mistake that wastes tokens and maintainer time.
146
+
147
+ ### Give the agent a way out
148
+
149
+ The agent has a `give_up` tool that lets it stop and explain why it can't proceed — open assumptions, unresolved questions, or fundamental issues with the request. A tool request might produce a recommendation not to make a tool rather than a plan to make one. A feedback request might result in push back with no commit until something the agent flags is resolved. This prevents forcing the agent into action when it doesn't have enough information, which would produce low-quality output. Better to surface the problem to a human than to generate a confident but wrong tool wrapper.
150
+
151
+ ## Development
152
+
153
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for guidance on the codebase structure, where to add new conventions (prompts vs. validation vs. let CI catch it), and how the generation and feedback flows are organized.
154
+
155
+ ## License
156
+
157
+ MIT
@@ -0,0 +1,45 @@
1
+ name: Tool Request
2
+ description: Request a new Galaxy tool wrapper to be generated
3
+ labels: ["tool-request"]
4
+ body:
5
+ - type: markdown
6
+ attributes:
7
+ value: |
8
+ Fill out this form to request a new Galaxy tool wrapper.
9
+ The bot will research the tool and post a plan as a comment.
10
+ A maintainer will then review and approve it for generation.
11
+ - type: input
12
+ id: tool-name
13
+ attributes:
14
+ label: Tool name
15
+ description: Name of the bioinformatics tool (e.g. samtools sort)
16
+ placeholder: e.g. samtools sort
17
+ validations:
18
+ required: true
19
+ - type: textarea
20
+ id: description
21
+ attributes:
22
+ label: Description
23
+ description: What should the tool do? What are the key inputs and outputs?
24
+ placeholder: Sort BAM files by coordinate or read name...
25
+ validations:
26
+ required: true
27
+ - type: textarea
28
+ id: links
29
+ attributes:
30
+ label: Links
31
+ description: Relevant URLs — GitHub repo, Bioconda page, DOI/publication, documentation
32
+ placeholder: |
33
+ https://github.com/samtools/samtools
34
+ https://doi.org/10.1093/bioinformatics/btp352
35
+ https://bioconda.github.io/recipes/samtools/README.html
36
+ validations:
37
+ required: false
38
+ - type: input
39
+ id: contact
40
+ attributes:
41
+ label: Contact
42
+ description: GitHub handle for follow-up questions (optional)
43
+ placeholder: "@your-github-handle"
44
+ validations:
45
+ required: false
@@ -0,0 +1,3 @@
1
+ """gxy-tool-bot: Agentic bot that generates Galaxy tool wrappers from user requests."""
2
+
3
+ __version__ = "0.1.0"