Add browse cookies commands for cookie management#1908
Open
derekmeegan wants to merge 3 commits intomainfrom
Open
Add browse cookies commands for cookie management#1908derekmeegan wants to merge 3 commits intomainfrom
browse cookies commands for cookie management#1908derekmeegan wants to merge 3 commits intomainfrom
Conversation
Adds cookies get/set/clear subcommands using Understudy's existing context.cookies(), addCookies(), and clearCookies() methods. Usage: browse cookies get # all cookies browse cookies get https://example.com # filtered by URL browse cookies set '[{"name":"a","value":"b","url":"https://..."}]' browse cookies clear # clear all browse cookies clear --domain example.com # filtered clear Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 1ac94ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Confidence score: 3/5
- There is a concrete regression risk in
packages/cli/src/index.ts: using a truthiness check for filter presence means an empty-string option can be interpreted as "no filter," which may unexpectedly clear all cookies. - Given the severity (6/10) and high confidence (8/10), this is user-impacting behavior rather than a minor edge-case, so the merge risk is moderate until the condition is tightened.
- Pay close attention to
packages/cli/src/index.ts- filter handling should distinguish empty-string values from an absent filter to avoid unintended cookie clearing.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/cli/src/index.ts">
<violation number="1" location="packages/cli/src/index.ts:2833">
P2: The filter-presence check uses truthiness, so empty-string option values are treated as “no filter” and can trigger clearing all cookies unexpectedly.</violation>
</file>
Architecture diagram
sequenceDiagram
participant User as User / Shell
participant CLI as CLI Command Handler
participant Executor as executeCommand (Router)
participant Context as Understudy Context
participant Browser as Browser (Local/Remote)
Note over User, Browser: NEW: Cookie Management Flow
User->>CLI: browse cookies get [urls]
CLI->>Executor: runCommand("cookies_get", [urls])
Executor->>Context: CHANGED: context.cookies(urls)
Context->>Browser: Request cookies (filtered by URL)
Browser-->>Context: Return cookie array
Context-->>Executor: Return cookies
Executor-->>CLI: { cookies: [...] }
CLI-->>User: Output JSON/Text
User->>CLI: browse cookies set <json>
CLI->>CLI: JSON.parse(json)
alt Invalid JSON
CLI-->>User: Error: must be JSON array
else Valid JSON
CLI->>Executor: runCommand("cookies_set", [cookies])
Executor->>Context: CHANGED: context.addCookies(cookieParams)
Context->>Browser: Inject cookies into session
Context-->>Executor: void
Executor-->>CLI: { added: count }
CLI-->>User: Success message
end
User->>CLI: browse cookies clear --domain <d>
CLI->>Executor: runCommand("cookies_clear", [{domain: d}])
Executor->>Context: CHANGED: context.clearCookies(filters)
Context->>Browser: Remove cookies matching filters
Context-->>Executor: void
Executor-->>CLI: { cleared: true }
CLI-->>User: Confirmation
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Prevents empty-string option values from being treated as absent, which would bypass the filter and clear all cookies unexpectedly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
browse cookies get [urls...]to inspect cookies (including httpOnly), with optional URL filteringbrowse cookies set <json>to add cookies from a JSON arraybrowse cookies clearto remove all cookies, or filter by--name,--domain,--pathcontext.cookies(),addCookies(),clearCookies()methodsUsage
Test results
cookies get(empty)[][]cookies set(add 1 cookie){added: 1}{added: 1}cookies get(verify set)cookies get <url>(URL filter)cookies clear --domain🤖 Generated with Claude Code