From 6c9a1ba56b66bc83d928d44cdb0290a2efbf488b Mon Sep 17 00:00:00 2001 From: Grail Finder Date: Tue, 3 Mar 2026 09:37:34 +0300 Subject: [PATCH] Chore: change 'when askes' to more proactive phrasing --- tools.go | 16 ++++++++-------- tools_playwright.go | 28 +++++++++++----------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/tools.go b/tools.go index 5683a90..76ba34e 100644 --- a/tools.go +++ b/tools.go @@ -77,17 +77,17 @@ Your current tools: { "name":"file_create", "args": ["path", "content"], -"when_to_use": "when asked to create a new file with optional content" +"when_to_use": "when there is a need to create a new file with optional content" }, { "name":"file_read", "args": ["path"], -"when_to_use": "when asked to read the content of a file" +"when_to_use": "when you need to read the content of a file" }, { "name":"file_read_image", "args": ["path"], -"when_to_use": "when asked to read or view an image file" +"when_to_use": "when you need to read or view an image file" }, { "name":"file_write", @@ -97,7 +97,7 @@ Your current tools: { "name":"file_write_append", "args": ["path", "content"], -"when_to_use": "when asked to append content to a file; use sed to edit content" +"when_to_use": "when you need append content to a file; use sed to edit content" }, { "name":"file_edit", @@ -112,22 +112,22 @@ Your current tools: { "name":"file_move", "args": ["src", "dst"], -"when_to_use": "when asked to move a file from source to destination" +"when_to_use": "when you need to move a file from source to destination" }, { "name":"file_copy", "args": ["src", "dst"], -"when_to_use": "when asked to copy a file from source to destination" +"when_to_use": "copy a file from source to destination" }, { "name":"file_list", "args": ["path"], -"when_to_use": "when asked to list files in a directory; path is optional (default: current directory)" +"when_to_use": "list files in a directory; path is optional (default: current directory)" }, { "name":"execute_command", "args": ["command", "args"], -"when_to_use": "when asked to execute a system command; args is optional; allowed commands: grep, sed, awk, find, cat, head, tail, sort, uniq, wc, ls, echo, cut, tr, cp, mv, rm, mkdir, rmdir, pwd, df, free, ps, top, du, whoami, date, uname, go" +"when_to_use": "execute a system command; args is optional; allowed commands: grep, sed, awk, find, cat, head, tail, sort, uniq, wc, ls, echo, cut, tr, cp, mv, rm, mkdir, rmdir, pwd, df, free, ps, top, du, whoami, date, uname, go" } ] diff --git a/tools_playwright.go b/tools_playwright.go index cd36b60..9f19a4b 100644 --- a/tools_playwright.go +++ b/tools_playwright.go @@ -33,52 +33,52 @@ Additional browser automation tools (Playwright): { "name": "pw_navigate", "args": ["url"], - "when_to_use": "when asked to open a specific URL in a web browser." + "when_to_use": "open a specific URL in the web browser." }, { "name": "pw_click", "args": ["selector", "index"], - "when_to_use": "when asked to click on an element on the current webpage. 'index' is optional (default 0) to handle multiple matches." + "when_to_use": "click on an element on the current webpage. Use 'index' for multiple matches (default 0)." }, { "name": "pw_fill", "args": ["selector", "text", "index"], - "when_to_use": "when asked to type text into an input field. 'index' is optional." + "when_to_use": "type text into an input field. Use 'index' for multiple matches (default 0)." }, { "name": "pw_extract_text", "args": ["selector"], - "when_to_use": "when asked to get text content from the page or specific elements. Use selector 'body' for all page text." + "when_to_use": "extract text content from the page or specific elements. Use selector 'body' for all page text." }, { "name": "pw_screenshot", "args": ["selector", "full_page"], - "when_to_use": "when asked to take a screenshot of the page or a specific element. Returns a file path to the image." + "when_to_use": "take a screenshot of the page or a specific element. Returns a file path to the image. Use to verify actions or inspect visual state." }, { "name": "pw_screenshot_and_view", "args": ["selector", "full_page"], - "when_to_use": "when asked to take a screenshot and show it to the model. Returns image for viewing." + "when_to_use": "take a screenshot and return the image for viewing. Use to visually verify page state." }, { "name": "pw_wait_for_selector", "args": ["selector", "timeout"], - "when_to_use": "when asked to wait for an element to appear on the page before proceeding." + "when_to_use": "wait for an element to appear on the page before proceeding with further actions." }, { "name": "pw_drag", "args": ["x1", "y1", "x2", "y2"], - "when_to_use": "drag the mouse from point (x1,y1) to (x2,y2)" + "when_to_use": "drag the mouse from point (x1,y1) to (x2,y2)." }, { "name": "pw_get_html", "args": ["selector"], - "when_to_use": "get the HTML content of the page or a specific element. Use when you need to understand page structure or extract HTML." + "when_to_use": "get the HTML content of the page or a specific element. Use to understand page structure or extract raw HTML." }, { "name": "pw_get_dom", "args": ["selector"], - "when_to_use": "get a structured DOM representation with tag, attributes, text, and children. Use when you need a readable tree view of page elements." + "when_to_use": "get a structured DOM representation with tag, attributes, text, and children. Use to inspect element hierarchy and properties." }, { "name": "pw_search_elements", @@ -493,12 +493,10 @@ func buildDOMTree(locator playwright.Locator) ([]DOMElement, error) { func elementToDOM(el playwright.Locator) (DOMElement, error) { dom := DOMElement{} - tag, err := el.Evaluate(`el => el.nodeName`, nil) if err == nil { dom.Tag = strings.ToLower(fmt.Sprintf("%v", tag)) } - attributes := make(map[string]string) attrs, err := el.Evaluate(`el => { let attrs = {}; @@ -520,17 +518,14 @@ func elementToDOM(el playwright.Locator) (DOMElement, error) { if len(attributes) > 0 { dom.Attributes = attributes } - text, err := el.TextContent() if err == nil && text != "" { dom.Text = text } - innerHTML, err := el.InnerHTML() if err == nil && innerHTML != "" { dom.InnerHTML = innerHTML } - childCount, _ := el.Count() if childCount > 0 { childrenLocator := el.Locator("*") @@ -539,7 +534,6 @@ func elementToDOM(el playwright.Locator) (DOMElement, error) { dom.Children = children } } - return dom, nil } @@ -599,7 +593,7 @@ func pwSearchElements(args map[string]string) []byte { text, _ := el.TextContent() html, _ := el.InnerHTML() results = append(results, map[string]string{ - "index": fmt.Sprintf("%d", i), + "index": strconv.Itoa(i), "tag": strings.ToLower(fmt.Sprintf("%v", tag)), "text": text, "html": html,