欢迎来到 RuyiX 的世界!RuyiX 是一个简单而强大的自然语言编程框架,旨在让每个人都能轻松地创造工具和智能体完成任务,无论是日常事务自动化、数据处理,还是设备操作。 Welcome to the world of RuyiX! RuyiX is a simple yet powerful natural language programming framework designed to let everyone easily turn ideas into executable programs, whether for automating daily tasks, processing data, or interacting with smart devices.

演示视频 Demo Videos

观看 RuyiX 在真实场景中自动化操作手机、浏览器等设备的演示 Watch RuyiX automate phones, browsers and other devices in real scenarios
* 所有视频均为实际演示录屏,未经加速 * All videos are actual demo recordings, not sped up

学术研究 Research

收集百度学术中 10 篇关于 GUI Agent 的文章信息及截图 Collect 10 GUI Agent papers from Baidu Scholar with screenshots

自动化学术信息收集,批量获取论文数据 Automated academic data collection in batch

办公协作 Office

在飞书中预约主题为 "RuyiX 讨论" 的会议 Schedule a "RuyiX Discussion" meeting in Feishu

智能日程管理,一键创建团队会议 Smart scheduling with one-click meeting setup

电商购物 Shopping

在京东 App 搜索并加购 iPhone 17 Pro Search and add iPhone 17 Pro to cart on JD App

自动化购物流程,智能商品搜索下单 Automated shopping flow with smart ordering

社交媒体 Social

在小红书搜索雷军并点赞关注及私信 Search Lei Jun on Xiaohongshu, like, follow & message

社交平台自动化互动,智能用户操作 Automated social media interaction


1. RuyiX 是什么? 1. What is RuyiX?

RuyiX 的核心思想是 “所思即所得,万事皆如意”。它致力于打破传统编程语言复杂的语法壁垒,通过自然、直观的方式描述需求,由强大的人工智能模型将其解释并执行。 The core idea of RuyiX is "What you think is what you get, everything goes as you wish." It aims to break down the complex syntactical barriers of traditional programming languages by describing needs in a natural, intuitive way, which is then interpreted and executed by a powerful AI model.

编程能力的重要性不言而喻。自计算机发明以来,各种编程语言和框架不断涌现,编程可以实现的功能越来越丰富,而最近出现的AI模型和工具例如ChatGPT、Claude、Deepseek、Cursor等又进一步将编程的效率大大提升… 未来,编程能够实现的能力边界将加速扩大;与此同时,编程者也不再仅仅只有人类,还将包括智能体(Agent),未来将是人与智能体协作生产力的时代。 The importance of programming is self-evident. Since the invention of computers, various programming languages and frameworks have emerged, continuously expanding what programming can achieve. Recent AI models and tools like ChatGPT, Claude, Deepseek, and Cursor have further boosted programming efficiency. In the future, the boundaries of what programming can accomplish will expand at an accelerated pace. At the same time, programmers will no longer be exclusively human but will also include intelligent agents. The future will be an era of human-agent collaborative productivity.

因此,我们认为编程将不再是少数人的专利,而是一种所有人都可以掌握的、用来与机器沟通协作的载体。RuyiX 就是出于这一目的而设计,我们希望让编程者可以跳过繁琐的代码语法、数据结构、算法实现,直接表达核心业务逻辑,高效完成目标。总结起来,RuyiX 的主要特点包括: Therefore, we believe programming will no longer be a skill for a select few, but a medium that everyone can master for communication and collaboration with machines. RuyiX is designed with this purpose in mind. We want to enable programmers to bypass tedious code syntax, data structures, and algorithmic implementations to directly express core business logic and achieve goals efficiently. To summarize, the main features of RuyiX include:

  1. 普适易学:为所有人设计,无论是否具备编程背景,都能快速上手,如同学习一种新的沟通方式。 Accessible and Easy to Learn: Designed for everyone, regardless of programming background, allowing for a quick start, much like learning a new way to communicate.
  2. 功能实用:当前功能覆盖重复性的操作流程自动化、数据整理与分析等,未来还将增加更多功能。 Functional and Practical: Current features cover the automation of repetitive workflows, data organization, and analysis, with more functionality to be added in the future.
  3. 容错性强:鼓励使用日常语言来编写,可以容忍指令的不精确,更注重理解实际意图。 Highly Fault-Tolerant: Encourages writing in everyday language, tolerates imprecise instructions, and focuses on understanding the actual intent.
  4. 注重逻辑:依然支持编程的核心逻辑概念,如变量、循环、条件判断、数据类型、函数等。 Logic-Focused: Continues to support core programming concepts like variables, loops, conditional statements, data types, and functions.
  5. AI解释器:RuyiX程序由AI大模型(RuyiX解释器)动态解释执行,执行准确性和运行速度会随着模型能力提升。 AI Interpreter: RuyiX programs are dynamically interpreted and executed by a large AI model (the RuyiX Interpreter), with execution accuracy and speed improving as the model's capabilities advance.

