Skip to content

docs: simplify agent-browser usage (auto CDP connect)#104

Open
ninyawee wants to merge 6 commits intovercel-labs:mainfrom
ninyawee:docs/simplify-agent-browser-usage
Open

docs: simplify agent-browser usage (auto CDP connect)#104
ninyawee wants to merge 6 commits intovercel-labs:mainfrom
ninyawee:docs/simplify-agent-browser-usage

Conversation

@ninyawee
Copy link
Copy Markdown

@ninyawee ninyawee commented Apr 6, 2026

Summary

Updates AGENTS.md and both SKILL.md files to remove manual --cdp $(d3k cdp-port) boilerplate from all examples.

With #103, d3k agent-browser auto-connects to the session's CDP port before running the user's command. The docs now reflect this:

# Before (5 commands, each with --cdp boilerplate)
CDP_PORT="$(d3k cdp-port)"
d3k agent-browser --cdp "$CDP_PORT" open http://localhost:3000
d3k agent-browser --cdp "$CDP_PORT" snapshot -i
d3k agent-browser --cdp "$CDP_PORT" click @e2

# After (just works)
d3k agent-browser open http://localhost:3000
d3k agent-browser snapshot -i
d3k agent-browser click @e2

Files changed

  • AGENTS.md — remove CDP_PORT variable, simplify browser examples
  • src/skills/d3k/SKILL.md — update Browser Interaction, Fix Workflow, Screenshots sections
  • skills/d3k/SKILL.md — update CDP Browser Control and Examples sections

Depends on #103.

Nutchanon Ninyawee added 6 commits April 6, 2026 15:29
`getLogPath()` always returned the most recently started session's
log file, ignoring which directory the user is in. In a monorepo
with multiple d3k instances running simultaneously, this means
`d3k logs` could show logs from the wrong project.

Now uses `getProjectName()` to match the current directory's session
first, falling back to the most recent session if no match is found.
`d3k agent-browser` currently requires `--cdp $(d3k cdp-port)` on
every invocation because it just forwards args to the binary without
session awareness. Since d3k already tracks the CDP URL in
session.json, auto-inject `--cdp` when the user hasn't provided one.

Also extracts `getSessionCdpPort()` to deduplicate the CDP port
resolution logic between `runLocalBrowserTool` and `cdp-port` command.
Extract duplicated `findActiveSessions()` from 5 command files into
a shared `utils/session.ts` with `findCurrentSession()` that uses
`getProjectName()` to prefer the session matching the current
working directory.

Commands fixed:
- `d3k errors` — was showing wrong project's errors
- `d3k fix` — was analyzing wrong project's logs
- `d3k crawl` — was crawling wrong project's app URL
- `d3k find-component` — was using wrong project's CDP

Also removes hardcoded `--cdp 9222` from crawl and find-component
(now handled by the auto-inject in cli.ts from the previous PR).

Net: -312 lines added, +107 lines removed (205 lines deleted).
agent-browser's `--cdp <port>` flag is broken (always falls back to
9222). The working approach is `agent-browser connect <port>` which
establishes a persistent daemon connection.

Change auto-inject from prepending `--cdp <port>` to running
`connect <port>` before the user's command. Update AGENTS.md and
both SKILL.md files to reflect the simplified usage.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 6, 2026

Someone is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant