npx skills add smithery/nicobailon --skill surf-codebase
marcfargas/surf-cli · Archived
surf-codebase
Navigate and modify surf-cli codebase - Chrome extension + native host for AI browser automation. Use for surf-cli code work, architecture questions, implementing browser control/CDP/accessibility/network features.
Installation
npx skills add marcfargas/surf-cli --skill surf-codebase
Stronger alternatives
This repository is archived — consider an actively maintained alternative.
Control Chrome browser via CLI for testing, automation, and debugging. Use when the user needs …
8 installsGiven a change_brief YAML (output from diff-intake), generates an exhaustive list of candidate …
8.9K installsAudit the active repo, MCP servers, plugins, connectors, env surfaces, and harness setup, then …
7K installs>- Your AI agent's crypto brain. One skill, 100+ commands across 14 data domains — real-time pr…
4K installsSimilar popular skills
Related neighbors and high-traction skills in the same topics — useful to compare before installing.
Skill for converting an installed Firebase Extension (or extension source) into a standalone Cl…
30K installsMigration and code evolution instructions generator for GitHub Copilot. Analyzes differences be…
9K installsUse this skill when the user explicitly asks to map, document, or onboard into an existing code…
1.8K installsInspect an application repository connected to PlanetScale and recommend SQLCommenter-compatibl…
13 installsShared vocabulary for designing deep modules. Use when the user wants to design or improve a mo…
575K installsAlso in this package
Other skills from marcfargas/surf-cli.
npx skills add marcfargas/surf-cli
More details
Agent compatibility
Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.
Also listed on
Alternate registries and mirrors of this skill.
Repository health
main
Package contents
Files included with this skill beyond the listing page.
-
skill md
SKILL.md3,735 B -
docs
SUMMARY.md235 B
History
- First seen on skills.sh
- First recorded snapshot · 8 installs
SKILL.md
surf-cli Codebase
Architecture
cli.cjs --socket:/tmp/surf.sock--> host.cjs --native-msg--> service-worker/index.ts --CDP/chrome-APIs--> browser
Add CLI Command
- Add to
TOOLSin native/cli.cjs:158 (args, opts, examples) - Add handler in src/service-worker/index.ts:50
handleMessage()switch - CDP op? → add method src/cdp/controller.ts:60
- DOM interaction? → add handler src/content/accessibility-tree.ts:99
Add CDP Operation
- Add method to
CDPControllerclass src/cdp/controller.ts:60 - Use
this.send(tabId, "Domain.method", params) - Handle events in
handleCDPEvent()if needed
Core Files
src/service-worker/index.ts (~2500L) - Central msg router, CDP ops, screenshot cache, tab registry
- Msg types: EXECUTECLICK, EXECUTETYPE, READPAGE, EXECUTESCREENSHOT
- Screenshot cache: generateScreenshotId(), cacheScreenshot(), getScreenshot()
- Tab names: tabNameRegistry Map<name,tabId>
src/cdp/controller.ts (~1000L) - CDP wrapper, CDPController class
- Mouse: click(), rightClick(), doubleClick(), hover(), drag()
- Keyboard: type(), pressKey(), pressKeyChord()
- Screenshots: captureScreenshot(), captureRegion()
- Network/Console: enableNetworkTracking(), getNetworkRequests(), getResponseBody(), subscribeToNetwork(), enableConsoleTracking(), getConsoleMessages()
- Emulation: emulateNetwork(), emulateCPU(), emulateGeolocation()
src/content/accessibility-tree.ts (~1900L) - Content script, generates a11y tree YAML, element interactions
- Handlers: GENERATEACCESSIBILITYTREE, CLICKELEMENT, FORMINPUT, GETELEMENTCOORDINATES, WAITFORELEMENT, WAITFORURL
- Element refs: e1, e2... in window.__piRefs for stable references
native/cli.cjs (~2100L) - CLI parser, socket client
- TOOLS: command defs with args/opts
- ALIASES: shortcut→command map
- AUTOSCREENSHOTTOOLS: commands that auto-capture
- parseArgs(), sendRequest()
native/host.cjs (~2100L) - Socket server, AI integration
- handleToolRequest(): main dispatcher
- mapToolToMessage(): tool→extension msg converter
- queueAiRequest(): AI request serialization
- AI clients: chatgptClient, geminiClient, perplexityClient
src/native/port-manager.ts - Extension↔native messaging, auto-reconnect, request/response tracking
Message Flow
- CLI:
surf click e5 - cli.cjs parses → socket → host.cjs
- host.cjs routes to EXECUTE_CLICK msg
- Native msg → service-worker/index.ts
- Service worker: CDP (cdp/controller.ts) or content script (chrome.tabs.sendMessage)
- Response flows back to CLI
Debug
- Extension logs: chrome://extensions → Service Worker → Console
- Host logs: /tmp/surf-host.log
- CLI raw output:
--jsonflag
Test
npm run build # Build ext
npm test # Run tests
npm run test:coverage # Coverage
Element Refs
A11y tree assigns e1, e2... during READ_PAGE. Stored window.__piRefs. Reset each read command.
Network Capture
- CDP captures via Network.* events cdp/controller.ts:73
- Storage: /tmp/surf/requests.jsonl
- Formatters: native/formatters/network.cjs:259
Build/Install
npm run dev # Watch mode
npm run build # Prod → dist/
# Load dist/ as unpacked ext
surf install <ext-id> # Register native host
Gotchas
- CDP attach: 100-500ms first time/tab
- chrome:// pages restricted
- Content script needs page refresh on existing tabs
- Screenshots auto-resize 1200px unless --full