function-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseFunction Creator
函数创建工具
Create new Wavelength functions or modify existing ones on a Datex Studio branch.
在Datex Studio分支上创建新的Wavelength函数或修改现有函数。
References
参考文档
- ../shared/branch-setup.md -- Branch & connection selection (shared across skills)
- references/command-syntax.md -- All commands with examples
dxs function - references/flag-guide.md -- When/why/how for each flag
- references/code-patterns.md -- Common patterns for function code
- ../shared/context-navigation.md -- How to retrieve & navigate designer context responses
- ../shared/branch-setup.md -- 分支与连接选择(全技能共享)
- references/command-syntax.md -- 所有命令及示例
dxs function - references/flag-guide.md -- 各参数的使用场景、原因及方法
- references/code-patterns.md -- 函数代码的常见模式
- ../shared/context-navigation.md -- 如何获取及导航设计器上下文响应
Dependencies
依赖技能
- skill — invoked to produce a requirements brief if one doesn't already exist in the conversation context
requirements-gathering - skill — invoked when modifying input/output parameters of an existing function
impact-analysis
- 技能 — 若对话上下文中不存在需求概要,则调用该技能生成需求概要
requirements-gathering - 技能 — 修改现有函数的输入/输出参数时调用
impact-analysis
Workflow
工作流
[Phase 1: Setup + Requirements]
Follow branch-setup.md for branch/connection selection
|
[requirements brief in context?]
+-----+-----+
| |
YES NO
| |
use it invoke `requirements-gathering` skill
| |
+-----+------+
|
[determine intent: create or modify?]
|
+-----+-----+
| |
CREATE MODIFY
| |
determine dxs function get <ref> --branch <id>
ref name extract code from stepConfig.executeCodeConfig.code
+ params write to temp .ts file
| |
+------+------+
|
[Phase 2: Intellisense]
dxs function context <config.json> --branch <id>
|
[Phase 3: Signature Safety -- modify only]
If input/output params are changing:
invoke impact-analysis skill
only continue if no callers or user approves
|
[Phase 4: Code]
Write or update TypeScript code in temp .ts file
|
[Phase 5: Generate + Validate + Upload]
dxs function generate ... --code-file <file.ts> -o <config.json>
dxs function validate <config.json> --branch <id>
dxs function upsert <config.json> --branch <id>[阶段1:设置 + 需求梳理]
遵循branch-setup.md进行分支/连接选择
|
[上下文中是否有需求概要?]
+-----+-----+
| |
是 否
| |
使用现有概要 调用`requirements-gathering`技能
| |
+-----+------+
|
[确定意图:创建还是修改?]
|
+-----+-----+
| |
创建 修改
| |
确定引用名称 dxs function get <ref> --branch <id>
+ 参数 从stepConfig.executeCodeConfig.code中提取代码
| |
+------+------+
|
[阶段2:智能提示]
dxs function context <config.json> --branch <id>
|
[阶段3:签名安全性 — 仅修改场景]
若输入/输出参数发生变化:
调用impact-analysis技能
仅在无调用者或用户批准后继续
|
[阶段4:代码编写]
在临时.ts文件中编写或更新TypeScript代码
|
[阶段5:生成 + 验证 + 上传]
dxs function generate ... --code-file <file.ts> -o <config.json>
dxs function validate <config.json> --branch <id>
dxs function upsert <config.json> --branch <id>Phase Details
阶段详情
Phase 1: Setup + Requirements
阶段1:设置 + 需求梳理
- Follow branch-setup.md for branch/connection selection
- Check whether a requirements brief already exists in the conversation context (produced by or another calling skill)
requirements-gathering- Requirements brief exists — use it. The brief provides the intent, expected inputs/outputs, and business rules.
- No requirements brief exists — invoke the skill first. This ensures the agent understands what the function should do (create) or what changes are needed (modify) before touching code.
requirements-gathering
- Determine intent: create new or modify existing?
Create flow (continued):
4. Determine reference name (valid JS identifier — must end with suffix, e.g., , )
5. Determine input/output parameters from the requirements brief
_flowsum_flowprocess_order_flowModify flow (continued):
4. Fetch the existing function:
5. Extract the current code from in the response JSON
6. Write the code to a temporary file for editing
7. Note the current input/output parameters for signature change detection
dxs function get <ref_name> --branch <id>stepConfig.executeCodeConfig.code.ts- 遵循branch-setup.md进行分支/连接选择
- 检查对话上下文中是否已存在需求概要(由或其他调用技能生成)
requirements-gathering- 存在需求概要 — 使用该概要。概要包含意图、预期输入/输出及业务规则。
- 无需求概要 — 先调用技能。这能确保Agent在接触代码前,理解函数应实现的功能(创建场景)或所需修改内容(修改场景)。
requirements-gathering
- 确定意图:创建新函数还是修改现有函数?
创建流程(续):
4. 确定引用名称(合法的JS标识符 — 必须以后缀结尾,例如、)
5. 从需求概要中确定输入/输出参数
_flowsum_flowprocess_order_flow修改流程(续):
4. 获取现有函数:
5. 从响应JSON的中提取当前代码
6. 将代码写入临时文件以便编辑
7. 记录当前输入/输出参数,用于检测签名变更
dxs function get <ref_name> --branch <id>stepConfig.executeCodeConfig.code.tsPhase 2: Intellisense
阶段2:智能提示
See context-navigation.md for the full guide on retrieving and reading context responses, including the backend vs frontend symbol filtering rules.
For create: Run with a placeholder code file (e.g., containing just ), then run context on the resulting JSON to get the type system before writing actual code.
dxs function generate --code-file <placeholder.ts> -r <name> -t "<title>" -d "<desc>" --in-param <params> --out-param <params> -o <config.json>// placeholderFor modify: The fetched config JSON from can be saved to a file and used directly with the context command.
dxs function getRetrieval:
bash
dxs -O json function context <config.json> --branch <id>Read to determine which -symbols are actually available — not every symbol in is usable in backend function code. Look up type definitions in for imported symbols only. The provides ambient utilities (, enums).
defaultContext.imports$appContext.varsappContext.textglobal_context$utils查看context-navigation.md获取完整的上下文响应获取与阅读指南,包括后端与前端符号过滤规则。
创建场景: 运行,使用占位符代码文件(例如仅包含),然后对生成的JSON运行context命令,在编写实际代码前获取类型系统信息。
dxs function generate --code-file <placeholder.ts> -r <name> -t "<title>" -d "<desc>" --in-param <params> --out-param <params> -o <config.json>// placeholder修改场景: 从获取的配置JSON可保存到文件,直接用于context命令。
dxs function get获取命令:
bash
dxs -O json function context <config.json> --branch <id>查看确定可用的符号 — 并非中的所有符号都可用于后端函数代码。仅查看导入符号在中的类型定义。提供环境工具(、枚举)。
defaultContext.imports$appContext.varsappContext.textglobal_context$utilsPhase 3: Signature Safety (modify only)
阶段3:签名安全性(仅修改场景)
If the modification changes input or output parameters:
- Invoke the impact-analysis skill with the function's reference name
- If callers exist, present them and ask the user whether to proceed
- If proceeding, the agent must update all affected callers after modifying the function
若修改涉及输入或输出参数变更:
- 使用函数的引用名称调用impact-analysis技能
- 若存在调用者,列出调用者并询问用户是否继续
- 若继续,Agent必须在修改函数后更新所有受影响的调用者
Phase 4: Code
阶段4:代码编写
Write or update the TypeScript code in a temp file. Use the intellisense data from Phase 2 to:
.ts- Reference other functions, datasources, reports, etc. with correct types
- Use and
$flow.inParams.*correctly$flow.outParams.* - Access runtime services (,
$utils, etc.)$services
See code-patterns.md for common patterns.
在临时文件中编写或更新TypeScript代码。使用阶段2的智能提示数据:
.ts- 以正确类型引用其他函数、数据源、报表等
- 正确使用和
$flow.inParams.*$flow.outParams.* - 访问运行时服务(、
$utils等)$services
查看code-patterns.md获取常见模式。
Phase 5: Generate, Validate, Upload
阶段5:生成、验证、上传
bash
undefinedbash
undefinedGenerate the config (local file operation — does not take --branch)
生成配置(本地文件操作 — 无需--branch参数)
dxs function generate
--code-file <file.ts>
-r <reference_name>
-t "<title>"
-d "<description>"
--in-param <name>:<type>
--out-param <name>:<type>
-o <config.json>
--code-file <file.ts>
-r <reference_name>
-t "<title>"
-d "<description>"
--in-param <name>:<type>
--out-param <name>:<type>
-o <config.json>
dxs function generate
--code-file <file.ts>
-r <reference_name>
-t "<title>"
-d "<description>"
--in-param <name>:<type>
--out-param <name>:<type>
-o <config.json>
--code-file <file.ts>
-r <reference_name>
-t "<title>"
-d "<description>"
--in-param <name>:<type>
--out-param <name>:<type>
-o <config.json>
Validate
验证
dxs function validate <config.json> --branch <id>
dxs function validate <config.json> --branch <id>
Upload
上传
dxs function upsert <config.json> --branch <id>
undefineddxs function upsert <config.json> --branch <id>
undefinedNaming Convention
命名规范
- Reference names must be valid JS identifiers (start with letter//
_, no spaces/hyphens)$ - Must end with suffix (e.g.,
_flow,sum_flow,validate_order_flow)boolean_array_to_mask_flow - Title () is a human-readable display name — can differ from reference name
-t
- 引用名称必须是合法的JS标识符(以字母//
_开头,无空格/连字符)$ - 必须以后缀结尾(例如
_flow、sum_flow、validate_order_flow)boolean_array_to_mask_flow - 标题()是人类可读的显示名称 — 可与引用名称不同
-t
Common Mistakes
常见错误
| Mistake | Fix |
|---|---|
Using | Assign to |
Wrong scoping on | Module code requires module prefix ( |
| Changing params without checking callers | Always invoke impact-analysis skill first when modifying input/output params |
| Guessing available services from memory | Always run |
Referencing a frontend-only symbol ( | Functions are backend-only. If a symbol is not in |
Using | The expression variable is |
| Code file exceeding 512 KB | Split logic into multiple functions or extract helpers |
| 错误 | 修复方法 |
|---|---|
使用 | 改为赋值给 |
| 模块代码需要模块前缀( |
| 修改参数前未检查调用者 | 修改输入/输出参数时,务必先调用impact-analysis技能 |
| 凭记忆猜测可用服务 | 始终运行 |
引用仅前端可用的符号( | 函数仅运行于后端。若符号不在 |
使用 | Wavelength中的表达式变量为 |
| 代码文件超过512 KB | 将逻辑拆分为多个函数或提取辅助函数 |