2. 快速开始 2. Quick Start

上手使用 RuyiX 非常简单,你只需要在我们的网站上下载 "RuyiX Studio" 应用,打开后按照引导完成基本设置,就可以在编辑窗口中开始创建你的第一个 RuyiX 程序了。 Getting started with RuyiX is very simple. You just need to download the "RuyiX Studio" application from our website, open it, follow the guide to complete the basic setup, and you can start creating your first RuyiX program in the editor window.

你的第一个 RuyiX 程序: Your first RuyiX program:

想象你想让RuyiX助手向你问好。你可以这样写: Imagine you want the RuyiX assistant to greet you. You can write:

# 我的第一个RuyiX程序
告诉用户 "你好,祝你一切如意!"# My first RuyiX program
tell user "Hi, RuyiX for you!"

接下来,点击RuyiX Studio中的“执行”按钮,你就可以从对话窗口中看到助手发来的问候消息。 Next, click the "Execute" button in the RuyiX Studio, and you will see the greeting message from the assistant in the dialog window.

再来一个与 AI 互动的例子: Another example of interacting with AI:

# 询问AI并获取信息
询问AI,输入是 "中国的首都是哪里?",输出结果记为{首都}
告诉用户 "中国的首都是:{首都}"# Ask AI and get information
ask AI, input is "Where is the capital of China?", record output as {capital}
tell user "The capital of China is: {capital}"

看到了吗?就像在和一位聪明的助手对话一样,你只需用清晰的语言描述你的步骤和目标即可。 See? It's just like talking to a smart assistant; you only need to describe your steps and goals in clear language.

你可以尝试直接与应用中内置的“RuyiX智能助手”对话,告诉它你的需求,让它帮你自动生成一个程序草稿供你修改。 You can try talking directly to the built-in "RuyiX Smart Assistant" in the application, tell it your needs, and it will help you automatically generate a program draft for you to modify.

接下来本文将介绍RuyiX的语法规范,我们会在介绍过程中插入一些可以在RuyiX Studio中直接运行的例子,便于你边学边用,快速掌握。 Next, this article will introduce the syntax specifications of RuyiX. We will include examples that can be run directly in the RuyiX Studio during the introduction to help you learn and use it quickly.

你也可以跳过语法介绍部分,直接去看 实际案例 中感兴趣的例子,在例子中学习。 You can also skip the syntax introduction and go directly to the interesting examples in the Use Cases section and learn from the examples.

3. 基本语法与概念 3. Basic Syntax and Concepts

RuyiX 的语法非常灵活,但遵循一些简单的约定和概念将有助于系统更精确地理解你的意图。 RuyiX's syntax is very flexible, but following some simple conventions and concepts will help the system understand your intent more accurately.

RuyiX 程序由一系列语句组成,通常每行一个语句,描述一个操作或一个步骤,鼓励使用祈使句或清晰的陈述句。 A RuyiX program consists of a series of statements, usually one per line, describing an action or a step. Using imperative or clear declarative sentences is encouraged.

注释 Comments

