← 返回
未分类 中文

SnapGen

Use this skill when the user asks to open, run, or automate a specific desktop application. It manages the full lifecycle of automation scripts within dedica...
当用户要求打开、运行或自动化特定的桌面应用程序时使用此技能。它管理自动化脚本在专用环境中的完整生命周期。
snapgen
未分类 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 317
下载
💾 0
安装
1
版本
#latest

概述

Program Automator Skill

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.

Bundled Python Environment

This skill relies exclusively on the Python environment (accessible via the python command) rather than a bundled setup.

Dynamic Recorder Resolution

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'))"

Context Directory Structure

All resources are organized by process name in the .\apps\ directory:

  • Folder: {WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}\
  • Class File: ...\{PROCESS_NAME}\{PROCESS_NAME}.py (Contains a Python class with action methods)
  • Docs: ...\{PROCESS_NAME}\{PROCESS_NAME}.md

Workflow

Step 1: Identify & Normalize

Extract the program name from the user's request (e.g., "Firefox") and standardize it to a lowercase process name (e.g., firefox).

Step 2: Check Existence

Check for: apps/{PROCESS_NAME}/{PROCESS_NAME}.md AND apps/{PROCESS_NAME}/{PROCESS_NAME}.py

  • IF both exist -> Go to Step 3: Capability Audit.
  • IF either is missing -> Go to Scenario B: Creation Protocol.

Step 3: Capability Audit

Read apps/{PROCESS_NAME}/{PROCESS_NAME}.md. Compare the user's request against the "Supported Actions".

  • IF supported -> Go to Scenario A: Dynamic Execution.
  • IF NOT supported -> Go to Scenario C: Extension Protocol.

Scenarios

Scenario A: Dynamic Execution (Function Call Strategy)

Since the Python file contains a Class, we must instantiate it and call the correct method.

  1. Analyze Source Code:
    • Read {WORKSPACE_PATH}\skills\snapgen\apps\{PROCESS_NAME}\{PROCESS_NAME}.py.
    • Identify the Class Name (usually matches the process name, e.g., class FirefoxAutomator).
    • Identify the Method Name that matches the user's intent (e.g., def open_url(self, url):).
  1. Extract Parameters:
    • If the target method requires arguments (e.g., url, text, filepath), extract these values from the user's prompt.
  1. Generate Driver Script:

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)

```

  1. Execute (CRITICAL):

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.

  • Command: python run_temp.py
  • Working Directory (cwd): {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:

  • Execute the command "{RECORDER_EXE}" replay to bring up the recorder interface.
  • Instruct the user to manually perform the login operations within the opened window and close it once finished.
  • Do not perform any additional operations or retries automatically after giving this instruction.
  1. Output Processing Format:

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.

  1. Cleanup:

Delete run_temp.py from the application folder.

Scenario B: Creation Protocol (Brand New App)

Initiate this when the application folder does not exist.

  1. Notify: "I don't have a configuration for yet. Initiating generation..."
  2. Define Paths:
    • 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
  1. Record & Generate:
    • Create the directory {PROCESS_SKILL_PATH} if it doesn't exist.
    • Run the recorder command using the {RECORDER_EXE} path resolved in dependencies:

```bash

"{RECORDER_EXE}" replayAndGencode -p "{PROCESS_SKILL_PATH}" -o "{PYTHON_CODE_FILE}"

```

  1. Extract and Generate Documentation & Meta:
    • READ the generated {PYTHON_CODE_FILE}.
    • ANALYZE the Python code to understand what actions were just recorded and identify properties.
    • CREATE {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.
    • CREATE {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.)

Scenario C: Extension Protocol (Adding Methods)

Initiate this when the app folder exists, but the specific action is missing from the documentation.

  1. Notify: "I know , but I need to learn this new specific action. Recording new steps..."
  2. Define Paths:
    • 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
  1. Record (New Features Only):

Run the recorder, saving only the new steps to the temporary file:

```

"{RECORDER_EXE}" replayAndGencode -p "{PROCESS_SKILL_PATH}" -o "{TEMP_NEW_CODE}"

```

  1. Merge Code:
    • READ both EXISTING_CODE and TEMP_NEW_CODE.
    • MERGE them logically:
    • Combine imports.
    • Append the new functions/logic from TEMP_NEW_CODE into EXISTING_CODE.
    • Ensure the old logic remains intact.
    • SAVE the merged content back to EXISTING_CODE.
  1. Update Documentation and Meta:
    • READ the new content of EXISTING_CODE (or the diff).
    • UPDATE {DOC_FILE}:
    • Add the new capability to the "Supported Actions" list.
    • Add the newly defined properties to the "Automatable Elements" list.
    • Ensure the file accurately describes the combined capabilities of the script.
    • UPDATE {META_JSON_FILE}:
    • Update the "Description" to reflect the new capabilities.
  1. Cleanup & Execute:
    • Delete TEMP_NEW_CODE.
    • Proceed to Scenario A to run the newly added method immediately (respecting the CWD requirement).

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-07 11:19 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 840 📥 316,719
ai-agent

Find Skills

guipi888
场景驱动+关键词双模式技能发现工具。当用户用自然语言描述场景/需求(如"我想做一个海报""帮我分析股票"),或明确说"安装技能/find skills/找个skill"时,自动从官方内置、本地已安装、SkillHub、虾评、GitHub、C
★ 1,479 📥 541,560
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,113 📥 834,545