mthds-run
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRun MTHDS methods
运行MTHDS方法
Execute MTHDS method bundles and interpret their JSON output.
执行MTHDS方法包并解析其JSON输出。
Process
流程
Step 0 — CLI Check (mandatory, do this FIRST)
步骤0 — CLI检查(强制要求,优先执行)
Run . The minimum required version is 0.1.0 (declared in this skill's front matter as ).
mthds-agent --versionmin_mthds_version- If the command is not found: STOP. Do not proceed. Tell the user:
TheCLI is required but not installed. Install it with:mthds-agentnpm install -g mthdsThen re-run this skill.
- If the version is below 0.1.0: STOP. Do not proceed. Tell the user:
This skill requiresversion 0.1.0 or higher (found X.Y.Z). Upgrade with:mthds-agentnpm install -g mthds@latestThen re-run this skill.
- If the version is 0.1.0 or higher: proceed to the next step.
Do not write files manually, do not scan for existing methods, do not do any other work. The CLI is required for validation, formatting, and execution — without it the output will be broken.
.mthds运行 。最低要求版本为0.1.0(在本技能的前置信息中声明为)。
mthds-agent --versionmin_mthds_version- 如果未找到该命令:停止操作,不要继续。告知用户:
需要CLI但尚未安装。请使用以下命令安装:mthds-agentnpm install -g mthds安装完成后重新运行本技能。
- 如果版本低于0.1.0:停止操作,不要继续。告知用户:
本技能要求版本为0.1.0或更高(当前版本为X.Y.Z)。请使用以下命令升级:mthds-agentnpm install -g mthds@latest升级完成后重新运行本技能。
- 如果版本为0.1.0或更高:继续执行下一步。
不要手动编写文件,不要扫描现有方法,不要执行任何其他操作。CLI是校验、格式化和执行的必备工具,没有它输出结果会出错。
.mthdsStep 0.5 — Pipelex Runtime Check (mandatory)
步骤0.5 — Pipelex运行时检查(强制要求)
Running methods requires the Pipelex runtime to be installed and configured.
First, check if is available:
pipelex-agentbash
pipelex-agent --version- If the command is not found: STOP. Tell the user:
The Pipelex runtime is not installed. Install it with:curl -fsSL https://pipelex.com/install.sh | sh
Then, if is installed, check configuration health:
pipelex-agentbash
mthds-agent pipelex doctor- If the doctor reports config issues (missing backends, missing API keys) AND the user is requesting a live run (not ): STOP. Tell the user:
--dry-run
Pipelex needs to be configured with inference backends before running methods. Usefor guided configuration./pipelex-setup
-
If the user is requesting a dry run (): config issues are OK — dry runs work without backend configuration. Proceed.
--dry-run -
If healthy: proceed to Step 1.
运行方法需要先安装并配置Pipelex运行时。
首先,检查是否可用:
pipelex-agentbash
pipelex-agent --version- 如果未找到该命令:停止操作,告知用户:
Pipelex运行时尚未安装。请使用以下命令安装:curl -fsSL https://pipelex.com/install.sh | sh
接下来,如果已经安装,检查配置健康状态:
pipelex-agentbash
mthds-agent pipelex doctor- 如果健康检查报告配置问题(缺少后端、缺少API密钥) 且用户请求的是正式运行(不是):停止操作,告知用户:
--dry-run
运行方法前需要为Pipelex配置推理后端。使用获取引导式配置指引。/pipelex-setup
-
如果用户请求的是试运行():配置问题不影响,试运行不需要后端配置,继续操作即可。
--dry-run -
如果健康状态正常:继续执行步骤1。
Step 1: Identify the Target
步骤1:确定运行目标
| Target | Command |
|---|---|
| Pipeline directory (recommended) | |
| Specific pipe in a directory | |
| Bundle file directly | |
| Pipe by code from library | |
Directory mode (recommended): Pass the pipeline directory as target. The CLI auto-detects,bundle.mthds, and setsinputs.jsonautomatically — no need to specify them explicitly. This also avoids namespace collisions with other bundles.-L
| 目标 | 命令 |
|---|---|
| 流水线目录(推荐) | |
| 目录下的指定pipe | |
| 直接指定包文件 | |
| 调用库中的pipe代码 | |
目录模式(推荐):传入流水线目录作为目标,CLI会自动检测、bundle.mthds并自动设置inputs.json参数,无需显式指定,同时还能避免与其他包产生命名空间冲突。-L
Step 2: Prepare Inputs and Check Readiness
步骤2:准备输入并检查就绪状态
Fast path — inputs just prepared
快速路径 — 输入已提前准备
If inputs were already prepared during this conversation — via (user-data, synthetic, or mixed strategy), or by manually assembling with real values earlier in this session — skip the schema fetch and readiness check. The inputs are ready. Proceed directly to Step 3 with a normal run.
/mthds-inputsinputs.jsonThis applies when you just wrote or saw being written with real content values. It does NOT apply after (which saves a placeholder template) or after with the template strategy.
inputs.json/mthds-build/mthds-inputs如果在本次对话中已经通过准备好输入(用户数据、合成数据或混合策略),或者在本次会话的更早阶段已经手动组装好包含真实值的,可以跳过schema获取和就绪检查,输入已准备完成,直接进入步骤3正常运行即可。
/mthds-inputsinputs.json该规则仅适用于你刚刚编写或看到被写入了真实内容的场景,不适用于(仅保存占位符模板)或使用模板策略执行之后的场景。
inputs.json/mthds-build/mthds-inputsFull check — cold start
完整检查 — 冷启动
If is invoked without prior input preparation in this session, perform the full readiness check:
/mthds-runGet the input schema for the target:
bash
mthds-agent pipelex inputs pipe bundle.mthdsOutput:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}Fill in the fields with actual values. For complex inputs, use the /mthds-inputs skill.
content如果调用前本次会话中没有提前准备输入,执行完整的就绪检查:
/mthds-run获取目标的输入schema:
bash
mthds-agent pipelex inputs pipe bundle.mthds输出示例:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}使用真实值填充字段,复杂输入可以使用/mthds-inputs技能处理。
contentInput Readiness Check
输入就绪检查
Before running, assess whether inputs are ready. This prevents runtime failures from placeholder values.
No inputs required: If returns an empty object (), inputs are ready — skip to Step 3.
mthds-agent pipelex inputs pipeinputs{}Inputs required: If inputs exist, check for readiness:
inputs.json- Does exist in the bundle directory?
inputs.json - If it exists, scan all values for placeholder signals:
content- Template defaults: ,
"url_value","text_value","number_value","integer_value", or any value matching the pattern"boolean_value"*_value - Angle-bracket placeholders: values containing (e.g.
<...>,<path-to-cv.pdf>)<your-text-here> - Non-existent file paths: fields pointing to local files that don't exist on disk
url
- Template defaults:
Readiness result:
- Ready: exists AND all content values are real (no placeholders, referenced files exist) → proceed to Step 3 with normal run
inputs.json - Not ready: is missing, OR contains any placeholder values → proceed to Step 3 with dry-run fallback
inputs.json
运行前评估输入是否就绪,避免占位符值导致运行时失败。
无需输入:如果返回空的对象(),说明输入已就绪,直接跳转到步骤3。
mthds-agent pipelex inputs pipeinputs{}需要输入:如果存在输入,检查的就绪状态:
inputs.json- 包目录下是否存在?
inputs.json - 如果存在,扫描所有值是否存在占位符信号:
content- 模板默认值:、
"url_value"、"text_value"、"number_value"、"integer_value",或任何匹配"boolean_value"模式的值*_value - 尖括号占位符:包含的值(例如
<...>、<path-to-cv.pdf>)<your-text-here> - 不存在的文件路径:字段指向的本地文件在磁盘上不存在
url
- 模板默认值:
就绪结果:
- 就绪:存在且所有content值都是真实的(无占位符、引用的文件存在)→ 进入步骤3正常运行
inputs.json - 未就绪:缺失,或包含任意占位符值 → 进入步骤3,默认使用试运行回退方案
inputs.json
Step 3: Choose Run Mode
步骤3:选择运行模式
If inputs are not ready
如果输入未就绪
Default to and inform the user:
--dry-run --mock-inputs"The inputs for this pipeline contain placeholder values (not real data). I'll do a dry run with mock inputs to validate the pipeline structure."
After the dry run, offer the user these options:
- Prepare real inputs — use to fill in actual values, then re-run
/mthds-inputs - Provide files — if the pipeline expects file inputs (documents, images), ask the user to supply file paths
- Keep dry run — accept the dry-run result as-is
默认使用并告知用户:
--dry-run --mock-inputs"该流水线的输入包含占位符值(非真实数据),我将使用模拟数据执行试运行,验证流水线结构是否正常。"
试运行结束后,为用户提供以下选项:
- 准备真实输入 — 使用填充真实值后重新运行
/mthds-inputs - 提供文件 — 如果流水线需要文件输入(文档、图片),请用户提供文件路径
- 保留试运行结果 — 直接接受试运行结果
Run modes reference
运行模式参考
| Mode | Command | Use When |
|---|---|---|
| Dry run + mock inputs | | Quick structural validation, no real data needed, or inputs not ready |
| Dry run with real inputs | | Validate input shapes without making API calls (auto-detects |
| Full run | | Production execution (auto-detects |
| Full run inline | | Quick execution with inline JSON inputs |
| Full run without graph | | Execute without generating graph visualization |
| Full run with memory | | When piping output to another method |
Graph by default: Execution graphs (/live_run.html) are now generated automatically. Usedry_run.htmlto disable.--no-graph
| 模式 | 命令 | 使用场景 |
|---|---|---|
| 试运行 + 模拟输入 | | 快速结构验证,不需要真实数据,或输入未就绪 |
| 使用真实输入试运行 | | 无需调用API即可验证输入格式(自动检测 |
| 全量运行 | | 生产环境执行(自动检测 |
| 内联输入全量运行 | | 使用内联JSON输入快速执行 |
| 不生成图谱全量运行 | | 执行时不生成图谱可视化内容 |
| 带内存全量运行 | | 需要将输出传递给其他方法时使用 |
默认生成图谱:现在执行时会自动生成执行图谱(/live_run.html),使用dry_run.html可关闭该功能。--no-graph
Inline JSON for Inputs
内联JSON输入
The flag accepts both file paths and inline JSON. The CLI auto-detects: if the value starts with , it is parsed as JSON directly. This is the fastest path — no file creation needed for simple inputs.
--inputs{bash
undefined--inputs{bash
undefinedInline JSON
内联JSON
mthds-agent pipelex run pipe <bundle-dir>/ --inputs '{"theme": {"concept": "native.Text", "content": {"text": "nature"}}}'
mthds-agent pipelex run pipe <bundle-dir>/ --inputs '{"theme": {"concept": "native.Text", "content": {"text": "nature"}}}'
File path (auto-detected in directory mode)
文件路径(目录模式下自动检测)
mthds-agent pipelex run pipe <bundle-dir>/
undefinedmthds-agent pipelex run pipe <bundle-dir>/
undefinedStep 4: Present Results
步骤4:呈现结果
After a successful run, always show the actual output to the user — never just summarize what fields exist.
运行成功后,始终向用户展示真实输出 — 不要仅总结存在哪些字段。
Output format modes
输出格式模式
The CLI has two output modes:
- Compact (default): stdout is the concept's structured JSON directly — no envelope, no wrapper. This is the primary output of the method's main concept. Parse the JSON directly for field access.
success - With memory (): stdout has
--with-memory(withmain_stuff,json,markdownrenderings) +html(all named stuffs and aliases). Use this when piping output to another method.working_memory
The and are written to disk as side effects (paths appear in logs/stderr), not in compact stdout.
output_filegraph_filesCLI有两种输出模式:
- 精简模式(默认):标准输出直接返回概念的结构化JSON,没有外壳,没有包装,这是方法核心概念的主要输出,可直接解析JSON获取字段。
success - 带内存模式():标准输出包含
--with-memory(带有main_stuff、json、markdown渲染结果) +html(所有命名内容和别名),需要将输出传递给其他方法时使用该模式。working_memory
output_filegraph_files4a. Determine what to show
4a. 确定展示内容
In compact mode (default), the output is the concept JSON directly. Show the fields to the user:
json
{
"clauses": [...],
"overall_risk": "high"
}In mode, the output structure depends on the pipe architecture:
--with-memoryif main_stuff is non-empty (not {} or null):
→ main_stuff is the primary output (single unified result)
else:
→ working_memory.root holds the primary output (multiple named results)| Pipe Type | | What to show |
|---|---|---|
| PipeLLM, PipeCompose, PipeExtract, PipeImgGen, PipeSearch | Always | |
| PipeSequence | Always (last step) | |
| PipeBatch | Always (list) | |
| PipeCondition | Always | |
PipeParallel with | Yes | |
PipeParallel without | No ( | |
**精简模式(默认)**下,输出直接是概念JSON,向用户展示字段即可:
json
{
"clauses": [...],
"overall_risk": "high"
}--with-memory如果main_stuff非空(不是{}或null):
→ main_stuff是主要输出(单一统一结果)
否则:
→ working_memory.root保存主要输出(多个命名结果)| Pipe类型 | 是否存在 | 展示内容 |
|---|---|---|
| PipeLLM、PipeCompose、PipeExtract、PipeImgGen、PipeSearch | 始终存在 | |
| PipeSequence | 始终存在(最后一步结果) | |
| PipeBatch | 始终存在(列表) | |
| PipeCondition | 始终存在 | |
带 | 是 | |
不带 | 否( | |
4b. Show the output content
4b. 展示输出内容
In compact mode: show the JSON fields directly. For structured concepts, format for readability.
In mode when is present (most pipe types):
--with-memorymain_stuff- Show directly — this is the human-readable rendering. Display it as-is so the user sees the full output.
main_stuff.markdown - For structured concepts with fields, also show formatted for readability.
main_stuff.json
In mode when is empty (PipeParallel without ):
--with-memorymain_stuffcombined_output- Iterate and present each named result.
working_memory.root - For each entry, show the field with its key as a label.
content - Example: "french_translation: Bonjour le monde" / "spanish_translation: Hola mundo"
For dry runs: Show the same output but clearly label it as mock/simulated data.
精简模式:直接展示JSON字段,结构化概念请格式化以提升可读性。
--with-memorymain_stuff- 直接展示— 这是人类可读的渲染结果,原样展示即可让用户看到完整输出。
main_stuff.markdown - 对于带字段的结构化概念,同时展示格式化后易读的。
main_stuff.json
--with-memorymain_stuffcombined_output- 遍历,逐个展示每个命名结果。
working_memory.root - 每个条目以键作为标签,展示字段。
content - 示例:"法语翻译:Bonjour le monde" / "西班牙语翻译:Hola mundo"
试运行场景:展示相同输出,但要明确标注为模拟/仿真数据。
4c. Output file
4c. 输出文件
- The CLI automatically saves the full JSON output next to the bundle (or
live_run.json).dry_run.json - The output file path appears in runtime logs (stderr), not in compact stdout.
- CLI会自动将完整JSON输出保存在包目录旁(或
live_run.json)。dry_run.json - 输出文件路径出现在运行时日志(标准错误输出)中,不会出现在精简模式的标准输出中。
4d. Present graph files
4d. 展示图谱文件
- Graph visualizations are generated by default (/
live_run.html). Usedry_run.htmlto disable.--no-graph - The graph file path appears in runtime logs (stderr), not in compact stdout.
- 默认生成执行图谱可视化文件(/
live_run.html),使用dry_run.html可关闭该功能。--no-graph - 图谱文件路径出现在运行时日志(标准错误输出)中,不会出现在精简模式的标准输出中。
4e. Mention intermediate results
4e. 提及中间结果
- If the pipeline has multiple steps, briefly note key intermediate values from (e.g., "The match analysis intermediate step scored 82/100").
working_memory - Offer: "I can show the full working memory if you want to inspect any intermediate step."
- 如果流水线包含多个步骤,简要说明中的关键中间值(例如:"匹配分析中间步骤得分为82/100")。
working_memory - 提供选项:"如果你想要查看任意中间步骤的详情,我可以展示完整的工作内存。"
4f. Suggest next steps
4f. 建议后续步骤
- Re-run with different inputs
- Adjust prompts or pipe configurations if output quality needs improvement
- 使用不同输入重新运行
- 如果输出质量需要提升,调整提示词或pipe配置
Step 5: Handle Errors
步骤5:处理错误
When encountering runtime errors, re-run with for additional context:
--log-level debugbash
mthds-agent --log-level debug pipelex run pipe <bundle-dir>/ --inputs data.jsonFor all error types and recovery strategies, see Error Handling Reference.
遇到运行时错误时,使用重新运行以获取更多上下文:
--log-level debugbash
mthds-agent --log-level debug pipelex run pipe <bundle-dir>/ --inputs data.json所有错误类型和恢复策略请参考错误处理参考。
Execution Graphs
执行图谱
Execution graph visualizations are generated by default alongside the run output. Use to disable.
--no-graphbash
mthds-agent pipelex run pipe <bundle-dir>/Graph files ( / ) are written to disk next to the bundle. Their paths appear in runtime logs on stderr, not in compact stdout. When using , is included in the returned JSON envelope.
live_run.htmldry_run.html--with-memorygraph_files运行输出旁默认会生成执行图谱可视化文件,使用可关闭该功能。
--no-graphbash
mthds-agent pipelex run pipe <bundle-dir>/图谱文件( / )会写入包目录旁的磁盘中,路径出现在标准错误输出的运行时日志里,不会出现在精简模式的标准输出中。使用时,返回的JSON外壳中会包含。
live_run.htmldry_run.html--with-memorygraph_filesPiping Methods
方法管道
The run command accepts piped JSON on stdin when is not provided. This enables chaining methods:
--inputsbash
mthds-agent pipelex run method extract-terms --inputs data.json --with-memory \
| mthds-agent pipelex run method assess-risk --with-memory \
| mthds-agent pipelex run method generate-reportWhen methods are installed as CLI shims, the same chain is:
bash
extract-terms --inputs data.json --with-memory \
| assess-risk --with-memory \
| generate-report- Use on intermediate steps to pass the full working memory envelope.
--with-memory - The final step omits to produce compact output.
--with-memory - always overrides stdin when both are present.
--inputs - Upstream stuff names are matched against downstream input names. Method authors should name their outputs to match the downstream's expected input names.
未提供时,run命令接受标准输入传入的管道JSON,可实现方法链式调用:
--inputsbash
mthds-agent pipelex run method extract-terms --inputs data.json --with-memory \
| mthds-agent pipelex run method assess-risk --with-memory \
| mthds-agent pipelex run method generate-report如果方法已安装为CLI垫片,相同的链式调用写法为:
bash
extract-terms --inputs data.json --with-memory \
| assess-risk --with-memory \
| generate-report- 中间步骤使用传递完整的工作内存外壳。
--with-memory - 最后一步省略以生成精简输出。
--with-memory - 同时存在和标准输入时,
--inputs始终优先。--inputs - 上游内容名称会与下游输入名称匹配,方法开发者应将输出命名为与下游预期输入名称匹配的值。
Reference
参考
- Error Handling — read when CLI returns an error to determine recovery
- MTHDS Agent Guide — read for CLI command syntax or output format details
- MTHDS Language Reference — read for .mthds syntax documentation
- Native Content Types — read when interpreting pipeline outputs or preparing input JSON, to understand the attributes of each content type
- 错误处理 — CLI返回错误时阅读,确定恢复方案
- MTHDS Agent指南 — 了解CLI命令语法或输出格式详情时阅读
- MTHDS语言参考 — 了解.mthds语法文档时阅读
- 原生内容类型 — 解析流水线输出或准备输入JSON时阅读,了解各内容类型的属性