greenrun-cli 0.2.14 → 0.2.15

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.
package/README.md CHANGED
@@ -77,6 +77,7 @@ Detect which tests are impacted by recent git changes and offer to run them.
77
77
  | `create_test` | Create a test (with credential_name, tags, pages) |
78
78
  | `update_test` | Update test (auto-invalidates script on content change) |
79
79
  | `prepare_test_batch` | Fetch, filter, and start runs for a batch of tests |
80
+ | `export_test_script` | Write a test's cached Playwright script to a local file (keeps scripts out of context) |
80
81
  | `sweep` | Find tests affected by specific pages |
81
82
  | `start_run` | Start a test run |
82
83
  | `complete_run` | Record test result |
package/dist/server.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { z } from 'zod';
4
+ import { writeFileSync, mkdirSync } from 'node:fs';
5
+ import { dirname } from 'node:path';
4
6
  import { ApiClient } from './api-client.js';
5
7
  export async function startServer() {
6
8
  const GREENRUN_API_URL = process.env.GREENRUN_API_URL || 'https://app.greenrun.dev';
@@ -120,6 +122,19 @@ export async function startServer() {
120
122
  const result = await api.updateTest(test_id, data);
121
123
  return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
122
124
  });
125
+ server.tool('export_test_script', 'Fetch a test\'s cached Playwright script and write it directly to a file. The script content is never returned — only a confirmation. Use this to export scripts without consuming context.', {
126
+ test_id: z.string().describe('Test UUID'),
127
+ file_path: z.string().describe('Absolute file path to write the script to (e.g. /tmp/greenrun-tests/{test_id}.spec.ts)'),
128
+ }, async (args) => {
129
+ const result = await api.getTest(args.test_id);
130
+ const script = result.test?.script;
131
+ if (!script) {
132
+ return { content: [{ type: 'text', text: `No script found for test ${args.test_id}` }] };
133
+ }
134
+ mkdirSync(dirname(args.file_path), { recursive: true });
135
+ writeFileSync(args.file_path, script, 'utf-8');
136
+ return { content: [{ type: 'text', text: `Script written to ${args.file_path} (${script.length} chars)` }] };
137
+ });
123
138
  // --- Sweep ---
124
139
  server.tool('sweep', 'Find tests affected by specific pages (impact analysis). Use after making changes to determine which tests to re-run.', {
125
140
  project_id: z.string().describe('Project UUID'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "greenrun-cli",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
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",
@@ -120,22 +120,14 @@ Gather all tests that have scripts (previously scripted + newly generated from S
120
120
 
121
121
  **0. Clean up** — run `rm -rf /tmp/greenrun-tests` via Bash to clear any stale files from a previous run.
122
122
 
123
- **1. Fetch scripts and write test files** — launch one Task agent per scripted test, all in parallel. These are just API calls + file writes so they don't conflict. Also write the Playwright config directly (it's small).
124
-
125
- For each scripted test, launch in parallel:
123
+ **1. Fetch scripts and write test files** — call `export_test_script` for each scripted test (all calls in parallel). This fetches each script from the API and writes it directly to disk without returning the script content, keeping context clean. Also write the Playwright config directly.
126
124
 
125
+ For each scripted test, call in parallel:
127
126
  ```
128
- Task tool with:
129
- - subagent_type: "general-purpose"
130
- - max_turns: 5
131
- - model: "haiku"
132
- - prompt: "Fetch the Playwright script for test {test_id} and write it to a file.
133
- 1. Call `get_test(\"{test_id}\")` to fetch the test
134
- 2. Write the `script` field to `/tmp/greenrun-tests/{test_id}.spec.ts` using the Write tool
135
- 3. Return: \"{test_name} | written\""
127
+ export_test_script(test_id: "{test_id}", file_path: "/tmp/greenrun-tests/{test_id}.spec.ts")
136
128
  ```
137
129
 
138
- While the agents run, write `/tmp/greenrun-tests/playwright.config.ts` directly:
130
+ Then write `/tmp/greenrun-tests/playwright.config.ts` directly:
139
131
 
140
132
  ```ts
141
133
  import { defineConfig } from '@playwright/test';