用途:为 Truto 集成编写统一 API 映射,即把代理 API 的原始响应与请求体转换为 Truto 统一模型(crm、ats、hris、ecommerce 等)的 JSONata。build 命令驱动 LLM 循环,将每个统一资源/方法路由到代理端点、采样、生成 JSONata、校验,并产出单个 MappingFile。不覆盖集成定义本身(见 truto-integrations-build)、JSONata 语言与自定义 $functions(见 truto-jsonata)、按环境手工覆盖映射(见 truto-cli)及通用 CLI 认证。
主要能力:三步工作流。1) build:truto unified-mappings build acme crm --account <id>(实时采样,只读,仅对 list/get 发 GET);或 --source-url 基于文档,可重复并支持 glob;--resources/--methods 限定范围;默认 agentic(Claude Opus 编排),--structured 为固定逐单元流水线(仍由 LLM 生成)。交互终端结束时有 refinement 循环,可输入自由指令重建受影响单元,:show 查看逐单元评审,空行结束;--no-refine、--yes、--only-missing 或管道输出时跳过。2) validate:truto unified-mappings validate acme.crm.mappings.json,确定性审计,无 LLM、无写入、无费用,出错非零退出,-v 列出全部建议性警告。3) apply:truto unified-mappings apply acme.crm.mappings.json --target base|env,--dry-run 预览不写入,--yes 跳过确认。
使用方式:先安装并认证 CLI(curl -fsSL https://cli.truto.one/install.sh | bash;truto login --token <your-api-token>;Windows 用 irm https://cli.truto.one/install.ps1 | iex)。在 profile 中设置 anthropicApiKey(必需,驱动构建)、可选 firecrawlApiKey、unifiedMappingDir、integrationConfigDir。解析顺序为 --flag > 环境变量 > 活动 profile > 交互提示。嵌入用本地 ONNX 模型,无需外部密钥。
适用场景:需要为某集成批量生成统一模型映射并校验、应用时。限制:build 至少需 --account 或 --source-url;写单元(create/update/delete)依据文档请求体构建,不做实时写采样;输出文件为 MappingFile,含 cells[] 与 build_summary,apply 前应查看 skipped 与 warnings;已有输出文件会续建,--fresh 从头开始,--only-missing 仅建缺失单元且不重试失败。其余细节暂未提供。