mxyhi/ok-skills / browser-trace
browser-trace
VerifiedCapture a full DevTools-protocol trace of any browser automation — CDP firehose, screenshots, and DOM dumps — then bisect the stream into per-page searchable buckets. Use when the user wants to debug a failed run, audit network/console/DOM activity, attach a trace to an in-progress session, or feed structured per-page summaries back into an agent loop so its next iteration learns from the last one.
| File | Kind | Size |
|---|---|---|
| EXAMPLES.md | markdown | 8.4 KB |
| LICENSE.txt | markdown | 1.0 KB |
| REFERENCE.md | markdown | 20.1 KB |
| SKILL.md | skill md | 14.7 KB |
| package.json | manifest | 91 B |
| scripts/bb-capture.mjsexecutable | script | 3.7 KB |
| scripts/bb-finalize.mjsexecutable | script | 3.2 KB |
| scripts/bisect-cdp.mjsexecutable | script | 7.6 KB |
| scripts/lib.mjsexecutable | script | 4.2 KB |
| scripts/query.mjsexecutable | script | 8.6 KB |
| scripts/snapshot-loop.mjsexecutable | script | 2.6 KB |
| scripts/start-capture.mjsexecutable | script | 2.9 KB |
| scripts/stop-capture.mjsexecutable | script | 1.5 KB |
scripts/start-capture.mjs
View on GitHub#!/usr/bin/env node
// Start an observability capture against a CDP target.
//
// Usage:
// node scripts/start-capture.mjs <port|ws-url> [run-id] [interval-seconds]
//
// Env:
// O11Y_ROOT base directory for runs (default: .o11y)
// O11Y_DOMAINS space-separated CDP domains (default: "Network Console Runtime Log Page")
import fs from 'node:fs';
import path from 'node:path';
import { spawn } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import {
runDir, ensureDir, isoUtcSeconds, isAlive, sleepMs, writeJson,
} from './lib.mjs';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const [target, runIdArg, intervalArg] = process.argv.slice(2);
if (!target) {
console.error('usage: start-capture.mjs <port|ws-url> [run-id] [interval-seconds]');
process.exit(2);
}
const runId = runIdArg || isoUtcSeconds().replace(/[-:]/g, '');
const interval = Number(intervalArg) || 2;
const domainsList = (process.env.O11Y_DOMAINS || 'Network Console Runtime Log Page').trim().split(/\s+/);
const domainArgs = domainsList.flatMap(d => ['--domain', d]);
const RD = runDir(runId);
ensureDir(path.join(RD, 'cdp'));
ensureDir(path.join(RD, 'screenshots'));
ensureDir(path.join(RD, 'dom'));
writeJson(path.join(RD, 'manifest.json'), {
run_id: runId,
target,
domains: domainsList.join(' '),
interval_seconds: interval,
started_at: isoUtcSeconds(),
});
// Spawn the CDP firehose in the background. Detach + unref so it survives this
// process exiting. browse cdp writes one JSON object per line to stdout.
const rawFd = fs.openSync(path.join(RD, 'cdp', 'raw.ndjson'), 'w');
const errFd = fs.openSync(path.join(RD, 'cdp', 'stderr.log'), 'w');
const cdp = spawn('browse', ['cdp', target, ...domainArgs], {
detached: true,
stdio: ['ignore', rawFd, errFd],
});
cdp.unref();
fs.writeFileSync(path.join(RD, '.cdp.pid'), String(cdp.pid));
// Spawn the periodic screenshot/DOM/url sampler (separate process so it can
// be SIGTERM'd independently from the CDP stream).
const loopFd = fs.openSync(path.join(RD, 'snapshot-loop.log'), 'w');
const loopScript = path.join(__dirname, 'snapshot-loop.mjs');
const loop = spawn(process.execPath, [loopScript, target, RD, String(interval)], {
detached: true,
stdio: ['ignore', loopFd, loopFd],
});
loop.unref();
fs.writeFileSync(path.join(RD, '.loop.pid'), String(loop.pid));
// Give browse cdp a beat to fail loudly on bad targets so the user sees the
// real error instead of a silent zero-event capture.
await sleepMs(1000);
if (!isAlive(cdp.pid)) {
console.error(`browse cdp exited immediately — check ${RD}/cdp/stderr.log`);
try { console.error(fs.readFileSync(path.join(RD, 'cdp', 'stderr.log'), 'utf8')); } catch {}
try { process.kill(loop.pid); } catch {}
process.exit(1);
}
console.log(`run_id=${runId}`);
console.log(`run_dir=${RD}`);
console.log(`target=${target}`);
console.log(`cdp_pid=${cdp.pid}`);
console.log(`loop_pid=${loop.pid}`);
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |