Skip to content

olaafrossi/FoamPilot / .claude/skills/browse

browse

Flagged

Fast headless browser for QA testing and site dogfooding. Navigate any URL, interact with elements, verify page state, diff before/after actions, take annotated screenshots, check responsive layouts, test forms and uploads, handle dialogs, and assert element states. ~100ms per command. Use when you need to test a feature, verify a deployment, dogfood a user flow, or file a bug with evidence. Use when asked to "open in browser", "test the site", "take a screenshot", or "dogfood this".

FileKindSize
SKILL.mdskill md22.5 KB
SKILL.md.tmplother4.1 KB
scripts/build-node-server.shscript1.9 KB
src/activity.tsscript6.4 KB
src/browser-manager.tsscript33.3 KB
src/buffers.tsscript4.2 KB
src/bun-polyfill.cjsscript2.9 KB
src/cli.tsscript25.0 KB
src/commands.tsscript9.0 KB
src/config.tsscript4.6 KB
src/cookie-import-browser.tsscript22.5 KB
src/cookie-picker-routes.tsscript8.5 KB
src/cookie-picker-ui.tsscript21.6 KB
src/find-browse.tsscript1.7 KB
src/meta-commands.tsscript20.6 KB
src/platform.tsscript634 B
src/read-commands.tsscript13.4 KB
src/server.tsscript47.9 KB
src/sidebar-agent.tsscript10.0 KB
src/sidebar-utils.tsscript629 B
src/snapshot.tsscript15.1 KB
src/url-validation.tsscript3.5 KB
src/write-commands.tsscript14.1 KB
test/activity.test.tsscript4.4 KB
test/adversarial-security.test.tsscript1.2 KB
test/browser-manager-unit.test.tsscript677 B
test/bun-polyfill.test.tsscript2.9 KB
test/commands.test.tsscript76.7 KB
test/compare-board.test.tsscript11.3 KB
test/config.test.tsscript13.0 KB
test/cookie-import-browser.test.tsscript20.8 KB
test/cookie-picker-routes.test.tsscript9.5 KB
test/file-drop.test.tsscript10.0 KB
test/find-browse.test.tsscript2.0 KB
test/findport.test.tsscript6.2 KB
test/fixtures/basic.htmlother914 B
test/fixtures/cursor-interactive.htmlother883 B
test/fixtures/dialog.htmlother603 B
test/fixtures/empty.htmlother43 B
test/fixtures/forms.htmlother1.8 KB
test/fixtures/iframe.htmlother852 B
test/fixtures/network-idle.htmlother974 B
test/fixtures/qa-eval-checkout.htmlother4.2 KB
test/fixtures/qa-eval-spa.htmlother3.2 KB
test/fixtures/qa-eval.htmlother1.7 KB
test/fixtures/responsive.htmlother1.4 KB
test/fixtures/snapshot.htmlother1.5 KB
test/fixtures/spa.htmlother638 B
test/fixtures/states.htmlother567 B
test/fixtures/upload.htmlother849 B
test/gstack-config.test.tsscript5.2 KB
test/gstack-update-check.test.tsscript21.4 KB
test/handoff.test.tsscript8.1 KB
test/path-validation.test.tsscript3.3 KB
test/platform.test.tsscript1.0 KB
test/server-auth.test.tsscript3.0 KB
test/sidebar-agent-roundtrip.test.tsscript7.5 KB
test/sidebar-agent.test.tsscript6.8 KB
test/sidebar-integration.test.tsscript9.8 KB
test/sidebar-security.test.tsscript4.2 KB
test/sidebar-unit.test.tsscript3.3 KB
test/snapshot.test.tsscript19.7 KB
test/state-ttl.test.tsscript1.3 KB
test/test-server.tsscript1.7 KB
test/url-validation.test.tsscript2.8 KB
test/watch.test.tsscript4.0 KB

src/activity.ts

View on GitHub
/**
 * Activity streaming — real-time feed of browse commands for the Chrome extension Side Panel
 *
 * Architecture:
 *   handleCommand() ──► emitActivity(command_start)
 *                   ──► emitActivity(command_end)
 *   wirePageEvents() ──► emitActivity(navigation)
 *
 *   GET /activity/stream?after=ID ──► SSE via ReadableStream
 *   GET /activity/history?limit=N ──► REST fallback
 *
 * Privacy: filterArgs() redacts passwords, auth tokens, and sensitive query params.
 * Backpressure: subscribers notified via queueMicrotask (never blocks command path).
 * Gap detection: client sends ?after=ID, server detects if ring buffer overflowed.
 */

import { CircularBuffer } from './buffers';

// ─── Types ──────────────────────────────────────────────────────

export interface ActivityEntry {
  id: number;
  timestamp: number;
  type: 'command_start' | 'command_end' | 'navigation' | 'error';
  command?: string;
  args?: string[];
  url?: string;
  duration?: number;
  status?: 'ok' | 'error';
  error?: string;
  result?: string;
  tabs?: number;
  mode?: string;
}

// ─── Buffer & Subscribers ───────────────────────────────────────

const BUFFER_CAPACITY = 1000;
const activityBuffer = new CircularBuffer<ActivityEntry>(BUFFER_CAPACITY);
let nextId = 1;

type ActivitySubscriber = (entry: ActivityEntry) => void;
const subscribers = new Set<ActivitySubscriber>();

// ─── Privacy Filtering ─────────────────────────────────────────

const SENSITIVE_COMMANDS = new Set(['fill', 'type', 'cookie', 'header']);
const SENSITIVE_PARAM_PATTERN = /\b(password|token|secret|key|auth|bearer|api[_-]?key)\b/i;

/**
 * Redact sensitive data from command args before streaming.
 */
export function filterArgs(command: string, args: string[]): string[] {
  if (!args || args.length === 0) return args;

  // fill: redact the value (last arg) for password-type fields
  if (command === 'fill' && args.length >= 2) {
    const selector = args[0];
    // If the selector suggests a password field, redact the value
    if (/password|passwd|secret|token/i.test(selector)) {
      return [selector, '[REDACTED]'];
    }
    return args;
  }

  // header: redact Authorization and other sensitive headers
  if (command === 'header' && args.length >= 1) {
    const headerLine = args[0];
    if (/^(authorization|x-api-key|cookie|set-cookie)/i.test(headerLine)) {
      const colonIdx = headerLine.indexOf(':');
      if (colonIdx > 0) {
        return [headerLine.substring(0, colonIdx + 1) + '[REDACTED]'];
      }
    }
    return args;
  }

  // cookie: redact cookie values
  if (command === 'cookie' && args.length >= 1) {
    const cookieStr = args[0];
    const eqIdx = cookieStr.indexOf('=');
    if (eqIdx > 0) {
      return [cookieStr.substring(0, eqIdx + 1) + '[REDACTED]'];
    }
    return args;
  }

  // type: always redact (could be a password field)
  if (command === 'type') {
    return ['[REDACTED]'];
  }

  // URL args: redact sensitive query params
  return args.map(arg => {
    if (arg.startsWith('http://') || arg.startsWith('https://')) {
      try {
        const url = new URL(arg);
        let redacted = false;
        for (const key of url.searchParams.keys()) {
          if (SENSITIVE_PARAM_PATTERN.test(key)) {
            url.searchParams.set(key, '[REDACTED]');
            redacted = true;
          }
        }
        return redacted ? url.toString() : arg;
      } catch {
        return arg;
      }
    }
    return arg;
  });
}

/**
 * Truncate result text for streaming (max 200 chars).
 */
function truncateResult(result: string | undefined): string | undefined {
  if (!result) return undefined;
  if (result.length <= 200) return result;
  return result.substring(0, 200) + '...';
}

// ─── Public API ─────────────────────────────────────────────────

/**
 * Emit an activity event. Backpressure-safe: subscribers notified asynchronously.
 */
export function emitActivity(entry: Omit<ActivityEntry, 'id' | 'timestamp'>): ActivityEntry {
  const full: ActivityEntry = {
    ...entry,
    id: nextId++,
    timestamp: Date.now(),
    args: entry.args ? filterArgs(entry.command || '', entry.args) : undefined,
    result: truncateResult(entry.result),
  };
  activityBuffer.push(full);

  // Notify subscribers asynchronously — never block the command path
  for (const notify of subscribers) {
    queueMicrotask(() => {
      try { notify(full); } catch { /* subscriber error — don't crash */ }
    });
  }

  return full;
}

/**
 * Subscribe to live activity events. Returns unsubscribe function.
 */
export function subscribe(fn: ActivitySubscriber): () => void {
  subscribers.add(fn);
  return () => subscribers.delete(fn);
}

/**
 * Get recent activity entries after the given cursor ID.
 * Returns entries and gap info if the buffer has overflowed.
 */
export function getActivityAfter(afterId: number): {
  entries: ActivityEntry[];
  gap: boolean;
  gapFrom?: number;
  availableFrom?: number;
  totalAdded: number;
} {
  const total = activityBuffer.totalAdded;
  const allEntries = activityBuffer.toArray();

  if (afterId === 0) {
    return { entries: allEntries, gap: false, totalAdded: total };
  }

  // Check for gap: if afterId is too old and has been evicted
  const oldestId = allEntries.length > 0 ? allEntries[0].id : nextId;
  if (afterId < oldestId) {
    return {
      entries: allEntries,
      gap: true,
      gapFrom: afterId + 1,
      availableFrom: oldestId,
      totalAdded: total,
    };
  }

  // Filter to entries after the cursor
  const filtered = allEntries.filter(e => e.id > afterId);
  return { entries: filtered, gap: false, totalAdded: total };
}

/**
 * Get the N most recent activity entries.
 */
export function getActivityHistory(limit: number = 50): {
  entries: ActivityEntry[];
  totalAdded: number;
} {
  const allEntries = activityBuffer.toArray();
  const sliced = limit < allEntries.length ? allEntries.slice(-limit) : allEntries;
  return { entries: sliced, totalAdded: activityBuffer.totalAdded };
}

/**
 * Get subscriber count (for debugging/health).
 */
export function getSubscriberCount(): number {
  return subscribers.size;
}
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall