This skill is a router and manager. It ensures every application has its own dedicated folder containing both its automation class file and its capability documentation.
This skill relies exclusively on the Python environment (accessible via the python command) rather than a bundled setup.
Because we use the global Python environment, the Clicknium.Recorder.exe is located inside the system's site-packages.
To dynamically resolve its location (referred to below as {RECORDER_EXE}), use this command:
python -c "import clicknium, os; print(os.path.join(os.path.dirname(clicknium.__file__), '.lib', 'automation', 'Clicknium.Recorder.exe'))"
All resources are organized by process name in the .\apps\ directory:
{WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}\
...\{PROCESS_NAME}\{PROCESS_NAME}.py (Contains a Python class with action methods)
...\{PROCESS_NAME}\{PROCESS_NAME}.md
Extract the program name from the user's request (e.g., "Firefox") and standardize it to a lowercase process name (e.g., firefox).
Check for: apps/{PROCESS_NAME}/{PROCESS_NAME}.md AND apps/{PROCESS_NAME}/{PROCESS_NAME}.py
Read apps/{PROCESS_NAME}/{PROCESS_NAME}.md. Compare the user's request against the "Supported Actions".
Since the Python file contains a Class, we must instantiate it and call the correct method.
{WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}\{PROCESS_NAME}.py.
class FirefoxAutomator).
def open_url(self, url):).
url, text, filepath), extract these values from the user's prompt.
Create a temporary Python script (e.g., run_temp.py) inside the application folder {WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME} with the following logic. If the executed method has a return value, it must be captured and printed directly as a Python object.
```python
import sys
import os
# Ensure Current Working Directory matches the script location
os.chdir(r"{WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}")
# Import the Specific Module from the current directory
from {PROCESS_NAME} import {CLASS_NAME}
# Instantiate and Run
bot = {CLASS_NAME}()
result = bot.{METHOD_NAME}({PARAMETERS})
# Capture output. The return value is expected to be a Python list (array) object.
if result is not None:
print(result)
```
Run the generated run_temp.py using the global system Python environment.
IMPORTANT: The execution process (subprocess/terminal) MUST set the Current Working Directory (CWD) to the application folder. The total execution time $T$ will depend strictly on the complexity of the execution script.
python run_temp.py
{WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}
Failure to set the execution directory correctly will result in module import errors or missing resource failures.
Error Handling - Login Required:
If an execution error occurs and the error message implies that the user needs to log in:
"{RECORDER_EXE}" replay to bring up the recorder interface.
If the executed function returns a value, it will be a Python list (array) object. The JSON block below is only used to illustrate the expected object's structure:
```json
[
{
"element": "", // corresponding locatorid
"value": "" // fetched value during execution, content to be output
}
]
```
When interpreting the output, you must iterate through this array in the exact order, extract the "value" field from each element, and inform the user of these output values sequentially.
Delete run_temp.py from the application folder.
Initiate this when the application folder does not exist.
PROCESS_SKILL_PATH: {WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}
PYTHON_CODE_FILE: {PROCESS_SKILL_PATH}\{PROCESS_NAME}.py
DOC_FILE: {PROCESS_SKILL_PATH}\{PROCESS_NAME}.md
META_JSON_FILE: {PROCESS_SKILL_PATH}\meta.json
{PROCESS_SKILL_PATH} if it doesn't exist.
{RECORDER_EXE} path resolved in dependencies:
```bash
"{RECORDER_EXE}" replayAndGencode -p "{PROCESS_SKILL_PATH}" -o "{PYTHON_CODE_FILE}"
```
{PYTHON_CODE_FILE}.
{DOC_FILE}. Include:
# {PROCESS_NAME} Automation
## Supported Actions: List the intents realized by the code.
## Automatable Elements: List the properties (with @property) defined in the Python class.
{META_JSON_FILE} with the following structure:
```json
{
"Name": "{PROCESS_NAME}",
"Description": "Automation for the {PROCESS_NAME} application, supporting actions such as [List of Supported Actions]."
}
```
(Note: The automation name should be adjusted to be more user-friendly if needed. The description should be a concise summary of the skill's capabilities.)
Initiate this when the app folder exists, but the specific action is missing from the documentation.
PROCESS_SKILL_PATH: {WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}
EXISTING_CODE: {PROCESS_SKILL_PATH}\{PROCESS_NAME}.py
TEMP_NEW_CODE: {PROCESS_SKILL_PATH}\{PROCESS_NAME}_new_feature.py
DOC_FILE: {PROCESS_SKILL_PATH}\{PROCESS_NAME}.md
META_JSON_FILE: {PROCESS_SKILL_PATH}\meta.json
Run the recorder, saving only the new steps to the temporary file:
```
"{RECORDER_EXE}" replayAndGencode -p "{PROCESS_SKILL_PATH}" -o "{TEMP_NEW_CODE}"
```
EXISTING_CODE and TEMP_NEW_CODE.
TEMP_NEW_CODE into EXISTING_CODE.
EXISTING_CODE.
EXISTING_CODE (or the diff).
{DOC_FILE}:
{META_JSON_FILE}:
TEMP_NEW_CODE.
共 1 个版本