使用 # 符号开始一行,表示这一行是注释。注释用于解释代码,系统在执行时会忽略它们。 Use the # symbol to start a line, indicating that this line is a comment. Comments are used to explain the code and are ignored by the system during execution.

# 这是一个注释,系统不会执行这句话
告诉用户 "你好,注释让代码更易懂" # 这也是一个行内注释# This is a comment, the system will not execute this sentence
tell user "Hello, comments make code easier to understand" # This is also an inline comment

变量 Variables

变量就像是贴了标签的盒子,用来存储信息,方便后续使用。在 RuyiX 中,变量一般用大括号包裹的词语表示,例如 {变量} Variables are like labeled boxes used to store information for later use. In RuyiX, variables are generally represented by words enclosed in curly braces, like {variable}.

  • 声明(记录)变量Declaring (Recording) Variables:通常使用 记为{变量名} 或类似的自然语言方式。: Usually done using record as {variableName} or similar natural language phrases.

    询问AI,输入是"目前人工智能领域的头部公司有哪些?",输出公司列表,记为{公司列表}
    设置变量 {用户姓名} 为 "小明"
    将 "北京" 存入 {当前城市}
    创建变量 {来访人数},初始值为 0ask AI, input is "What are the leading companies in AI?", output a list of companies, record as {companyList}
    set variable {userName} to "Xiao Ming"
    store "Beijing" in {currentCity}
    create variable {visitorCount}, with an initial value of 0
  • 使用变量Using Variables:在需要用到存储信息的地方,使用 {变量名},即代表将变量的值填入对应的位置。: Wherever you need the stored information, use {variableName}, which means the value of the variable will be inserted at that position.

    告诉用户 "你好,{用户姓名}"
    在浏览器中搜索 "{当前城市} 人口数量",记为 {人口数量}
    告诉用户 "{当前城市} 的人口数量是 {人口数量}。"tell user "Hello, {userName}"
    in the browser, search for "{currentCity} population", record as {population}
    tell user "The population of {currentCity} is {population}."

变量名建议使用有意义的词语,方便理解。 It is recommended to use meaningful words for variable names for better understanding.

数据类型 Data Types

每个变量在系统中存储和传递时,是被理解为不同类型的数据进行实际操作的。不同类型的变量用于不同场景的数据处理,例如数字类型变量用于数据统计、文本类型的变量用于文档操作、对话等。 When variables are stored and passed in the system, they are understood as different types of data for specific operations. Different variable types are used for different data processing scenarios; for example, number-type variables are for statistics, while text-type variables are for document operations, dialogues, etc.

类型在传统的编程语言中是个重要的概念(也往往比较容易出错),但在 RuyiX 中,你不需要专门关心变量的类型,RuyiX 会根据你的代码自动理解每个变量的类型。当然你也可以在定义变量时补充说明类型,以对整个处理过程更有控制感。例如: Types are an important (and often error-prone) concept in traditional programming languages. However, in RuyiX, you don't need to explicitly worry about variable types; RuyiX will automatically understand the type of each variable from your code. Of course, you can also specify the type when defining a variable to have more control over the process. For example:

询问AI "北京的人口数量是多少?",输出数字,记为{人口数}
询问AI "北京去年的人均GDP是多少?",输出文本,记为{人均GDP}
告诉用户 "北京的人口数量是 {人口数},人均GDP为 {人均GDP}。"ask AI "What is the population of Beijing?", output a number, record as {population}
ask AI "What was Beijing's per capita GDP last year?", output text, record as {perCapitaGDP}
tell user "The population of Beijing is {population}, and the per capita GDP is {perCapitaGDP}."

基本数据类型 Basic Data Types

RuyiX 目前支持下列基本数据类型:RuyiX currently supports the following basic data types:

  • 文本Text: 用引号括起来的字符序列,如 "Hello world!"'你好,世界!'A sequence of characters enclosed in quotes, such as "Hello world!" or '你好, 世界!'.
  • 数字Number: 整数或小数,如 103.14Integers or decimals, such as 10 or 3.14.
  • 布尔Boolean: (或者 / ),用于表示条件或状态。true or false (or yes / no), used to represent conditions or states.
