Browse topics
Docs Hooks
Typed calls exposed by the docs applet.
Nine hooks. Position values (offset, cursor, from, to) are UTF-16 code-unit offsets into the markdown source as persisted on disk.
docs.selectDoc
Open the given file path in the docs editor for this applet and focus it. Fails if the docs editor is not mounted.
Params: { resource_id: string; pane_id?: string; path: string } - path is relative to the applet folder.
Returns: { opened_path: string }
Permission: docs:read
Handler: Frontend
docs.createDoc
Create a new markdown doc at the given path with optional initial content. Fails if the path already exists (no silent overwrite). Emits an activity log.
Params: { resource_id: string; path: string; content?: string | null }
Returns: { path: string }
Permission: docs:write
Handler: Rust
docs.getOpenedFile
Return the file currently open in the docs editor: path, current buffer content, dirty state, and cursor position.
Params: { resource_id: string; pane_id?: string }
Returns: { path: string | null; content: string; is_dirty: boolean; cursor: number } - path: null if no file is open.
Permission: docs:read
Handler: Frontend
docs.moveCursor
Move the cursor in the opened file to the given character offset.
Params: { resource_id: string; pane_id?: string; offset: number }
Returns: { cursor: number } (clamped if out of bounds)
Permission: docs:write - cursor moves are visible interactive state changes.
Handler: Frontend
docs.searchOpened
Search the currently opened file’s buffer for a query. Returns match ranges as character offsets.
Params: { resource_id: string; pane_id?: string; query: string; regex?: boolean; case_sensitive?: boolean }
Returns: { matches: Array<{ from: number; to: number }> }
Permission: docs:read
Handler: Frontend
docs.search
Grep across markdown files in the docs applet’s folder.
Params: { resource_id: string; query: string; regex?: boolean; case_sensitive?: boolean; max_results?: number | null }
Returns: { matches: Array<{ path: string; line: number; snippet: string }> }
Permission: docs:read
Handler: Rust
docs.getSelection
Return the current selection range as character offsets plus the selected text.
Params: { resource_id: string; pane_id?: string }
Returns: { from: number; to: number; text: string } - from === to means empty selection (caret).
Permission: docs:read
Handler: Frontend
docs.setSelection
Select a range of the opened file by start and end character offsets. Clamped to document length.
Params: { resource_id: string; pane_id?: string; from: number; to: number }
Returns: { from: number; to: number } - the resulting (clamped) selection.
Permission: docs:write
Handler: Frontend
docs.insertAtSelection
Replace the current selection with the given text. If there is no selection, insert at the cursor.
Params: { resource_id: string; pane_id?: string; text: string }
Returns: { cursor: number }
Permission: docs:write
Handler: Frontend