phodal / shire

Shire - AI Coding Agent Language (编程智能体语言), which can enables communication between an LLM and control IDE for automated programming.
https://shire.phodal.com/
Mozilla Public License 2.0
154 stars 21 forks source link

Web Interaction #132

Open phodal opened 2 weeks ago

phodal commented 2 weeks ago

Is your feature request related to a problem? Please describe.
In web automation, it can be cumbersome and error-prone to write individual code blocks for each webpage interaction step (e.g., opening a URL, clicking, inputting text, etc.). This often results in repetitive and complex code, especially when handling scenarios that involve waiting for elements or dealing with conditional logic. I’m always frustrated by how much manual setup is required for even simple interaction pipelines.

Describe the solution you'd like
I would like a streamlined, pipeline-style approach for handling webpage interactions in a single, chainable format. This would allow commands like open(url), click(selector), input(selector, text), and submit() to be written as a fluid sequence, improving readability and simplifying automation setup. Additionally, built-in support for wait conditions (e.g., waitFor(selector, timeout)) and error handling (onError(action)) would make it easier to manage asynchronous page elements and unexpected issues.

Describe alternatives you've considered
An alternative approach could involve writing helper functions for each step and chaining them manually. However, this adds extra complexity and does not provide the same level of readability or modularity. Using existing libraries (e.g., Selenium) is another option, but they lack the simplicity and intuitive flow that a custom pipeline-style API would provide.

Additional context
This feature could significantly reduce code length and complexity, particularly in scenarios with multi-step interactions on dynamic web pages. For example:

openWebpage("https://example.com/login") {
    waitFor("#username", timeout = 5000) |
    input("#username", "user123") |
    input("#password", "password123") |
    click("#submit") |
    waitFor("#dashboard", timeout = 10000) |
    onError { print("Failed to log in") }
}

This pipeline-style interaction could enhance both productivity and maintainability in web automation projects.

Usecase: use online chat or other tools, like https://v0.dev/

phodal commented 2 weeks ago

Change syntax for new type block-action

openWebpage("https://example.com/login") {
    waitFor("#username", timeout = 5000) |
    input("#username", "user123") |
    input("#password", "password123") |
    click("#submit") |
    waitFor("#dashboard", timeout = 10000) |
    onError { print("Failed to log in") }
}