询问用户 "你的年龄是多少?",结果记为 {年龄}
判断 {年龄} 是否大于 18,记为 {是否成年} # {是否成年} 会是 真 或 假
如果 {是否成年} 为真:
    告诉用户 "你已成年。"ask user "What is your age?", record result as {age}
check if {age} is greater than 18, record as {isAdult} # {isAdult} will be true or false
if {isAdult} is true:
    tell user "You are an adult."
  • 图像Image: 代表图片数据。可以通过拍照、读取文件或AI生成等方式获得。Represents image data. Can be obtained by taking a photo, reading a file, or generating with AI.
拍照,记为 {产品图片}
读取图片文件 "logo.png",记为 {公司Logo}
询问AI "生成一张卡通猫的图片",输出图像,记为 {卡通猫图片}
告诉用户 "这是拍摄的产品图片:"
把{产品图片}发送给用户take a photo, record as {productImage}
read image file "logo.png", record as {companyLogo}
ask AI "generate an image of a cartoon cat", output an image, record as {cartoonCatImage}
tell user "This is the product photo taken:"
send {productImage} to the user

对象 (Object) Object

对象是包含多个属性的集合,用于表示一个具体的事物或实体。每个属性都有一个名称和一个对应的值(也称为键值对)。属性的值可能是一个基本类型的变量,也可能是另外一个对象。 An object is a collection of multiple properties, used to represent a specific thing or entity. Each property has a name and a corresponding value (also known as a key-value pair). The value of a property can be a basic type variable or another object.

  • 创建对象Creating an Object:

    创建一个对象,名为 {我的汽车}
    设置 {我的汽车} 的 {颜色} 为 "红色"
    设置 {我的汽车} 的 {品牌} 为 "特斯拉"
    设置 {我的汽车} 的 {型号} 为 "Model Y"
    
    # 或者更简洁的方式,AI会理解你的意图
    创建一个对象 {客户},其属性包括: "姓名" 是 "李明","年龄" 是 24,"城市" 是 "上海"create an object named {myCar}
    set the {color} of {myCar} to "red"
    set the {brand} of {myCar} to "Tesla"
    set the {model} of {myCar} to "Model Y"
    
    # Or in a more concise way, the AI will understand your intent
    create an object {customer} with properties: "name" is "Li Ming", "age" is 24, "city" is "Shanghai"
  • 访问对象属性Accessing Object Properties: 可以直接在大括号中使用自然语言访问到属性值,或者使用更接近传统编程的点 . 操作符。You can access property values using natural language within curly braces, or by using the more traditional dot . operator.

    告诉用户 "我的汽车颜色是 {我的汽车的颜色}"
    如果 {客户的年龄} 大于 18: # 假设{客户}是一个前面定义的对象
        告诉用户 "{客户的姓名}是成年人。"
    
    # 或者使用{变量名.属性名}的方式
    告诉用户 "我的汽车颜色是:{我的汽车.颜色},品牌是{我的汽车.品牌},型号是{我的汽车.型号}"tell user "My car's color is {the color of myCar}"
    if {the age of customer} is greater than 18: # Assuming {customer} is a previously defined object
        tell user "{the name of customer} is an adult."
    
    # Or using the {variable.property} style
    tell user "My car's color is: {myCar.color}, brand is {myCar.brand}, and model is {myCar.model}"

列表 (List) List

列表是一系列有序的基本类型元素或对象。 A list is an ordered series of basic type elements or objects.

# 创建列表
将列表 {"苹果", "香蕉", "橙子"} 记为 {水果列表}
询问AI,输入是"目前人工智能领域的上市公司有哪些?",输出公司名称列表,记为{公司列表} # {公司列表} 是一个文本列表

# 访问列表元素(AI 会智能理解)
获取 {水果列表} 的第一个,记为{水果1}
告诉用户 "我最喜欢的水果是:{水果1}"
获取 {公司列表} 中元素的数量,记为{公司数量}
告诉用户 "AI领域上市公司大约有 {公司数量} 家。"# Create a list
record the list {"Apple", "Banana", "Orange"} as {fruitList}
ask AI, input is "What are the publicly traded companies in AI?", output a list of company names, record as {companyList} # {companyList} is a list of text

