Skip to content

feat(tool): add open tool for files and URLs#24891

Draft
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Marxist-Leninist:upstream/feat/open-tool
Draft

feat(tool): add open tool for files and URLs#24891
Marxist-Leninist wants to merge 1 commit intoanomalyco:devfrom
Marxist-Leninist:upstream/feat/open-tool

Conversation

@Marxist-Leninist
Copy link
Copy Markdown

Issue for this PR

Closes #24890

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a built-in open tool that can surface a local file, folder, file:// URL, or http(s) URL using the operating system default handler.

The tool resolves relative local paths from the project directory, rejects unsupported URL schemes, asks for an open permission before launching anything, and returns structured metadata indicating whether the OS launcher accepted the request. On Windows it uses rundll32.exe url.dll,FileProtocolHandler for files/URLs and Explorer for folders/reveal, avoiding cmd /c start shell parsing.

How did you verify your code works?

  • packages/opencode: bun test test/tool/open.test.ts --timeout 30000
  • git diff --check
  • Changed files scrubbed for private fork strings/secrets with git grep.

Screenshots / recordings

No screenshot. This is a tool/runtime change; the TUI shows a compact Open tool part.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…lder

Adds an `open` builtin tool that hands a file path, folder, or URL to
the OS default handler. Useful for "open the generated report",
"reveal this artifact in Explorer", or "show this URL in the user's
browser" without needing a bash command.

Parameters:
* `target` — local path, folder, or http(s)/file URL.
* `reason` — optional short reason rendered to the user.
* `reveal_in_folder` — when target is a real file, open the parent
  folder with the file selected (Windows: explorer /select,, macOS:
  open -R, Linux: xdg-open parent).

Safety:
* Allowed URL schemes: http, https, file. Anything else (including
  javascript: and data:) is rejected.
* Local paths must exist — refuses missing targets up-front.
* No shell — spawns the platform launcher directly with windowsHide
  so untrusted target text cannot inject commands.

Wires registry, agent permission list, and the TUI ToolPart switch
so the chat shows "⤢ Open file report.txt" or
"⤢ Open url https://example.com..." instead of the generic spinner.
@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

The search results show that PR #24891 (the current PR) appears in all results. After filtering out the current PR itself, the other PRs found don't appear to be duplicates - they address different features like pagination, browser tools, sidebar plugins, clipboard handling, path separators, text transformations, and tool aliases.

No duplicate PRs found

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.

[FEATURE]: add an open tool for surfacing files and URLs

1 participant