Skip to content

Commit f50f933

Browse files
Copilotpelikhan
andcommitted
Convert setup-agentic-workflows.prompt.md to custom agent
- Created new setup-agentic-workflows.md agent template - Updated commands.go to embed the new agent template - Renamed function from ensureGettingStartedPrompt to ensureSetupAgenticWorkflowsAgent - Updated add_command.go to use ensureAgentFromTemplate instead of ensurePromptFromTemplate - Updated init.go to create agent instead of prompt - Renamed and updated test file from getting_started_prompt_test.go to setup_agentic_workflows_agent_test.go - Updated init_command.go documentation to mention the new agent - All tests pass successfully Co-authored-by: pelikhan <[email protected]>
1 parent cf222c2 commit f50f933

File tree

6 files changed

+148
-41
lines changed

6 files changed

+148
-41
lines changed

pkg/cli/add_command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,9 @@ func ensureSharedAgenticWorkflowPrompt(verbose bool, skipInstructions bool) erro
709709
return ensurePromptFromTemplate("create-shared-agentic-workflow.prompt.md", sharedAgenticWorkflowPromptTemplate, verbose, skipInstructions)
710710
}
711711

712-
// ensureGettingStartedPrompt ensures that .github/prompts/setup-agentic-workflows.prompt.md contains the getting started guide
713-
func ensureGettingStartedPrompt(verbose bool, skipInstructions bool) error {
714-
return ensurePromptFromTemplate("setup-agentic-workflows.prompt.md", gettingStartedPromptTemplate, verbose, skipInstructions)
712+
// ensureSetupAgenticWorkflowsAgent ensures that .github/agents/setup-agentic-workflows.md contains the setup guide agent
713+
func ensureSetupAgenticWorkflowsAgent(verbose bool, skipInstructions bool) error {
714+
return ensureAgentFromTemplate("setup-agentic-workflows.md", setupAgenticWorkflowsAgentTemplate, verbose, skipInstructions)
715715
}
716716

717717
// checkCleanWorkingDirectory checks if there are uncommitted changes

pkg/cli/commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ var agenticWorkflowAgentTemplate string
2828
//go:embed templates/create-shared-agentic-workflow.prompt.md
2929
var sharedAgenticWorkflowPromptTemplate string
3030

31-
//go:embed templates/setup-agentic-workflows.prompt.md
32-
var gettingStartedPromptTemplate string
31+
//go:embed templates/setup-agentic-workflows.md
32+
var setupAgenticWorkflowsAgentTemplate string
3333

3434
// SetVersionInfo sets the version information for the CLI
3535
func SetVersionInfo(v string) {

pkg/cli/init.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ func InitRepository(verbose bool, mcp bool) error {
6969
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Created /create-shared-agentic-workflow command"))
7070
}
7171

72-
// Write getting started prompt
73-
initLog.Print("Writing getting started prompt")
74-
if err := ensureGettingStartedPrompt(verbose, false); err != nil {
75-
initLog.Printf("Failed to write getting started prompt: %v", err)
76-
return fmt.Errorf("failed to write getting started prompt: %w", err)
72+
// Write setup agentic workflows agent
73+
initLog.Print("Writing setup agentic workflows agent")
74+
if err := ensureSetupAgenticWorkflowsAgent(verbose, false); err != nil {
75+
initLog.Printf("Failed to write setup agentic workflows agent: %v", err)
76+
return fmt.Errorf("failed to write setup agentic workflows agent: %w", err)
7777
}
7878
if verbose {
79-
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Created getting started guide"))
79+
fmt.Fprintln(os.Stderr, console.FormatSuccessMessage("Created setup agentic workflows agent"))
8080
}
8181

8282
// Configure MCP if requested

pkg/cli/init_command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ This command:
2323
- Configures .gitattributes to mark .lock.yml files as generated
2424
- Creates GitHub Copilot custom instructions at .github/instructions/github-agentic-workflows.instructions.md
2525
- Creates the custom agent for workflow creation at .github/agents/create-agentic-workflow.md
26+
- Creates the setup agentic workflows agent at .github/agents/setup-agentic-workflows.md
2627
- Removes the old /create-agentic-workflow prompt if it exists
2728
2829
With --mcp flag:
@@ -31,6 +32,7 @@ With --mcp flag:
3132
3233
After running this command, you can:
3334
- Use GitHub Copilot Chat with @.github/agents/create-agentic-workflow.md to create workflows interactively
35+
- Use GitHub Copilot Chat with @.github/agents/setup-agentic-workflows.md for setup guidance
3436
- Add workflows from the catalog with: ` + constants.CLIExtensionPrefix + ` add <workflow-name>
3537
- Create new workflows from scratch with: ` + constants.CLIExtensionPrefix + ` new <workflow-name>
3638

pkg/cli/getting_started_prompt_test.go renamed to pkg/cli/setup_agentic_workflows_agent_test.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import (
88
"testing"
99
)
1010

11-
func TestEnsureGettingStartedPrompt(t *testing.T) {
11+
func TestEnsureSetupAgenticWorkflowsAgent(t *testing.T) {
1212
tests := []struct {
1313
name string
1414
existingContent string
1515
expectedContent string
1616
}{
1717
{
18-
name: "creates new getting started prompt file",
18+
name: "creates new setup agentic workflows agent file",
1919
existingContent: "",
20-
expectedContent: strings.TrimSpace(gettingStartedPromptTemplate),
20+
expectedContent: strings.TrimSpace(setupAgenticWorkflowsAgentTemplate),
2121
},
2222
{
2323
name: "does not modify existing correct file",
24-
existingContent: gettingStartedPromptTemplate,
25-
expectedContent: strings.TrimSpace(gettingStartedPromptTemplate),
24+
existingContent: setupAgenticWorkflowsAgentTemplate,
25+
expectedContent: strings.TrimSpace(setupAgenticWorkflowsAgentTemplate),
2626
},
2727
{
2828
name: "updates modified file",
29-
existingContent: "# Modified Getting Started\n\nThis is a modified version.",
30-
expectedContent: strings.TrimSpace(gettingStartedPromptTemplate),
29+
existingContent: "# Modified Setup\n\nThis is a modified version.",
30+
expectedContent: strings.TrimSpace(setupAgenticWorkflowsAgentTemplate),
3131
},
3232
}
3333

@@ -51,34 +51,34 @@ func TestEnsureGettingStartedPrompt(t *testing.T) {
5151
t.Fatalf("Failed to init git repo: %v", err)
5252
}
5353

54-
promptsDir := filepath.Join(tempDir, ".github", "prompts")
55-
promptPath := filepath.Join(promptsDir, "setup-agentic-workflows.prompt.md")
54+
agentsDir := filepath.Join(tempDir, ".github", "agents")
55+
agentPath := filepath.Join(agentsDir, "setup-agentic-workflows.md")
5656

5757
// Create initial content if specified
5858
if tt.existingContent != "" {
59-
if err := os.MkdirAll(promptsDir, 0755); err != nil {
60-
t.Fatalf("Failed to create prompts directory: %v", err)
59+
if err := os.MkdirAll(agentsDir, 0755); err != nil {
60+
t.Fatalf("Failed to create agents directory: %v", err)
6161
}
62-
if err := os.WriteFile(promptPath, []byte(tt.existingContent), 0644); err != nil {
63-
t.Fatalf("Failed to create initial getting started prompt: %v", err)
62+
if err := os.WriteFile(agentPath, []byte(tt.existingContent), 0644); err != nil {
63+
t.Fatalf("Failed to create initial setup agent: %v", err)
6464
}
6565
}
6666

6767
// Call the function with skipInstructions=false to test the functionality
68-
err = ensureGettingStartedPrompt(false, false)
68+
err = ensureSetupAgenticWorkflowsAgent(false, false)
6969
if err != nil {
70-
t.Fatalf("ensureGettingStartedPrompt() returned error: %v", err)
70+
t.Fatalf("ensureSetupAgenticWorkflowsAgent() returned error: %v", err)
7171
}
7272

7373
// Check that file exists
74-
if _, err := os.Stat(promptPath); os.IsNotExist(err) {
75-
t.Fatalf("Expected getting started prompt file to exist")
74+
if _, err := os.Stat(agentPath); os.IsNotExist(err) {
75+
t.Fatalf("Expected setup agentic workflows agent file to exist")
7676
}
7777

7878
// Check content
79-
content, err := os.ReadFile(promptPath)
79+
content, err := os.ReadFile(agentPath)
8080
if err != nil {
81-
t.Fatalf("Failed to read getting started prompt: %v", err)
81+
t.Fatalf("Failed to read setup agent: %v", err)
8282
}
8383

8484
contentStr := strings.TrimSpace(string(content))
@@ -93,7 +93,7 @@ func TestEnsureGettingStartedPrompt(t *testing.T) {
9393
}
9494
}
9595

96-
func TestEnsureGettingStartedPrompt_WithSkipInstructionsTrue(t *testing.T) {
96+
func TestEnsureSetupAgenticWorkflowsAgent_WithSkipInstructionsTrue(t *testing.T) {
9797
// Create a temporary directory for testing
9898
tempDir := t.TempDir()
9999

@@ -112,22 +112,22 @@ func TestEnsureGettingStartedPrompt_WithSkipInstructionsTrue(t *testing.T) {
112112
t.Fatalf("Failed to init git repo: %v", err)
113113
}
114114

115-
promptsDir := filepath.Join(tempDir, ".github", "prompts")
116-
promptPath := filepath.Join(promptsDir, "setup-agentic-workflows.prompt.md")
115+
agentsDir := filepath.Join(tempDir, ".github", "agents")
116+
agentPath := filepath.Join(agentsDir, "setup-agentic-workflows.md")
117117

118118
// Call the function with skipInstructions=true
119-
err = ensureGettingStartedPrompt(false, true)
119+
err = ensureSetupAgenticWorkflowsAgent(false, true)
120120
if err != nil {
121-
t.Fatalf("ensureGettingStartedPrompt() returned error: %v", err)
121+
t.Fatalf("ensureSetupAgenticWorkflowsAgent() returned error: %v", err)
122122
}
123123

124124
// Check that file does not exist
125-
if _, err := os.Stat(promptPath); !os.IsNotExist(err) {
126-
t.Fatalf("Expected getting started prompt file to not exist when skipInstructions=true")
125+
if _, err := os.Stat(agentPath); !os.IsNotExist(err) {
126+
t.Fatalf("Expected setup agent file to not exist when skipInstructions=true")
127127
}
128128
}
129129

130-
func TestGettingStartedPromptContainsRequiredSections(t *testing.T) {
130+
func TestSetupAgenticWorkflowsAgentContainsRequiredSections(t *testing.T) {
131131
// Verify the template contains all required sections
132132
requiredSections := []string{
133133
"Configure Secrets for Your Chosen Agent",
@@ -141,7 +141,7 @@ func TestGettingStartedPromptContainsRequiredSections(t *testing.T) {
141141
"gh secret set",
142142
}
143143

144-
content := strings.TrimSpace(gettingStartedPromptTemplate)
144+
content := strings.TrimSpace(setupAgenticWorkflowsAgentTemplate)
145145

146146
for _, section := range requiredSections {
147147
if !strings.Contains(content, section) {
@@ -150,14 +150,14 @@ func TestGettingStartedPromptContainsRequiredSections(t *testing.T) {
150150
}
151151
}
152152

153-
func TestGettingStartedPromptHasValidDocumentationLinks(t *testing.T) {
153+
func TestSetupAgenticWorkflowsAgentHasValidDocumentationLinks(t *testing.T) {
154154
// Verify the template contains documentation links
155155
requiredLinks := []string{
156156
"https://githubnext.github.io/gh-aw/reference/engines/",
157157
"https://github.com/settings/tokens",
158158
}
159159

160-
content := strings.TrimSpace(gettingStartedPromptTemplate)
160+
content := strings.TrimSpace(setupAgenticWorkflowsAgentTemplate)
161161

162162
for _, link := range requiredLinks {
163163
if !strings.Contains(content, link) {
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
name: setup-agentic-workflows
3+
description: A guided agent to help you set up your agentic workflows using gh-aw
4+
tools:
5+
- runInTerminal
6+
- getTerminalOutput
7+
- createFile
8+
- createDirectory
9+
- editFiles
10+
- search
11+
- changes
12+
- githubRepo
13+
---
14+
15+
You are a conversational chat agent that interacts with the user to gather requirements and iteratively builds the workflow. Don't overwhelm the user with too many questions at once or long bullet points; always ask the user to express their intent in their own words and translate it in an agent workflow.
16+
17+
- Do NOT tell me what you did until I ask you to as a question to the user.
18+
19+
## Starting the conversation
20+
21+
1. **Initial Decision**
22+
Start by asking the user:
23+
```
24+
What agent will you use today?
25+
- `copilot` (GitHub Copilot CLI) - **Recommended for most users**
26+
- `claude` (Anthropic Claude Code) - Great for reasoning and code analysis
27+
- `codex` (OpenAI Codex) - Designed for code-focused tasks
28+
29+
Once you choose, I'll guide you through setting up any required secrets.
30+
```
31+
32+
That's it stop here and wait for the user to respond.
33+
34+
## Configure Secrets for Your Chosen Agent
35+
36+
### For `copilot` (Recommended)
37+
Say to the user:
38+
````
39+
You'll need a GitHub Personal Access Token with Copilot subscription.
40+
41+
**Steps:**
42+
1. Go to [GitHub Token Settings](https://github.com/settings/tokens)
43+
2. Create a Personal Access Token (Classic) with appropriate scopes
44+
3. Ensure you have an active Copilot subscription
45+
46+
**Documentation:** [GitHub Copilot Engine Setup](https://githubnext.github.io/gh-aw/reference/engines/#github-copilot-default)
47+
48+
**Set the secret** in a separate terminal window (never share your secret directly with the agent):
49+
50+
```bash
51+
gh secret set COPILOT_CLI_TOKEN -a actions --body "your-github-pat-here"
52+
```
53+
````
54+
55+
### For `claude`
56+
57+
Say to the user:
58+
````
59+
You'll need an Anthropic API key.
60+
61+
**Steps:**
62+
1. Sign up for Anthropic API access at [console.anthropic.com](https://console.anthropic.com/)
63+
2. Generate an API key from your account settings
64+
65+
**Documentation:** [Anthropic Claude Code Engine](https://githubnext.github.io/gh-aw/reference/engines/#anthropic-claude-code)
66+
67+
**Set the secret** in a separate terminal window:
68+
69+
```bash
70+
gh secret set ANTHROPIC_API_KEY -a actions --body "your-anthropic-api-key-here"
71+
```
72+
````
73+
74+
### For `codex`
75+
76+
Say to the user:
77+
````
78+
You'll need an OpenAI API key.
79+
80+
**Steps:**
81+
1. Sign up for OpenAI API access at [platform.openai.com](https://platform.openai.com/)
82+
2. Generate an API key from your account settings
83+
84+
**Documentation:** [OpenAI Codex Engine](https://githubnext.github.io/gh-aw/reference/engines/#openai-codex)
85+
86+
**Set the secret** in a separate terminal window:
87+
88+
```bash
89+
gh secret set OPENAI_API_KEY -a actions --body "your-openai-api-key-here"
90+
```
91+
````
92+
93+
## Build Your First Workflow
94+
95+
Say to the user:
96+
````
97+
When you're ready, just type the command:
98+
99+
```
100+
/create-agentic-workflow
101+
```
102+
103+
This will start the configuration flow to help you create your first agentic workflow.
104+
105+
````

0 commit comments

Comments
 (0)