# Access list elements (AI will understand intelligently)
get the first item of {fruitList}, record as {fruit1}
tell user "My favorite fruit is: {fruit1}"
get the number of elements in {companyList}, record as {companyCount}
tell user "There are approximately {companyCount} publicly traded AI companies."

数据表 (Table) Table

数据表类似于电子表格,包含行和列。数据表可以看作是由多个结构相同的对象组成的列表。表中的每一行对应一个对象,每一列对应对象的一个属性。你可以创建数据表、添加、删除、修改数据表中的数据、将数据表从文件导入或导出到文件等。 A table is similar to a spreadsheet, containing rows and columns. A table can be seen as a list of objects with the same structure. Each row in the table corresponds to an object, and each column corresponds to a property of the object. You can create tables, add, delete, modify data in tables, and import/export tables from/to files.

# 创建数据表
建立一个空的数据表,包含 "姓名"、"部门"、"工号" 列,记为 {员工信息表}

# 添加一行 (可以理解为添加一个符合结构的对象)
创建一个对象 {新员工A},包含属性 "姓名"是"张三","部门"是"技术部","工号"是"T001"
将 {新员工A} 作为新行添加到 {员工信息表}

# 添加一行内容 (更简洁的方式)
将一行数据 {"姓名":"小明", "部门":"市场部", "工号":"M023"} 添加到 {员工信息表}

# 从文件加载数据到数据表
读取表格文件 "外部员工数据.xlsx" 的内容,存入新的数据表 {外部员工表}

# 保存数据表到文件
将{员工信息表}保存到文件,文件名为"员工信息.xlsx"# Create a table
create an empty table with columns "Name", "Department", "ID", record as {employeeInfoTable}

# Add a row (can be seen as adding a structured object)
create an object {newEmployeeA} with properties "Name" is "Zhang San", "Department" is "Tech", "ID" is "T001"
add {newEmployeeA} as a new row to {employeeInfoTable}

# Add a row of data (more concise way)
add a row of data {"Name":"Xiao Ming", "Department":"Marketing", "ID":"M023"} to {employeeInfoTable}

# Load data from a file into a table
read the content of the spreadsheet file "external_employee_data.xlsx", store in a new table {externalEmployeeTable}

# Save table to a file
save {employeeInfoTable} to a file named "employee_info.xlsx"

数据处理 Data Processing

RuyiX 集成了AI大模型能力,在数据处理方面非常强大。你只需要描述你的处理需求,即可完成各种复杂的数据处理操作。 RuyiX integrates the capabilities of large AI models, making it very powerful for data processing. You just need to describe your processing needs to perform various complex data operations.

  • 筛选Filter:
    从{公司数据表}中筛选出所有“市值”(单位:亿)大于100的公司记录,结果记为{大型公司表}from {companyDataTable}, filter all records where "Market Cap" (unit: 100M) is greater than 100, record result as {largeCapCompanyTable}
  • 提取Extract:
    获取{公司数据表}中的“国家”列,去重后记为{国家名称列表}get the "Country" column from {companyDataTable}, remove duplicates, record as {countryNameList}
  • 汇总Summarize:
    计算{公司数据表}中所有“国家”属性为“中国”的公司的“市值”总和,记为{中国公司总市值}calculate the sum of "Market Cap" for all companies where "Country" is "China" in {companyDataTable}, record as {chinaTotalMarketCap}
  • 排序Sort:
    将{公司数据表}按“市值”列的值从大到小排序sort {companyDataTable} by the "Market Cap" column in descending order
  • 合并Merge:
    将{国内销售表}和{海外销售表}两个数据表按“产品ID”列合并,记为{全球销售总表}merge the {domesticSalesTable} and {overseasSalesTable} tables on the "ProductID" column, record as {globalSalesTable}
  • 计算Calculate:
    将{公司数据表}中的“市值”除以“员工数量”,增加为“人均市值”列in {companyDataTable}, divide "Market Cap" by "Employee Count" and add it as a new column "Market Cap Per Employee"

