creating-taubyte-resources
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreating Taubyte Resources
创建Taubyte资源
When to use
使用场景
- "Add a domain / website / library / function / database / storage / messaging / service"
- "Create an application for app-scoped resources"
- Building out a project after
bootstrapping-taubyte-projects - Reviewing or scripting non-interactive resource creation
- "添加域名/网站/库/函数/数据库/存储/消息服务/服务"
- "为应用范围的资源创建应用"
- 在(初始化Taubyte项目)之后构建项目
bootstrapping-taubyte-projects - 审阅或编写非交互式资源创建脚本
Intent-first resource planning (agent behavior)
基于意图的资源规划(代理行为)
When a user asks to "create an app" (not just a resource), first infer the minimum Taubyte resource set required to make that app real, then create those resources with correct scope + wiring.
General heuristics:
- Web app UI → create a website (project-scoped if needed or mentioned) + a domain (project-scoped if mentioned) and attach the site to the domain and path(s).
- Persistent data → create a database (application-scoped if needed). create storage if needed ; choose only when implied by the intent.
- UI ↔ data/API glue → create at least one HTTP function that reads/writes the database and returns JSON for the website to consume. Attach the function to the same domain when a same-origin pattern is implied.
/api/...
Rules while doing this:
- Prefer the fewest resources that satisfy the intent, but do not omit the glue (e.g. database without a function is usually not an "app").
- Keep scopes correct: database/storage/messaging/service are application-scoped if needed or mentioned; website/domain are project-scoped if needed or mentioned.
- Use match strings as stable wiring keys (database , messaging channel, service protocol) and keep them consistent with Go calls and triggers (see enforcing-taubyte-constraints rule 16).
match
当用户要求“创建应用”(而非仅单个资源)时,首先推断让该应用可用所需的最小Taubyte资源集合,然后以正确的范围和关联方式创建这些资源。
通用启发式规则:
- Web应用UI → 创建网站(若有需要或提及则设为项目范围)+ 域名(若提及则设为项目范围),并将网站关联到域名及对应路径。
- 持久化数据 → 创建数据库(若有需要则设为应用范围)。若有需要则创建存储;仅当意图明确暗示时才选择创建。
- UI ↔ 数据/API衔接层 → 至少创建一个HTTP函数,用于读写数据库并返回JSON供网站调用。当暗示同源模式时,将函数关联到同一域名。
/api/...
执行时需遵循的规则:
- 优先选择能满足意图的最少资源,但不可省略衔接层(例如,仅创建数据库通常不能构成一个“应用”)。
- 保持范围正确:数据库/存储/消息服务/服务若有需要或提及则为应用范围;网站/域名若有需要或提及则为项目范围。
- 使用匹配字符串作为稳定的关联键(数据库、消息通道、服务协议),并确保其与Go调用和触发器一致(参见enforcing-taubyte-constraints规则16)。
match
Preconditions
前置条件
- shows the correct Project (and the right Application, or none, depending on scope) — see selecting-taubyte-context.
tau --defaults --yes json current - Project has been created/imported — see bootstrapping-taubyte-projects.
- 显示正确的项目(以及对应的应用,或无应用,取决于范围)——参见selecting-taubyte-context。
tau --defaults --yes json current - 项目已创建/导入——参见bootstrapping-taubyte-projects。
Scope rule (project vs application)
范围规则(项目 vs 应用)
| Resource | Scope |
|---|---|
| Project |
| Project |
| Project |
| Project (default) or Application |
| Project (creates the application) |
| Application |
| Application |
| Application |
| Application |
For app-scoped resources: first; for project-scoped, ensure no application is selected ().
tau --defaults --yes select application --name <app>tau --defaults --yes clear application| 资源 | 范围 |
|---|---|
| 项目 |
| 项目 |
| 项目 |
| 项目(默认)或应用 |
| 项目(用于创建应用) |
| 应用 |
| 应用 |
| 应用 |
| 应用 |
对于应用范围的资源:先执行;对于项目范围的资源,确保未选择任何应用(执行)。
tau --defaults --yes select application --name <app>tau --defaults --yes clear applicationDomains
域名
Generated FQDN (Dream / quick demos)
生成FQDN(Dream/快速演示)
bash
tau --defaults --yes new domain <domain_name> \
--generated-fqdn \
--type auto \
--description "<desc>"Result: a random FQDN of the form .
<random>.<universe>.localtaubash
tau --defaults --yes new domain <domain_name> \
--generated-fqdn \
--type auto \
--description "<desc>"结果:生成一个格式为的随机FQDN。
<random>.<universe>.localtauCustom FQDN (remote, controlled hostname)
自定义FQDN(远程、可控主机名)
bash
tau --defaults --yes new domain <domain_name> \
--fqdn <fqdn> \
--type auto \
--description "<desc>"bash
tau --defaults --yes new domain <domain_name> \
--fqdn <fqdn> \
--type auto \
--description "<desc>"Some remotes: *.gen.<cloud_fqdn>
and the project CID suffix
*.gen.<cloud_fqdn>部分远程主机:*.gen.<cloud_fqdn>
与项目CID后缀
*.gen.<cloud_fqdn>Host policy can require that a generated-style hostname under embed the last eight characters of the project’s canonical CID from → . Compute: . Omitting this substring breaks config-compile with errors like . When replacing a domain for this reason, reuse the same logical domain resource name (e.g. ) if you can — so on websites/functions stay valid without mass YAML edits.
*.gen.<cloud>tau query project <name> --jsonidpython3 -c "s='<cid>'; print(s[-8:])"does not contain last 8 of project idgenerateddomains:主机策略可能要求**下的生成式主机名必须嵌入项目规范CID的最后8个字符,该CID可通过中的字段获取。计算方式:。若省略该子串,会导致配置编译失败,错误信息类似。若因此需要替换域名,尽可能复用相同的逻辑域名资源名称**(例如)——这样网站/函数上的****配置无需大量YAML编辑即可保持有效。
*.gen.<cloud>tau query project <name> --jsonidpython3 -c "s='<cid>'; print(s[-8:])"does not contain last 8 of project idgenerateddomains:Forbidden flag
禁用标志
Never pass (or ) — it's not supported by policy. Use alone or use with a controlled hostname.
--generated-fqdn-prefix--g-prefix--generated-fqdn--fqdn切勿传递(或)——该参数不受策略支持。仅使用或搭配可控主机名使用。
--generated-fqdn-prefix--g-prefix--generated-fqdn--fqdnWebsites
网站
bash
tau --defaults --yes new website <site_name> \
--domains <domain_name> \
--paths / \
--template empty \
--generate-repository \
--repository-name tb_code_<project>_<site_name> \
--private \
--no-embed-token \
--branch main
tau --defaults --yes import website <site_name>
tau --defaults --yes list websitesNotes:
- creates a separate GitHub repo for the website; pair with a deterministic
--generate-repository(recommended:--repository-name).tb_code_<project>_<site> - After creation, run so the local clone appears under
import website.<project>/websites/<repo>/ - Author build content under writing to
.taubyte/build.sh— see building-taubyte-websites./out
To attach an existing website repo instead of generating one, use or and drop .
--repository-name <fullname>--repository-id <id>--generate-repositorybash
tau --defaults --yes new website <site_name> \
--domains <domain_name> \
--paths / \
--template empty \
--generate-repository \
--repository-name tb_code_<project>_<site_name> \
--private \
--no-embed-token \
--branch main
tau --defaults --yes import website <site_name>
tau --defaults --yes list websites注意事项:
- 会为网站创建一个独立的GitHub仓库;建议搭配确定性的
--generate-repository(推荐格式:--repository-name)。tb_code_<project>_<site> - 创建完成后,运行使本地克隆出现在
import website目录下。<project>/websites/<repo>/ - 在中编写构建内容并输出到
.taubyte/build.sh目录——参见building-taubyte-websites。/out
若要关联现有网站仓库而非生成新仓库,使用或并移除参数。
--repository-name <fullname>--repository-id <id>--generate-repositoryLibraries
库
bash
tau --defaults --yes new library <lib_name> \
--path /libraries/<lib_name> \
--template empty \
--generate-repository \
--repository-name tb_code_<project>_<lib_name> \
--private \
--no-embed-token \
--branch main
tau --defaults --yes import library <lib_name>
tau --defaults --yes list libraries--pathbash
tau --defaults --yes new library <lib_name> \
--path /libraries/<lib_name> \
--template empty \
--generate-repository \
--repository-name tb_code_<project>_<lib_name> \
--private \
--no-embed-token \
--branch main
tau --defaults --yes import library <lib_name>
tau --defaults --yes list libraries--pathHTTP functions
HTTP函数
bash
tau --defaults --yes new function <fn_name> \
--type http \
--method GET \
--paths /<path> \
--domains <domain_name> \
--language Go \
--source . \
--memory 64MB \
--timeout 30s \
--call <ExportedHandler> \
--template emptyOr use a known-good ping_pong template:
bash
tau --defaults --yes new function ping \
--type http --method GET --paths /ping \
--generate-domain \
--language Go --source . \
--memory 64MB --timeout 1s \
--call ping \
--template ping_pong --use-templateFunction rules:
- One function per (path, method) — never comma-separated methods.
- must equal a
--callsymbol in the source.//export <name> - For Go, edit the function root (next to
empty.go) — never create ago.modtree or hand-authorlib/.main.go
bash
tau --defaults --yes new function <fn_name> \
--type http \
--method GET \
--paths /<path> \
--domains <domain_name> \
--language Go \
--source . \
--memory 64MB \
--timeout 30s \
--call <ExportedHandler> \
--template empty或使用经过验证的ping_pong模板:
bash
tau --defaults --yes new function ping \
--type http --method GET --paths /ping \
--generate-domain \
--language Go --source . \
--memory 64MB --timeout 1s \
--call ping \
--template ping_pong --use-template函数规则:
- 每个(路径、方法)对应一个函数——切勿使用逗号分隔多个方法。
- 必须与源码中的
--call符号一致。//export <name> - 对于Go语言,编辑函数根目录下的(与
empty.go同级)——切勿创建go.mod目录或手动编写lib/。main.go
Applications
应用
bash
tau --defaults --yes new application <app_name> \
--description "<desc>"
tau --defaults --yes select application --name <app_name>
tau --defaults --yes list applicationsbash
tau --defaults --yes new application <app_name> \
--description "<desc>"
tau --defaults --yes select application --name <app_name>
tau --defaults --yes list applicationsDatabases (application-scoped)
数据库(应用范围)
bash
tau --defaults --yes new database <db_name> \
--match <matcher> \
--min 1 --max 2 \
--size 1GBConstraint observed: fails with . Use (or higher max).
--min 1 --max 1min(1) cannot be greater than max(1)--min 1 --max 2The value is the runtime key: Go code must call with the identical string (including any leading ).
--matchdatabase.New("<matcher>")/bash
tau --defaults --yes new database <db_name> \
--match <matcher> \
--min 1 --max 2 \
--size 1GB需遵守的约束:会失败,错误信息为。请使用(或更大的max值)。
--min 1 --max 1min(1) cannot be greater than max(1)--min 1 --max 2--match/database.New("<matcher>")Storage (application-scoped)
存储(应用范围)
bash
tau --defaults --yes new storage <storage_name> \
--match <matcher> \
--size 1GB \
--bucket Object \
--publicbash
tau --defaults --yes new storage <storage_name> \
--match <matcher> \
--size 1GB \
--bucket Object \
--publicMessaging (application-scoped)
消息服务(应用范围)
bash
tau --defaults --yes new messaging <msg_name> \
--match <channel_match> \
--mqtt --wsThe is the channel string. Producers in Go call 's , and PubSub-triggered functions set .
<channel_match>pubsub/nodeChannel("<channel_match>")trigger.channel: <channel_match>bash
tau --defaults --yes new messaging <msg_name> \
--match <channel_match> \
--mqtt --ws<channel_match>pubsub/nodeChannel("<channel_match>")trigger.channel: <channel_match>Services (application-scoped)
服务(应用范围)
bash
tau --defaults --yes new service <svc_name> \
--protocol /apiOn Git Bash / MSYS, prefix path-like flags with to avoid path mangling.
MSYS_NO_PATHCONV=1bash
tau --defaults --yes new service <svc_name> \
--protocol /api在Git Bash/MSYS中,需为类路径的标志添加前缀以避免路径被篡改。
MSYS_NO_PATHCONV=1Workflow checklist for a typical project
典型项目的工作流检查清单
Resource creation progress:
- [ ] Verify selection (tau --json current)
- [ ] Create domain (project scope)
- [ ] Create website + import (project scope)
- [ ] Create library + import (project scope)
- [ ] Create application
- [ ] Select application
- [ ] Create database / storage / messaging / service
- [ ] Create functions (HTTP at project scope, others at app scope as needed)
- [ ] tau clear application
- [ ] tau push project --config-only --message "..."
- [ ] Wait for config build success before pushing website/library code资源创建进度:
- [ ] 验证当前选择(tau --json current)
- [ ] 创建域名(项目范围)
- [ ] 创建网站并导入(项目范围)
- [ ] 创建库并导入(项目范围)
- [ ] 创建应用
- [ ] 选择应用
- [ ] 创建数据库/存储/消息服务/服务
- [ ] 创建函数(HTTP函数设为项目范围,其他函数按需设为应用范围)
- [ ] 执行tau clear application
- [ ] 执行tau push project --config-only --message "..."
- [ ] 等待配置构建成功后再推送网站/库代码Gotchas
常见陷阱
- Dream vs CLI vs remote WASM paths: with an application selected may scaffold under
tau new function ... --source .in your clone, while Dream or remote builders often expectcode/applications/<app>/functions/<fn>/(nocode/<app>/functions/<fn>/segment). A remote job may fail with couldn't findapplications/under.taubytewhile your tree still has.../<app>/functions/<fn>. Treat the path in the first failing build log as ground truth and move the function directory (and fix any relative references) so.../applications/<app>/functions/<fn>sits where the builder looks — do not guess a different layout..taubyte/ - Application bleed: forgetting causes later
tau clear applicationto land in the app instead of project scope.tau new domain|website|library - Matcher = runtime string: in YAML must equal the literal Go calls (
match,database.New("..."),pubsubnode.Channel("...")). Mismatched leadingtrigger.channelis a frequent cause of "open failed" / silent producers./ - Repo strategy must be explicit for websites/libraries — either with a deterministic
--generate-repository, or--repository-name/--repository-namefor an existing repo.--repository-id - Don't hand-edit domain YAML. Always use /
tau new domain/tau delete domain.tau query domain - Min/max on database: must be strictly less than
--min.--max
- Dream vs CLI vs 远程WASM路径差异:当已选择应用时,执行可能会在克隆仓库的**
tau new function ... --source .目录下生成脚手架,而Dream或远程构建器通常期望路径为code/applications/<app>/functions/<fn>/(无code/<app>/functions/<fn>/目录)。远程任务可能会失败,错误信息为couldn't findapplications/** under.taubyte,而本地目录结构仍为.../<app>/functions/<fn>。请以首次构建失败日志中的路径为准,移动函数目录(并修复所有相对引用),使.../applications/<app>/functions/<fn>位于构建器期望的位置——切勿猜测其他目录结构。.taubyte/ - 应用范围泄漏:忘记执行会导致后续的
tau clear application命令将资源创建在应用范围内而非项目范围内。tau new domain|website|library - 匹配符 = 运行时字符串:YAML中的必须与Go调用中的字面字符串完全一致(
match、database.New("...")、pubsubnode.Channel("..."))。前导trigger.channel不匹配是导致“打开失败”/生产者静默失败的常见原因。/ - 网站/库的仓库策略必须明确——要么使用搭配确定性的
--generate-repository,要么使用--repository-name/--repository-name关联现有仓库。--repository-id - 请勿手动编辑域名YAML。请始终使用/
tau new domain/tau delete domain进行操作。tau query domain - 数据库的min/max约束:必须严格小于
--min。--max
Related skills
相关技能
bootstrapping-taubyte-projectsselecting-taubyte-contextpushing-taubyte-projectsbuilding-taubyte-websitesverifying-taubyte-functions
bootstrapping-taubyte-projectsselecting-taubyte-contextpushing-taubyte-projectsbuilding-taubyte-websitesverifying-taubyte-functions