greenrun-cli 0.1.4 → 0.1.6

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.
@@ -138,10 +138,60 @@ function installClaudeMd() {
138
138
  console.log(' Created CLAUDE.md with Greenrun instructions');
139
139
  }
140
140
  }
141
+ function installSettings() {
142
+ const settingsDir = join(process.cwd(), '.claude');
143
+ mkdirSync(settingsDir, { recursive: true });
144
+ const settingsPath = join(settingsDir, 'settings.local.json');
145
+ let existing = {};
146
+ if (existsSync(settingsPath)) {
147
+ try {
148
+ existing = JSON.parse(readFileSync(settingsPath, 'utf-8'));
149
+ }
150
+ catch {
151
+ // overwrite invalid JSON
152
+ }
153
+ }
154
+ const greenrunTools = [
155
+ 'mcp__greenrun__list_projects',
156
+ 'mcp__greenrun__get_project',
157
+ 'mcp__greenrun__create_project',
158
+ 'mcp__greenrun__list_pages',
159
+ 'mcp__greenrun__create_page',
160
+ 'mcp__greenrun__list_tests',
161
+ 'mcp__greenrun__get_test',
162
+ 'mcp__greenrun__create_test',
163
+ 'mcp__greenrun__update_test',
164
+ 'mcp__greenrun__start_run',
165
+ 'mcp__greenrun__complete_run',
166
+ 'mcp__greenrun__get_run',
167
+ 'mcp__greenrun__list_runs',
168
+ 'mcp__greenrun__sweep',
169
+ ];
170
+ const browserTools = [
171
+ 'mcp__claude-in-chrome__tabs_context_mcp',
172
+ 'mcp__claude-in-chrome__tabs_create_mcp',
173
+ 'mcp__claude-in-chrome__navigate',
174
+ 'mcp__claude-in-chrome__computer',
175
+ 'mcp__claude-in-chrome__read_page',
176
+ 'mcp__claude-in-chrome__find',
177
+ 'mcp__claude-in-chrome__form_input',
178
+ 'mcp__claude-in-chrome__javascript_tool',
179
+ 'mcp__claude-in-chrome__get_page_text',
180
+ 'mcp__claude-in-chrome__read_console_messages',
181
+ 'mcp__claude-in-chrome__read_network_requests',
182
+ ];
183
+ const requiredTools = [...greenrunTools, ...browserTools];
184
+ existing.permissions = existing.permissions || {};
185
+ const currentAllow = existing.permissions.allow || [];
186
+ const merged = [...new Set([...currentAllow, ...requiredTools])];
187
+ existing.permissions.allow = merged;
188
+ writeFileSync(settingsPath, JSON.stringify(existing, null, 2) + '\n');
189
+ console.log(' Updated .claude/settings.local.json with tool permissions');
190
+ }
141
191
  function installCommands() {
142
192
  const commandsDir = join(process.cwd(), '.claude', 'commands');
143
193
  mkdirSync(commandsDir, { recursive: true });
144
- const commands = ['greenrun.md', 'greenrun-sweep.md'];
194
+ const commands = ['greenrun.md', 'greenrun-sweep.md', 'procedures.md'];
145
195
  for (const cmd of commands) {
146
196
  const src = join(TEMPLATES_DIR, 'commands', cmd);
147
197
  if (!existsSync(src)) {
@@ -156,6 +206,7 @@ function installCommands() {
156
206
  export function runUpdate() {
157
207
  console.log('\nGreenrun - Updating templates\n');
158
208
  installCommands();
209
+ installSettings();
159
210
  installClaudeMd();
160
211
  console.log('\nDone! Templates updated to latest version.\n');
161
212
  }
@@ -247,6 +298,7 @@ export async function runInit(args) {
247
298
  if (opts.commands) {
248
299
  installCommands();
249
300
  }
301
+ installSettings();
250
302
  console.log(`
251
303
  Done! Restart Claude Code to connect.
252
304
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greenrun-cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "CLI and MCP server for Greenrun - browser test management for Claude Code",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",
@@ -36,41 +36,4 @@ Present the affected tests:
36
36
 
37
37
  ### 6. Offer to run
38
38
 
39
- Ask the user if they want to run the affected tests. If yes, execute them **in parallel** using the same approach as the `/greenrun` command:
40
-
41
- Use the project's `concurrency` setting (default: 5) to determine batch size. Split affected tests into batches and launch each batch simultaneously using the **Task tool** with `run_in_background: true`.
42
-
43
- For each test in a batch, launch a background agent with `max_turns: 30` and `model: "sonnet"`. Use this prompt:
44
-
45
- ```
46
- You are executing a single Greenrun browser test. You have access to browser automation tools and Greenrun MCP tools.
47
-
48
- **Test: {test_name}** (ID: {test_id})
49
-
50
- Step 1: Call `get_test` with test_id "{test_id}" to get full instructions.
51
- Step 2: Call `start_run` with test_id "{test_id}" to begin - save the returned `run_id`.
52
- Step 3: Execute the test instructions using browser automation:
53
- - Call `tabs_context_mcp` then create a new browser tab for this test
54
- - Follow each instruction step exactly as written
55
- - The instructions will tell you where to navigate and what to do
56
- - Only take a screenshot when you need to verify a visual assertion — not for every navigation or click
57
- - When reading page content, prefer `find` or `read_page` with `filter: "interactive"` over full DOM reads
58
- - NEVER trigger JavaScript alerts, confirms, or prompts — they block the browser extension entirely. Before clicking delete buttons or other destructive actions, use `javascript_tool` to override: `window.alert = () => {}; window.confirm = () => true; window.prompt = () => null;`
59
- - If browser tools stop responding (no result or timeout), assume a dialog is blocking — report the error and stop. Do not keep retrying.
60
- - If you get stuck or a step fails, record the failure and move on — do not retry more than once
61
- Step 4: Call `complete_run` with:
62
- - run_id: the run ID from step 2
63
- - status: "passed" if all checks succeeded, "failed" if any check failed, "error" if execution was blocked
64
- - result: a brief summary of what happened (include the failure reason if failed/error)
65
- Step 5: Close the browser tab you created to clean up.
66
-
67
- Return a single line summary: {test_name} | {status} | {result_summary}
68
- ```
69
-
70
- Wait for each batch to complete before launching the next. After all tests finish, present a summary table:
71
-
72
- | Test | Pages | Tags | Status | Result |
73
- |------|-------|------|--------|--------|
74
- | Test name | Affected page URLs | tag1, tag2 | passed/failed/error | Brief summary |
75
-
76
- Include the total count: "X passed, Y failed, Z errors out of N tests"
39
+ Ask the user if they want to run the affected tests. If yes, read `.claude/commands/procedures.md` for the agent prompt template and execution procedures. Follow those procedures to pre-fetch test details, launch agents in batches, collect results, and summarize.
@@ -23,58 +23,6 @@ If no argument is given, run all active tests.
23
23
 
24
24
  If there are no matching active tests, tell the user and stop.
25
25
 
26
- ### 3. Execute tests in parallel
26
+ ### 3. Execute tests
27
27
 
28
- Split the test list into batches of size `concurrency` (from the project settings).
29
-
30
- For each batch, launch all tests simultaneously using the **Task tool** with `run_in_background: true`. Each background agent receives a prompt containing everything it needs to execute one test independently:
31
-
32
- ```
33
- For each test in the current batch, call the Task tool with:
34
- - subagent_type: "general-purpose"
35
- - run_in_background: true
36
- - max_turns: 30
37
- - model: "sonnet"
38
- - prompt: (see below)
39
- ```
40
-
41
- The prompt for each background agent should be:
42
-
43
- ```
44
- You are executing a single Greenrun browser test. You have access to browser automation tools and Greenrun MCP tools.
45
-
46
- **Test: {test_name}** (ID: {test_id})
47
-
48
- Step 1: Call `get_test` with test_id "{test_id}" to get full instructions.
49
- Step 2: Call `start_run` with test_id "{test_id}" to begin - save the returned `run_id`.
50
- Step 3: Execute the test instructions using browser automation:
51
- - Call `tabs_context_mcp` then create a new browser tab for this test
52
- - Follow each instruction step exactly as written
53
- - The instructions will tell you where to navigate and what to do
54
- - Only take a screenshot when you need to verify a visual assertion — not for every navigation or click
55
- - When reading page content, prefer `find` or `read_page` with `filter: "interactive"` over full DOM reads
56
- - NEVER trigger JavaScript alerts, confirms, or prompts — they block the browser extension entirely. Before clicking delete buttons or other destructive actions, use `javascript_tool` to override: `window.alert = () => {}; window.confirm = () => true; window.prompt = () => null;`
57
- - If browser tools stop responding (no result or timeout), assume a dialog is blocking — report the error and stop. Do not keep retrying.
58
- - If you get stuck or a step fails, record the failure and move on — do not retry more than once
59
- Step 4: Call `complete_run` with:
60
- - run_id: the run ID from step 2
61
- - status: "passed" if all checks succeeded, "failed" if any check failed, "error" if execution was blocked
62
- - result: a brief summary of what happened (include the failure reason if failed/error)
63
- Step 5: Close the browser tab you created to clean up.
64
-
65
- Return a single line summary: {test_name} | {status} | {result_summary}
66
- ```
67
-
68
- After launching all agents in a batch, wait for them all to complete (use `TaskOutput` to collect results) before launching the next batch.
69
-
70
- ### 4. Summarize results
71
-
72
- After all batches complete, collect results from all background agents and present a summary table:
73
-
74
- | Test | Pages | Tags | Status | Result |
75
- |------|-------|------|--------|--------|
76
- | Test name | /login, /dashboard | smoke, auth | passed/failed/error | Brief summary |
77
-
78
- Include the total count: "X passed, Y failed, Z errors out of N tests"
79
-
80
- If any tests failed, highlight what went wrong and suggest next steps.
28
+ Read `.claude/commands/procedures.md` for the agent prompt template and execution procedures. Follow those procedures to pre-fetch test details, launch agents in batches, collect results, and summarize.
@@ -0,0 +1,64 @@
1
+ Shared procedures for executing Greenrun browser tests in parallel. Referenced by `/greenrun` and `/greenrun-sweep`.
2
+
3
+ ## Pre-fetch
4
+
5
+ Before launching agents, call `get_test` for ALL tests **in parallel** to get full instructions. Then call `start_run` for ALL tests **in parallel** to get run IDs.
6
+
7
+ ## Launch agents
8
+
9
+ Split tests into batches of size `concurrency` (from project settings, default: 5).
10
+
11
+ For each batch, launch all tests simultaneously using the **Task tool** with `run_in_background: true`:
12
+
13
+ ```
14
+ For each test in the current batch, call the Task tool with:
15
+ - subagent_type: "general-purpose"
16
+ - run_in_background: true
17
+ - max_turns: 25
18
+ - model: "haiku"
19
+ - prompt: (see agent prompt below)
20
+ ```
21
+
22
+ ### Agent prompt
23
+
24
+ ```
25
+ Execute a Greenrun browser test. Run ID: {run_id}
26
+
27
+ **Test: {test_name}**
28
+
29
+ ## Instructions
30
+ {paste the full test instructions from get_test here}
31
+
32
+ ## Setup
33
+ 1. Call `tabs_context_mcp`, then `tabs_create_mcp` to create YOUR tab. Use ONLY this tabId — other tabs belong to parallel tests.
34
+ 2. Navigate to the first URL. Run `javascript_tool`: `window.location.pathname`. If it returns `/login`, call `complete_run` with status "error", result "Not authenticated", then `window.close()` and stop.
35
+
36
+ ## Execution rules
37
+ - Verify assertions with `screenshot` after actions that change the page. Do NOT use `read_page` for verification.
38
+ - Use `find` to locate elements, then `ref` parameter on `computer` tool or `form_input` to interact.
39
+ - Navigate with absolute URLs via `navigate` — don't click nav links.
40
+ - Before destructive buttons: `window.alert = () => {}; window.confirm = () => true; window.prompt = () => null;`
41
+ - On failure or timeout, retry ONCE then move on. Max 35 tool calls total.
42
+
43
+ ## Finish
44
+ Call `complete_run` with run_id "{run_id}", status ("passed"/"failed"/"error"), and a brief result summary.
45
+ Then run `javascript_tool`: `window.close()`.
46
+
47
+ Return: {test_name} | {status} | {result_summary}
48
+ ```
49
+
50
+ ## Collect results
51
+
52
+ After launching all agents in a batch, wait for them all to complete (use `TaskOutput`) before launching the next batch.
53
+
54
+ ## Summarize
55
+
56
+ After all batches complete, present a summary table:
57
+
58
+ | Test | Pages | Tags | Status | Result |
59
+ |------|-------|------|--------|--------|
60
+ | Test name | /login, /dashboard | smoke, auth | passed/failed/error | Brief summary |
61
+
62
+ Include the total count: "X passed, Y failed, Z errors out of N tests"
63
+
64
+ If any tests failed, highlight what went wrong and suggest next steps.