moda-automate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

moda-automate

moda-automate

<!-- moda:banner -->
PREREQUISITE — load
moda-core
once per session
(step-0, write contract, free/metered map). Already loaded? Skip ahead. If you cannot load it, the non-negotiables: run
moda doctor --json
before anything;
moda brand list
before creating; every write carries the latest revision — on
stale_revision
, re-read and retry once (it heals); send the canvas link the moment it exists; stuck or failed?
moda ask "<question>"
— free and fast, never guess.
<!-- /moda:banner -->
<!-- moda:banner -->
前提条件 —— 每个会话仅需加载一次
moda-core
(步骤0,编写合约,免费/计量映射)。已加载?请跳过。若无法加载,必须执行以下操作:先运行
moda doctor --json
;创建前运行
moda brand list
;每次写入操作需携带最新版本号——遇到
stale_revision
时,重新读取并重试一次即可恢复;画布链接生成后立即发送;遇到卡顿或失败?使用
moda ask "<问题>"
——免费且快速,切勿自行猜测。
<!-- /moda:banner -->

Say the architecture plainly, once

直白说明架构,仅此一次

Moda hosts no scheduler. Recurring Moda work is a scheduler you already have — cron, launchd, a systemd timer, a CI schedule — running Moda on a cadence.
  • Moda produces; your scheduler delivers. Nothing in Moda posts to a platform or sends mail. Each tick leaves a canvas link and an export file; the publishing step belongs to the host, and you say so before promising it.
  • The artifact still routes to its format skill. This skill owns the schedule and the unattended-run discipline; moda-social, moda-document, moda-chart and the rest own what each tick actually builds.
Moda本身不提供调度器。周期性Moda任务依赖你已有的调度器——cron、launchd、systemd定时器、CI调度——按周期运行Moda。
  • Moda负责生成;你的调度器负责交付。 Moda不会向平台发布内容或发送邮件。每次调度执行后会留下一个画布链接和导出文件;发布步骤由主机端负责,你需在承诺执行前明确这一点。
  • 产物仍会路由至对应的格式skill。 本skill负责调度和无人值守执行规则;moda-social、moda-document、moda-chart等其他skill负责实际生成每次调度的产物。

Make one run work unattended, then schedule it

先确保单次运行可无人值守,再进行调度

  1. Run it by hand end to end first. A schedule wrapped around a broken run fails quietly forever.
  2. Auth with no browser: the user mints a key at moda.app/cli/auth, and the scheduler gets it as
    MODA_API_KEY
    in its environment. (
    moda auth login --paste
    needs an interactive prompt, so it is not the unattended lane.) Never print, echo, log, or commit a key.
  3. Every command takes
    --json --no-input
    : it fails instead of prompting, and you decide from the JSON fields, not the human prose.
  4. Pin the workspace so the script carries no flags —
    .moda/context.json
    (load moda-context) for org, brand, and canvas.
  5. No browser verbs in a detached run:
    moda canvas open
    and its siblings are for a person at a keyboard.
  6. Writes to one canvas stay serial. A parallel batch shares one revision pin and loses outright.
undefined
  1. 先手动完整运行一次。如果调度包裹的是一个有问题的任务,它会一直静默失败。
  2. 无需浏览器的认证方式:用户在moda.app/cli/auth生成密钥,调度器通过环境变量
    MODA_API_KEY
    获取该密钥。(
    moda auth login --paste
    需要交互式提示,因此不适合无人值守场景。)切勿打印、回显、记录或提交密钥。
  3. 所有命令需添加
    --json --no-input
    参数:命令会直接失败而非弹出提示,你可通过JSON字段而非人类可读文本判断结果。
  4. 固定工作区,让脚本无需携带额外参数——通过
    .moda/context.json
    (加载moda-context)指定组织、品牌和画布。
  5. 脱离交互的运行中不要使用浏览器相关命令:
    moda canvas open
    及其同类命令仅供人工操作时使用。
  6. 对单个画布的写入操作需保持串行执行。并行批量操作会共享同一版本号并直接失败。
undefined

crontab — Mondays 08:00; the wrapper holds the steps, the environment holds the key

crontab — 每周一08:00执行;脚本包含执行步骤,环境变量存储密钥

0 8 * * 1 cd /srv/reports && ./moda-weekly.sh >> /var/log/moda-weekly.log 2>&1
undefined
0 8 * * 1 cd /srv/reports && ./moda-weekly.sh >> /var/log/moda-weekly.log 2>&1
undefined

