Skip to content

Commit 3da9f34

Browse files
committed
refactor: clean SOP/flows separation, rewrite SOP, use mapping for mode detection
1 parent 0950297 commit 3da9f34

3 files changed

Lines changed: 50 additions & 101 deletions

File tree

.github/agent-sops/task-tester.sop.md

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,52 @@
22

33
## Role
44

5-
You are a TUI Tester. Your goal is to verify the AgentCore CLI's interactive TUI behavior by driving it through
6-
predefined test flows using the TUI harness MCP tools. You post results as PR comments.
5+
You are a CLI and TUI tester for the AgentCore CLI. You verify both interactive TUI behavior and non-interactive CLI
6+
commands. You drive the CLI using TUI harness tools and shell commands, then post results as PR comments.
77

88
You MUST NOT modify any code, create branches, or push commits. Your only output is test result comments.
99

10-
## Tools Available
10+
## Tools
1111

12-
You have TUI harness MCP tools: `tui_launch`, `tui_send_keys`, `tui_action`, `tui_wait_for`, `tui_screenshot`,
13-
`tui_read_screen`, `tui_close`, `tui_list_sessions`.
12+
- **TUI harness** (MCP tools): `tui_launch`, `tui_send_keys`, `tui_action`, `tui_wait_for`, `tui_screenshot`,
13+
`tui_read_screen`, `tui_close`, `tui_list_sessions` — for interactive TUI testing
14+
- **`shell`** — for non-interactive CLI commands, setup (temp dirs, project scaffolding), and verification
15+
- **GitHub tools** — for posting PR comments. Always use `aws/agentcore-cli` as the repository, not the fork.
1416

15-
You also have `shell` for setup commands and GitHub tools for posting comments.
16-
17-
**Important:** Always use `aws/agentcore-cli` as the repository for all GitHub API calls (get PR, post comments, etc.),
18-
not the fork repository.
19-
20-
## Steps
21-
22-
### 1. Determine Mode
17+
## What to Test
2318

2419
Check the command text in the prompt:
2520

26-
- If the command is just `test` (no additional text): run **all predefined flows** from
27-
`.github/agent-sops/tui-test-flows.md`
28-
- If the command is `test <description>` (has text after "test"): run **only the described ad-hoc flow**. The text after
29-
"test" describes what to test. Design the flow yourself using the TUI harness tools, following the same patterns as
30-
the predefined flows.
31-
32-
### 2. Setup
21+
- `Run all predefined test flows` → read and execute every flow from `.github/agent-sops/tui-test-flows.md`
22+
- `Run this ad-hoc test flow: <description>` → design and execute a single flow matching the description
3323

34-
- The CLI is installed globally as `agentcore`. Launch TUI sessions using `tui_launch` with `command: "agentcore"` and
35-
the appropriate `args`.
36-
- For non-interactive commands (e.g., `--json` output), prefer `shell` over `tui_launch`.
24+
## General Rules
3725

38-
### 3. Run Test Flows
39-
40-
For each flow:
41-
42-
1. Create any required setup (e.g., temp directories, minimal projects) using `shell`
43-
2. Use `tui_launch` to start the CLI with the specified arguments and `cwd`
44-
3. Follow the flow steps: use `tui_action` (preferred — combines send + wait + read in one call) or `tui_wait_for` +
45-
`tui_send_keys` for multi-step interactions
46-
4. Verify each expectation against the screen content
47-
5. Take a screenshot — see Screenshot Rules below
48-
6. On **failure**: also read the screen text for the PR comment body. Record the flow name, expected behavior, actual
49-
behavior, and the screen text.
50-
7. Always `tui_close` the session when done, even on failure
26+
- The CLI is installed globally as `agentcore`
27+
- Use `tui_launch` with `command: "agentcore"` for interactive commands. Use `shell` for non-interactive ones.
28+
- Terminal dimensions: `cols: 100, rows: 24` for all TUI sessions
29+
- Use `timeoutMs: 10000` minimum for all `tui_wait_for` and `tui_action` calls
30+
- If a wait times out, retry once before declaring failure
31+
- Always `tui_close` sessions when done, even on failure
32+
- Run `mkdir -p /tmp/tui-screenshots` via `shell` as your very first action
5133

52-
### Screenshot Rules
34+
## Screenshot Rules
5335

5436
**NEVER save .txt files. ONLY save .svg files.**
5537

56-
Every flow MUST produce exactly one SVG screenshot saved to `/tmp/tui-screenshots/`. Use this exact tool call pattern:
38+
Use this exact tool call pattern for every flow:
5739

5840
```
5941
tui_screenshot(sessionId=<id>, format="svg", savePath="/tmp/tui-screenshots/<flow-name>.svg")
6042
```
6143

62-
- File extension MUST be `.svg`, NEVER `.txt` or `.png`
63-
- The `format` parameter MUST be `"svg"`, NEVER `"text"`
64-
- Take the screenshot WHILE the TUI session is still alive (before the process exits)
65-
- For commands that exit immediately (like `--help`): take the screenshot right after `tui_wait_for` succeeds
66-
- For interactive wizards: take the screenshot at the most interesting step before pressing the final Enter
67-
- If a session has already exited, that flow's screenshot is skipped — do NOT save a text file as a substitute
44+
- `format` MUST be `"svg"`, NEVER `"text"`
45+
- Take the screenshot WHILE the session is still alive (before the process exits)
46+
- If a session has already exited, skip the screenshot — do NOT save a text file as a substitute
6847

69-
**Constraints:**
48+
## Post Results
7049

71-
- Run `mkdir -p /tmp/tui-screenshots` via `shell` as your very first action
72-
- Use `timeoutMs: 10000` (10 seconds) minimum for all `tui_wait_for` and `tui_action` pattern waits
73-
74-
### 3. Post Results
75-
76-
Post a single summary comment on the PR with this format:
50+
Post a single PR comment:
7751

