diff --git a/AGENTS.md b/AGENTS.md index d40348e..76b5ade 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -271,7 +271,7 @@ you can find the logfile for playwriter executing `playwriter logfile`. read tha `playwriter logfile` also logs a jsonl file with all CDP commands and events being sent between extension, cli, mcp and relay. the cdp log is a jsonl file (one json object per line). you can use jq to process and read it efficiently. for example, list direction + method: ```bash -jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c +jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c ``` ## testing iframe behaviour with snapshots and out of process frames diff --git a/PLAYWRITER_AGENTS.md b/PLAYWRITER_AGENTS.md index 1af8a75..b3ae240 100644 --- a/PLAYWRITER_AGENTS.md +++ b/PLAYWRITER_AGENTS.md @@ -269,7 +269,7 @@ you can find the logfile for playwriter executing `playwriter logfile`. read tha `playwriter logfile` also logs a jsonl file with all CDP commands and events being sent between extension, cli, mcp and relay. the cdp log is a jsonl file (one json object per line). you can use jq to process and read it efficiently. for example, list direction + method: ```bash -jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c +jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c ``` ## testing iframe behaviour with snapshots and out of process frames diff --git a/README.md b/README.md index 57b22d6..167fd65 100644 --- a/README.md +++ b/README.md @@ -244,7 +244,7 @@ View relay server logs to debug issues: ```bash playwriter logfile # prints the log file path -# typically: /tmp/playwriter/relay-server.log (Linux/macOS) +# typically: ~/.playwriter/relay-server.log ``` The relay log contains extension, MCP and WebSocket server logs. A separate CDP JSONL log is also created alongside it (see `playwriter logfile`). Both are recreated on each server start. @@ -252,7 +252,7 @@ The relay log contains extension, MCP and WebSocket server logs. A separate CDP Example: summarize CDP traffic counts by direction + method: ```bash -jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c +jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c ``` ## Known Issues diff --git a/playwriter/CHANGELOG.md b/playwriter/CHANGELOG.md index b533b18..f1480bd 100644 --- a/playwriter/CHANGELOG.md +++ b/playwriter/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.0.57 + +### Bug Fixes + +- **Fix log dir permissions on shared machines**: Move default log directory from `/tmp/playwriter` to `~/.playwriter` so each OS user gets their own directory. Fixes startup crash when `/tmp/playwriter` is owned by another user (#44). + ## 0.0.56 ### Bug Fixes diff --git a/playwriter/src/skill.md b/playwriter/src/skill.md index 1e7ec60..f39d639 100644 --- a/playwriter/src/skill.md +++ b/playwriter/src/skill.md @@ -96,11 +96,11 @@ EOF ### Debugging playwriter issues -If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the system temp directory: +If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the user home directory: ```bash playwriter logfile # prints the log file path -# typically: /tmp/playwriter/relay-server.log (Linux/macOS) or %TEMP%\playwriter\relay-server.log (Windows) +# typically: ~/.playwriter/relay-server.log ``` The relay log contains logs from the extension, MCP and WS server. A separate CDP JSONL log is created alongside it (see `playwriter logfile`) with all CDP commands/responses and events, with long strings truncated. Both files are recreated every time the server starts. For debugging internal playwriter errors, read these files with grep/rg to find relevant lines. @@ -108,7 +108,7 @@ The relay log contains logs from the extension, MCP and WS server. A separate CD Example: summarize CDP traffic counts by direction + method: ```bash -jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c +jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c ``` If you find a bug, you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. Ask for user confirmation before doing this. diff --git a/playwriter/src/utils.ts b/playwriter/src/utils.ts index a3d697f..bcee752 100644 --- a/playwriter/src/utils.ts +++ b/playwriter/src/utils.ts @@ -33,8 +33,9 @@ export function getCdpUrl({ return `ws://${host}:${port}/cdp/${id}${suffix}` } -const LOG_BASE_DIR = os.platform() === 'win32' ? os.tmpdir() : '/tmp' -export const LOG_FILE_PATH = process.env.PLAYWRITER_LOG_FILE_PATH || path.join(LOG_BASE_DIR, 'playwriter', 'relay-server.log') +// Use ~/.playwriter for logs so each OS user gets their own dir (avoids permission errors on shared machines, see #44) +const LOG_BASE_DIR = path.join(os.homedir(), '.playwriter') +export const LOG_FILE_PATH = process.env.PLAYWRITER_LOG_FILE_PATH || path.join(LOG_BASE_DIR, 'relay-server.log') export const LOG_CDP_FILE_PATH = process.env.PLAYWRITER_CDP_LOG_FILE_PATH || path.join(path.dirname(LOG_FILE_PATH), 'cdp.jsonl') const packageJsonPath = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', 'package.json') diff --git a/website/public/SKILL.md b/website/public/SKILL.md index 7e51b50..f39d639 100644 --- a/website/public/SKILL.md +++ b/website/public/SKILL.md @@ -70,6 +70,10 @@ playwriter -s 1 -e "await page.screenshot({ path: 'screenshot.png', scale: 'css' # Get accessibility snapshot playwriter -s 1 -e "await accessibilitySnapshot({ page })" + +# Get accessibility snapshot for a specific iframe +const frame = await page.locator('iframe').contentFrame() +await accessibilitySnapshot({ frame }) ``` **Multiline code:** @@ -92,11 +96,11 @@ EOF ### Debugging playwriter issues -If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the system temp directory: +If some internal critical error happens you can read the relay server logs to understand the issue. The log file is located in the user home directory: ```bash playwriter logfile # prints the log file path -# typically: /tmp/playwriter/relay-server.log (Linux/macOS) or %TEMP%\playwriter\relay-server.log (Windows) +# typically: ~/.playwriter/relay-server.log ``` The relay log contains logs from the extension, MCP and WS server. A separate CDP JSONL log is created alongside it (see `playwriter logfile`) with all CDP commands/responses and events, with long strings truncated. Both files are recreated every time the server starts. For debugging internal playwriter errors, read these files with grep/rg to find relevant lines. @@ -104,7 +108,7 @@ The relay log contains logs from the extension, MCP and WS server. A separate CD Example: summarize CDP traffic counts by direction + method: ```bash -jq -r '.direction + "\t" + (.message.method // "response")' /tmp/playwriter/cdp.jsonl | uniq -c +jq -r '.direction + "\t" + (.message.method // "response")' ~/.playwriter/cdp.jsonl | uniq -c ``` If you find a bug, you can create a gh issue using `gh issue create -R remorses/playwriter --title title --body body`. Ask for user confirmation before doing this. @@ -113,7 +117,7 @@ If you find a bug, you can create a gh issue using `gh issue create -R remorses/ # playwriter best practices -Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. If you get "extension is not connected" or "no browser tabs have Playwriter enabled" error, tell user to click the playwriter extension icon on the tab they want to control. +Control user's Chrome browser via playwright code snippets. Prefer single-line code with semicolons between statements. Use playwriter immediately without waiting for user actions; only if you get "extension is not connected" or "no browser tabs have Playwriter enabled" should you ask the user to click the playwriter extension icon on the target tab. You can collaborate with the user - they can help with captchas, difficult elements, or reproducing bugs.