Three shapes cover almost everything

三种模式覆盖绝大多数场景

ShapeEach tickWhy it wins
Refresh one canvas (weekly report)read the pinned canvas → edit → export → deliverthe link never changes, so anyone watching it just sees the update
New artifact per tick (weekly post set)instantiate the team template → author → exportmoda-templates keeps every week on the approved layout
Sync jobpull the source data → author → export where the delivery step looksModa never reaches into your systems; the fetch is yours
Whichever shape it is, load the format skill for the authoring half — this skill does not teach how to build the artifact.
模式每次执行操作优势
刷新单个画布(周报)读取固定画布 → 编辑 → 导出 → 交付链接永不改变,关注者只需查看更新即可
每次生成新产物(每周发布内容组)实例化团队模板 → 创作 → 导出moda-templates确保每周内容都符合审批后的布局
同步任务拉取源数据 → 创作 → 导出至交付步骤指定位置Moda不会接入你的系统;数据拉取由你负责
无论使用哪种模式,都需加载对应格式的skill来完成创作部分——本skill不教授如何生成产物。

Discipline for a run nobody is watching

无人值守运行的规则

  • A failed write commits nothing: retry once is safe.
    stale_revision
    heals on a re-read and retry.
  • Same typed error twice → stop this tick, record
    moda last-error
    , let the next tick try. Never spin.
  • An identical repeated metered call REPLAYS its result instead of charging twice — retrying with the same inputs is safe; a reworded prompt is a new charge, so never "retry" generation by nudging the wording.
  • Keep the log: what ran, the canvas link, the export path, and the failure if there was one. An unattended run that reports nothing is indistinguishable from one that never ran.
  • 写入失败不会提交任何内容:重试一次是安全的。遇到
    stale_revision
    时,重新读取并重试即可恢复。
  • 连续两次出现相同类型的错误 → 终止本次调度,记录
    moda last-error
    ,等待下一次调度重试。切勿循环重试。
  • 完全相同的重复计量调用会返回之前的结果,不会重复收费——使用相同参数重试是安全的;修改提示措辞的重试会视为新调用并收费,因此切勿通过调整提示措辞来“重试”生成操作。
  • 保留日志:记录执行内容、画布链接、导出路径以及(若有)失败信息。不输出任何内容的无人值守运行,和未运行的状态无法区分。

Hand back the schedule itself

向用户反馈调度详情

Tell the user the literal schedule line you installed, where it lives, which skill builds the artifact, and how to turn it off. A schedule they cannot find is a schedule they cannot trust — and never install one they did not ask for.
告知用户你安装的具体调度命令、存储位置、生成产物的skill以及关闭方法。用户找不到的调度是无法信任的——切勿安装用户未要求的调度。

Examples

示例

  • "post our metrics chart to Slack every Monday" → this skill installs the weekly run, moda-chart builds the chart, the Slack step is the host's.
  • "keep the launch one-pager up to date" → refresh-one-canvas shape; moda-document owns the page.
  • "a fresh set of posts every week" → new-artifact shape off a team template; the platform's moda-social child owns the creative.
  • "every night, turn yesterday's numbers into a chart" → sync-job shape; pin the repo first (moda-context) so the tick needs no flags.
  • “每周一将我们的指标图表发布到Slack” → 本skill负责安装每周调度,moda-chart负责生成图表,Slack发布步骤由主机端完成。
  • “保持启动单页内容更新” → 使用刷新单个画布模式;moda-document负责页面内容。
  • “每周生成一组新的发布内容” → 使用基于团队模板生成新产物的模式;对应平台的moda-social子skill负责创意内容。
  • “每天晚上将昨日数据生成图表” → 使用同步任务模式;先固定仓库(moda-context),这样调度执行时无需额外参数。

Errors

错误处理

Any typed error → load moda-core and read its recovery reference. Auth failures in an unattended run are almost always a missing or expired
MODA_API_KEY
in the scheduler's environment — check it there, not in the interactive shell where it works.
See also: moda-core — the contract, recovery, everything Moda can do.
任何类型错误 → 加载moda-core并查看其恢复指南。无人值守运行中的认证失败几乎都是因为调度器环境中缺少或过期的
MODA_API_KEY
——请在调度器环境中检查,而非在可正常工作的交互式shell中。
另请参阅:moda-core —— 包含合约、恢复方法以及Moda的所有功能。