对于图像类数据,也有很多内置的处理操作可以执行: For Image data, many built-in processing operations can also be performed:

# 例子1
拍照,记为 {原始照片}
调整 {原始照片} 的尺寸为宽度500像素,高度自动,记为 {调整后照片}
将 {调整后照片} 转换为灰度图像,记为 {灰度照片}
询问AI,输入 "{原始照片} 给这个照片配一个10个字以内的标题",记为 {照片标题}
将 {灰度照片} 保存到文件,文件名是 "{照片标题}.jpg"# Example 1
take a photo, record as {originalPhoto}
resize {originalPhoto} to a width of 500 pixels, height auto, record as {resizedPhoto}
convert {resizedPhoto} to a grayscale image, record as {grayscalePhoto}
ask AI, input "{originalPhoto} give this photo a title within 10 words", record as {photoTitle}
save {grayscalePhoto} to a file named "{photoTitle}.jpg"
# 例子2
读取图片文件 "风景.jpg",记为 {风景照片}
询问AI,输入 "给这张照片 {风景照片} 应用复古滤镜效果",输出处理后的图像,记为 {复古风景照片}
询问AI,输入 "{风景照片} 给这张照片配诗",输出文字,记为 {照片配诗}
将 {复古风景照片} 发给用户
告诉用户 "这是你照片的配诗:{照片配诗}"# Example 2
read image file "landscape.jpg", record as {landscapePhoto}
ask AI, input "apply a vintage filter effect to this photo {landscapePhoto}", output the processed image, record as {vintageLandscapePhoto}
ask AI, input "{landscapePhoto} write a poem for this photo", output text, record as {photoPoem}
send {vintageLandscapePhoto} to user
tell user "Here is the poem for your photo: {photoPoem}"

流程控制 Control Flow

代码默认是一行一行顺序执行的,但你可以通过流程控制语法,改变代码的执行流程。 By default, code executes line by line in sequence, but you can change the execution flow using control flow syntax.

循环 Loops

当需要对一组项目中的每一个重复执行相同操作时,可以使用循环。一个循环包括循环条件、循环内容两部分。循环内容的代码通常需要缩进(即在每行循环内容代码前面留一些空格),以表示这些操作是循环内的一部分。RuyiX 的 AI 解释器对于缩进有一定容错性,但良好缩进有助于可读性和准确性。 When you need to repeat the same operation for each item in a set, you can use a loop. A loop consists of a condition and a body. The code in the loop body is usually indented (i.e., has some spaces at the beginning of the line) to indicate it is part of the loop. RuyiX's AI interpreter has some tolerance for indentation, but good indentation improves readability and accuracy.

# 可以指定循环次数进行循环
创建一个列表,名为{人员名单}
重复执行 5 次:
    告诉用户 "这是第 {循环当前次数} 次循环!" # {循环当前次数} 是一个特殊变量,从1开始
    询问用户 "请输入第{循环当前次数}个人名",获取用户回答,插入{人员名单}列表
将 {人员名单} 保存到文件,文件名是 "名单"

# 也可以按照时间循环
每隔5分钟,执行:
    告诉用户 "当前时间是{当前时间},这是第{循环当前次数}次问好!"

# 遍历{数据集合}中的每一个{单个项目变量名}
将列表 {"苹果派", "香蕉船", "橙汁"} 记为 {甜点菜单}
遍历{甜点菜单}中的每一个甜点,记为{当前甜点}
    告诉用户 "我们有售:{当前甜点}"# Loop for a specific number of times
create a list named {nameList}
repeat 5 times:
    tell user "This is loop iteration number {currentLoopIndex}!" # {currentLoopIndex} is a special variable starting from 1
    ask user "Please enter the {currentLoopIndex}-th name", get user response, insert into {nameList}
save {nameList} to a file named "names"

