Skip to content

Commit 768a8ec

Browse files
Copilotpelikhandsyme
authored
Import custom agents when importing workflows (#160)
* Initial plan * Update import-workflow to import referenced custom agents Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@users.noreply.github.com> Co-authored-by: Peli de Halleux <pelikhan@users.noreply.github.com>
1 parent 6d16104 commit 768a8ec

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

.github/workflows/import-workflow.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,38 @@ Before importing, verify the workflow does not already exist in this repository:
7070
- Check `README.md` for an existing entry
7171
- If the workflow already exists, exit with a clear message explaining the duplicate
7272

73-
## Step 3: Adapt the workflow for general use
73+
## Step 3: Check for custom agent references
74+
75+
Before adapting the workflow, check if it references any custom agents:
76+
77+
1. **Check the `engine.agent` field** in the workflow frontmatter:
78+
- If `engine.agent` is present, it references `.github/agents/{agent}.agent.md` from the source repository
79+
- Example: `agent: technical-doc-writer``.github/agents/technical-doc-writer.agent.md`
80+
81+
2. **Check the `imports` array** for `.github/agents/` references:
82+
- Imports can include paths like `.github/agents/my-agent.agent.md`
83+
- These are custom agent files that need to be imported alongside the workflow
84+
85+
3. **Fetch referenced custom agents** from the source repository:
86+
- Use `get_file_contents` to fetch each custom agent file from the source repository
87+
- Custom agent files are markdown files with frontmatter and agent instructions
88+
- Save each custom agent to `.github/agents/<agent-name>.agent.md` in this repository
89+
90+
4. **Note**: According to gh-aw documentation, only one custom agent file is allowed per workflow
91+
92+
## Step 4: Adapt the workflow for general use
7493

7594
The workflow from the source repository may contain project-specific references. Adapt it:
7695

7796
- Remove references specific to the source project (internal tools, specific file paths, project-specific patterns)
7897
- Generalize the prompt to work across different repository types and languages
7998
- Keep the core value and behavior of the workflow intact
8099
- Preserve the frontmatter structure (triggers, permissions, safe-outputs, tools, timeout)
100+
- **Preserve custom agent references** (engine.agent and imports) if they were imported
81101

82102
Save the adapted workflow to `workflows/<workflow-name>.md`.
83103

84-
## Step 4: Create the documentation page
104+
## Step 5: Create the documentation page
85105

86106
Create a new file at `docs/<workflow-name>.md` following the established documentation pattern used by other docs pages in this repository. The documentation page MUST include these sections:
87107

@@ -119,7 +139,7 @@ Create a new file at `docs/<workflow-name>.md` following the established documen
119139

120140
Study the existing docs pages (e.g., `docs/ci-doctor.md`, `docs/issue-triage.md`, `docs/plan.md`, `docs/daily-doc-updater.md`) to match the tone and style.
121141

122-
## Step 5: Update README.md
142+
## Step 6: Update README.md
123143

124144
Add the new workflow to the appropriate section in `README.md`. The existing categories are:
125145

@@ -137,18 +157,19 @@ Use the format: `- [<Emoji> <Title>](docs/<name>.md) - <Short description>`
137157

138158
If the workflow doesn't fit any existing category, create a new appropriately-named category section. Place it logically among the existing sections.
139159

140-
## Step 6: Compile the workflow
160+
## Step 7: Compile the workflow
141161

142162
Run `gh aw compile --dir workflows` to generate the `.lock.yml` file for the new workflow.
143163

144164
If `gh aw` is not installed, install it first with `gh extension install github/gh-aw`.
145165

146-
## Step 7: Create a pull request
166+
## Step 8: Create a pull request
147167

148168
Create a draft pull request with all the changes:
149169

150170
- The new workflow file in `workflows/`
151171
- The compiled `.lock.yml` file
172+
- Any imported custom agent files in `.github/agents/`
152173
- The new documentation page in `docs/`
153174
- The updated `README.md`
154175

@@ -157,6 +178,7 @@ The PR description should include:
157178
- **Source**: Link to the original workflow in the source repository
158179
- **What it does**: Brief description of the workflow's purpose
159180
- **Adaptations**: What was changed to generalize the workflow
181+
- **Custom agents**: List any custom agent files that were imported
160182
- **Category**: Which README section it was added to
161183

162184
## Important Guidelines

0 commit comments

Comments
 (0)