Преглед изворни кода

docs: projects, find.files, notifications (#6438)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
opencode-agent[bot] пре 1 месец
родитељ
комит
37da005a01

+ 23 - 0
packages/web/src/content/docs/keybinds.mdx

@@ -118,6 +118,29 @@ You can disable a keybind by adding the key to your config with a value of "none
 
 ---
 
+## Desktop prompt shortcuts
+
+The OpenCode desktop app prompt input supports common Readline/Emacs-style shortcuts for editing text. These are built-in and currently not configurable via `opencode.json`.
+
+| Shortcut | Action                                   |
+| -------- | ---------------------------------------- |
+| `ctrl+a` | Move to start of current line            |
+| `ctrl+e` | Move to end of current line              |
+| `ctrl+b` | Move cursor back one character           |
+| `ctrl+f` | Move cursor forward one character        |
+| `alt+b`  | Move cursor back one word                |
+| `alt+f`  | Move cursor forward one word             |
+| `ctrl+d` | Delete character under cursor            |
+| `ctrl+k` | Kill to end of line                      |
+| `ctrl+u` | Kill to start of line                    |
+| `ctrl+w` | Kill previous word                       |
+| `alt+d`  | Kill next word                           |
+| `ctrl+y` | Yank (paste) last killed text            |
+| `ctrl+t` | Transpose characters                     |
+| `ctrl+g` | Cancel popovers / abort running response |
+
+---
+
 ## Shift+Enter
 
 Some terminals don't send modifier keys with Enter by default. You may need to configure your terminal to send `Shift+Enter` as an escape sequence.

+ 4 - 0
packages/web/src/content/docs/plugins.mdx

@@ -230,6 +230,10 @@ export const NotificationPlugin = async ({ project, client, $, directory, worktr
 
 We are using `osascript` to run AppleScript on macOS. Here we are using it to send notifications.
 
+:::note
+If you’re using the OpenCode desktop app, it can send system notifications automatically when a response is ready or when a session errors.
+:::
+
 ---
 
 ### .env protection

+ 18 - 8
packages/web/src/content/docs/sdk.mdx

@@ -283,13 +283,19 @@ await client.session.prompt({
 
 ### Files
 
-| Method                    | Description                  | Response                                                                                    |
-| ------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------- |
-| `find.text({ query })`    | Search for text in files     | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` |
-| `find.files({ query })`   | Find files by name           | `string[]` (file paths)                                                                     |
-| `find.symbols({ query })` | Find workspace symbols       | <a href={typesUrl}><code>Symbol[]</code></a>                                                |
-| `file.read({ query })`    | Read a file                  | `{ type: "raw" \| "patch", content: string }`                                               |
-| `file.status({ query? })` | Get status for tracked files | <a href={typesUrl}><code>File[]</code></a>                                                  |
+| Method                    | Description                        | Response                                                                                    |
+| ------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------- |
+| `find.text({ query })`    | Search for text in files           | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` |
+| `find.files({ query })`   | Find files and directories by name | `string[]` (paths)                                                                          |
+| `find.symbols({ query })` | Find workspace symbols             | <a href={typesUrl}><code>Symbol[]</code></a>                                                |
+| `file.read({ query })`    | Read a file                        | `{ type: "raw" \| "patch", content: string }`                                               |
+| `file.status({ query? })` | Get status for tracked files       | <a href={typesUrl}><code>File[]</code></a>                                                  |
+
+`find.files` supports a few optional query fields:
+
+- `type`: `"file"` or `"directory"`
+- `directory`: override the project root for the search
+- `limit`: max results (1–200)
 
 ---
 
@@ -302,7 +308,11 @@ const textResults = await client.find.text({
 })
 
 const files = await client.find.files({
-  query: { query: "*.ts" },
+  query: { query: "*.ts", type: "file" },
+})
+
+const directories = await client.find.files({
+  query: { query: "packages", type: "directory", limit: 20 },
 })
 
 const content = await client.file.read({

+ 16 - 8
packages/web/src/content/docs/server.mdx

@@ -173,14 +173,22 @@ The opencode server exposes the following APIs.
 
 ### Files
 
-| Method | Path                     | Description                  | Response                                                                                    |
-| ------ | ------------------------ | ---------------------------- | ------------------------------------------------------------------------------------------- |
-| `GET`  | `/find?pattern=<pat>`    | Search for text in files     | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` |
-| `GET`  | `/find/file?query=<q>`   | Find files by name           | `string[]` (file paths)                                                                     |
-| `GET`  | `/find/symbol?query=<q>` | Find workspace symbols       | <a href={typesUrl}><code>Symbol[]</code></a>                                                |
-| `GET`  | `/file?path=<path>`      | List files and directories   | <a href={typesUrl}><code>FileNode[]</code></a>                                              |
-| `GET`  | `/file/content?path=<p>` | Read a file                  | <a href={typesUrl}><code>FileContent</code></a>                                             |
-| `GET`  | `/file/status`           | Get status for tracked files | <a href={typesUrl}><code>File[]</code></a>                                                  |
+| Method | Path                     | Description                        | Response                                                                                    |
+| ------ | ------------------------ | ---------------------------------- | ------------------------------------------------------------------------------------------- |
+| `GET`  | `/find?pattern=<pat>`    | Search for text in files           | Array of match objects with `path`, `lines`, `line_number`, `absolute_offset`, `submatches` |
+| `GET`  | `/find/file?query=<q>`   | Find files and directories by name | `string[]` (paths)                                                                          |
+| `GET`  | `/find/symbol?query=<q>` | Find workspace symbols             | <a href={typesUrl}><code>Symbol[]</code></a>                                                |
+| `GET`  | `/file?path=<path>`      | List files and directories         | <a href={typesUrl}><code>FileNode[]</code></a>                                              |
+| `GET`  | `/file/content?path=<p>` | Read a file                        | <a href={typesUrl}><code>FileContent</code></a>                                             |
+| `GET`  | `/file/status`           | Get status for tracked files       | <a href={typesUrl}><code>File[]</code></a>                                                  |
+
+#### `/find/file` query parameters
+
+- `query` (required) — search string (fuzzy match)
+- `type` (optional) — limit results to `"file"` or `"directory"`
+- `directory` (optional) — override the project root for the search
+- `limit` (optional) — max results (1–200)
+- `dirs` (optional) — legacy flag (`"false"` returns only files)
 
 ---