# Can also loop based on time
every 5 minutes, execute:
    tell user "The current time is {currentTime}, this is greeting number {currentLoopIndex}!"

# Iterate over each {item} in a {collection}
record the list {"Apple Pie", "Banana Split", "Orange Juice"} as {dessertMenu}
for each dessert in {dessertMenu}, record as {currentDessert}:
    tell user "We have: {currentDessert}"

条件分支 Conditional Branches

当程序需要根据不同的情况执行不同的操作时,使用条件分支。程序根据条件表达式的判定情况,决定执行哪一条分支。条件表达式一般是一个判断,例如 {市值}小于100亿{医院列表}是空的 等。 When a program needs to perform different actions based on different situations, use conditional branches. The program decides which branch to execute based on the evaluation of a conditional expression. A conditional expression is typically a comparison, like {marketCap} is less than 10 billion or {hospitalList} is empty.

基本格式Basic Format:

如果{条件1}: 
    ... (条件1成立时执行)
否则如果{条件2}:    # 可选
    ... (条件1不成立,但条件2成立时执行)
否则:              # 可选
    ... (条件1和条件2都不成立时执行)if {condition1}: 
    ... (execute when condition1 is true)
else if {condition2}:    # optional
    ... (execute when condition1 is false but condition2 is true)
else:              # optional
    ... (execute when neither condition1 nor condition2 is true)

例子Example:

# 例子1
询问用户"请输入你的年龄",获取用户回答,记为{用户年龄}
如果 {用户年龄} 小于 18:
    告诉用户 "你是未成年人。"
否则如果 {用户年龄} 大于等于 18 并且 {用户年龄} 小于 60:
    告诉用户 "你是成年人。"
否则:
    告诉用户 "你已步入老年。"

# 例子2
询问AI,输入是 "今天天气怎么样?",输出天气描述,记为 {天气情况}
如果 {天气情况} 包含 "雨":
    告诉用户 "出门请记得带伞。"
否则:
    告诉用户 "今天天气不错!"# Example 1
ask user "Please enter your age", get user response, record as {userAge}
if {userAge} is less than 18:
    tell user "You are a minor."
else if {userAge} is greater than or equal to 18 and {userAge} is less than 60:
    tell user "You are an adult."
else:
    tell user "You are a senior."

# Example 2
ask AI, input is "What's the weather like today?", output weather description, record as {weatherCondition}
if {weatherCondition} contains "rain":
    tell user "Remember to bring an umbrella when you go out."
else:
    tell user "The weather is nice today!"

任务分解(函数) Task Decomposition (Functions)

在 RuyiX 中,你可以将一组常用的操作定义为一个“任务”,这类似于传统编程语言中的“函数”或“子程序”。这样做可以使你的主流程更简洁,也方便代码复用。 In RuyiX, you can define a set of commonly used operations as a "task," which is similar to a "function" or "subroutine" in traditional programming languages. This makes your main workflow cleaner and facilitates code reuse.

  • 定义任务Defining a Task: 使用 定义一个任务,名为"{任务名称}" 开始。任务可以有输入参数和输出(返回值)。Start with define a task named "{taskName}". Tasks can have input parameters and outputs (return values).

    # 定义一个任务,用于向特定用户问好
    定义一个任务,名为 "定制问候语"
        任务输入: {用户名} (类型为文本)
        将 "你好,{用户名}!欢迎使用RuyiX。" 记为 {问候语文本}
        告诉用户 {问候语文本}
        # 这个任务没有明确的返回值
    
    # 定义一个任务,用于计算两个数的和并返回结果
    定义一个任务,名为 "计算两数之和"
        任务输入: {数字一} (数字类型) 和 {数字二} (数字类型)
        将 {数字一} 加上 {数字二} 的结果记为 {计算结果}
        任务返回 {计算结果} # 任务结束,并输出{计算结果}# Define a task to greet a specific user
    define a task named "customGreeting"
        task input: {userName} (type is text)
        record "Hello, {userName}! Welcome to RuyiX." as {greetingText}
        tell user {greetingText}
        # This task has no explicit return value
    
    # Define a task to calculate the sum of two numbers and return the result
    define a task named "calculateSum"
        task input: {numberOne} (number type) and {numberTwo} (number type)
        record the result of {numberOne} plus {numberTwo} as {calculationResult}
        task returns {calculationResult} # Task ends and outputs {calculationResult}
  • 调用任务Calling a Task: 使用 执行任务 "{任务名称}",并提供必要的输入参数,(可选)接收输出结果。Use execute task "{taskName}", provide the necessary input parameters, and (optionally) receive the output result.

    # 调用问候任务
    执行任务 "定制问候语",{用户名} 为 "张三"
    
    # 调用计算任务并获取输出
    执行任务 "计算两数之和",{数字一} 是 10,{数字二} 是 25,输出结果记为 {总和}
    告诉用户 "10 + 25 的结果是:{总和}"# Call the greeting task
    execute task "customGreeting", with {userName} as "Zhang San"
    
    # Call the calculation task and get the output
    execute task "calculateSum", with {numberOne} as 10 and {numberTwo} as 25, record output as {totalSum}
    tell user "The result of 10 + 25 is: {totalSum}"