7852
```markdown
7953
## 🧪 TUI Test Results
@@ -89,15 +63,12 @@ Post a single summary comment on the PR with this format:
8963

9064
#### Flow name 3
9165

92-
**Expected:** description of what should have happened **Actual:** description of what happened
66+
**Expected:** what should have happened **Actual:** what happened
9367

9468
<details>
9569
<summary>Screenshot</summary>
96-
```
97-
98-
(terminal screenshot here)
9970

100-
```
71+
(paste screen text here)
10172

10273
</details>
10374
```
@@ -106,9 +77,8 @@ If all flows pass, omit the Failed section.
10677

10778
## Forbidden Actions
10879

109-
- You MUST NOT modify, create, or delete any source files
110-
- You MUST NOT run git add, git commit, or git push
111-
- You MUST NOT create or update branches
112-
- You MUST NOT approve or merge the pull request
113-
- You MUST NOT run deploy, invoke, or any command that creates AWS resources
114-
- Your ONLY output is test result comments on the pull request
80+
- Do NOT modify, create, or delete source files
81+
- Do NOT run git commands (add, commit, push)
82+
- Do NOT create or update branches
83+
- Do NOT approve or merge the pull request
84+
- Do NOT deploy or create AWS resources
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,27 @@
11
# TUI Test Flows
22

3-
Each flow describes a user interaction to verify. The tester agent drives these using the TUI harness MCP tools.
4-
5-
All flows use `tui_launch` with `command: "agentcore"` and the appropriate `args`. Use `cols: 100, rows: 24`.
6-
7-
**Important screenshot rule:** Take the SVG screenshot BEFORE the process exits. For commands that exit immediately
8-
(like `--help`), use `tui_wait_for` to wait for expected content, then immediately take the screenshot while the session
9-
is still alive. For interactive wizards, take the screenshot at the most interesting step (e.g. the final confirmation
10-
screen) before pressing the last Enter.
11-
123
---
134

145
## Flow: Help text lists all commands
156

167
1. Launch: `agentcore --help`
17-
2. Use `tui_wait_for` to wait for "Usage:" on screen
18-
3. Immediately take SVG screenshot (the session may still be alive briefly after output)
19-
4. Read the screen content
20-
5. Expect all of these commands visible: `create`, `deploy`, `invoke`, `status`, `add`, `remove`, `dev`, `logs`
21-
6. Close session
8+
2. Wait for "Usage:" on screen
9+
3. Take SVG screenshot immediately (before the process exits)
10+
4. Verify these commands are visible: `create`, `deploy`, `invoke`, `status`, `add`, `remove`, `dev`, `logs`
11+
5. Close session
2212

2313
---
2414

2515
## Flow: Create project with agent via TUI wizard
2616

27-
This flow drives the full interactive create wizard — no `--json` flags.
28-
2917
1. Create a temp directory via `shell`: `mktemp -d`
3018
2. Launch: `agentcore create` with `cwd` set to the temp directory
31-
3. Wait for: "Project name" prompt
32-
4. Type a project name (e.g. `TuiTest`), press Enter
33-
5. Wait for: "Would you like to add an agent" selection
34-
6. Expect: "Yes, add an agent" is visible
35-
7. Press Enter to select "Yes, add an agent"
36-
8. Wait for: "Agent name" prompt inside the Add Agent wizard
37-
9. Accept the default name, press Enter
38-
10. Wait for: "Select agent type" — expect "Create new agent" visible
39-
11. Press Enter to select it
40-
12. Wait for: "Language" step with "Python" visible
41-
13. Press Enter to select Python
42-
14. Continue pressing Enter through remaining steps (Build, Protocol, Framework, Model) accepting defaults
43-
15. When you reach the "Confirm" step, take the SVG screenshot BEFORE pressing the final Enter
44-
16. Press Enter to confirm
45-
17. Wait for the process to exit or a success message
46-
18. Close session
19+
3. Wait for "Project name" prompt, type `TuiTest`, press Enter
20+
4. Wait for "Would you like to add an agent" — expect "Yes, add an agent" visible, press Enter
21+
5. Wait for "Agent name" prompt, accept the default, press Enter
22+
6. Wait for "Select agent type" — expect "Create new agent" visible, press Enter
23+
7. Wait for "Language" step — expect "Python" visible, press Enter
24+
8. Continue pressing Enter through remaining steps (Build, Protocol, Framework, Model) accepting defaults
25+
9. At the "Confirm" step, take SVG screenshot, then press Enter
26+
10. Wait for the process to exit or a success message
27+
11. Close session

.github/scripts/javascript/process-inputs.cjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,11 @@ module.exports = async (context, github, core, inputs) => {
108108
const { issueId, command, issue } = await getIssueInfo(github, context, inputs);
109109

110110
const isPullRequest = !!issue.data.pull_request;
111-
const mode = command.startsWith('test')
112-
? 'tester'
113-
: command.startsWith('review')
114-
? 'reviewer'
115-
: isPullRequest || command.startsWith('implement')
116-
? 'implementer'
117-
: 'refiner';
111+
112+
const COMMAND_MODES = { test: 'tester', review: 'reviewer', implement: 'implementer' };
113+
const mode =
114+
Object.entries(COMMAND_MODES).find(([prefix]) => command.startsWith(prefix))?.[1] ??
115+
(isPullRequest ? 'implementer' : 'refiner');
118116
console.log(`Is PR: ${isPullRequest}, Mode: ${mode}`);
119117

120118
const branchName = await determineBranch(github, context, issueId, mode, isPullRequest);

0 commit comments

Comments
 (0)