利用函数(任务),你可以将一个复杂的大任务分解成一系列更小、更易于管理和描述的子任务,进而逐个完成。这个分解任务的能力实际上就是架构和逻辑的能力,需要精心设计,使用变量在流程的不同阶段传递信息,同时保证程序总体结构的精简可读性。 By using functions (tasks), you can decompose a large, complex task into a series of smaller, more manageable sub-tasks to be completed one by one. This ability to decompose tasks is essentially the skill of architecture and logic, requiring careful design, using variables to pass information at different stages of the flow, while ensuring the overall program structure is concise and readable.

6. RuyiX Studio 教程 6. RuyiX Studio Tutorial

RuyiX Studio 是 RuyiX 的官方开发工具,提供了丰富的功能和教程,帮助你快速上手 RuyiX。 RuyiX Studio is the official development tool for RuyiX, providing rich features and tutorials to help you get started with RuyiX quickly.

添加设备 Adding Devices

  1. RuyiX Studio 可以控制外置手机、内置浏览器、电脑这三类设备 RuyiX Studio can control three types of devices: external phones, built-in browsers, and computers
  2. 对于手机设备,需要使用 USB 将其连接到电脑,并且启动该手机的 USB 调试功能,成功后会被 RuyiX Studio 自动识别 For phone devices, you need to connect them to the computer via USB and enable USB debugging on the phone. Once successful, they will be automatically detected by RuyiX Studio
  3. 在 RuyiX Studio 右侧的 “设备列表” 处的 “可添加设备” 的地方,可以快捷添加已经识别到的手机和任意多的内置浏览器设备 In the "Available Devices" section under "Device List" on the right side of RuyiX Studio, you can quickly add detected phones and any number of built-in browser devices

启动执行 Starting Execution

  1. 新建项目或载入创建好的项目 Create a new project or load an existing project
  2. 点击项目名称右侧的 ➕ 号,创建一个新的任务 Click the ➕ button to the right of the project name to create a new task
  3. 点击任务名称左侧的执行按钮 Click the execute button to the left of the task name
  4. 为该任务中所使用的设备配置已添加的设备 Configure the added devices for the devices used in the task
  5. 点击启动执行 Click to start execution

查看设备执行过程 Viewing Device Execution Process

  1. 界面中间部分下方的 “执行日志” 和 “变量” 展示了任务执行过程中的日志信息等 The "Execution Log" and "Variables" sections at the bottom center of the interface display log information during task execution
  2. 点击设备列表处的设备卡片可以查看设备投屏/截图 Click on a device card in the device list to view the device screen mirroring/screenshot
  3. 点击右上角的执行设备预览按钮,可以查看所有并行执行任务的设备/日志 Click the execution device preview button in the upper right corner to view all devices/logs for parallel task execution

7. 了解更多 7. Learn More

了解更多: 技术报告, GitHub Learn more: Technical Report, GitHub