fix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fix MTHDS bundles

修复MTHDS包

Automatically fix issues in MTHDS method bundles.
自动修复MTHDS方法包中的问题。

Process

流程

Prerequisite: See CLI Prerequisites
前提条件:查看CLI 前提条件

Step 1: Validate and Identify Errors

步骤1:验证并识别错误

Always use
-L
pointing to the bundle's own directory to avoid namespace collisions:
bash
mthds-agent pipelex validate <file>.mthds -L <bundle-directory>/
Parse the JSON output:
  • If
    success: true
    — nothing to fix, report clean status
  • If
    error_type: "ValidateBundleError"
    — iterate through
    validation_errors
    array and fix each (Step 2)
  • If model/config error — see Error Handling Reference (cannot be fixed by editing the .mthds file)
始终使用
-L
指向包自身的目录,以避免命名空间冲突:
bash
mthds-agent pipelex validate <file>.mthds -L <bundle-directory>/
解析JSON输出:
  • 如果
    success: true
    — 无需修复,报告状态正常
  • 如果
    error_type: "ValidateBundleError"
    — 遍历
    validation_errors
    数组并逐个修复(步骤2)
  • 如果是模型/配置错误 — 查看错误处理参考(无法通过编辑.mthds文件修复)

Step 2: Fix .mthds Validation Errors

步骤2:修复.mthds验证错误

Use the
error_type
field from each validation error to determine the fix:
Error TypeFix Strategy
missing_input_variable
Add the missing variable(s) to the parent pipe's
inputs
line
extraneous_input_variable
Remove the unused variable(s) from the pipe's
inputs
line
input_stuff_spec_mismatch
Correct the concept type in
inputs
to match what the sub-pipe expects
inadequate_output_concept
Change the
output
field to the correct concept type
inadequate_output_multiplicity
Add or remove
[]
from the output concept
circular_dependency_error
Restructure the method to break the cycle
llm_output_cannot_be_image
Use PipeImgGen instead of PipeLLM for image generation
img_gen_input_not_text_compatible
Ensure PipeImgGen input is text-based (use
ImgGenPrompt
)
invalid_pipe_code_syntax
Rename the pipe to valid snake_case
unknown_concept
Add the concept definition to the bundle, or fix the typo
batch_item_name_collision
Rename
input_item_name
(or
batch_as
) to a distinct singular form of the list name. Also update the branch pipe's
inputs
to use the new item name.
For error type descriptions, see Error Handling — Validation Error Types.
使用每个验证错误中的
error_type
字段确定修复方案:
错误类型修复策略
missing_input_variable
将缺失的变量添加到父管道的
inputs
行中
extraneous_input_variable
从管道的
inputs
行中移除未使用的变量
input_stuff_spec_mismatch
修正
inputs
中的概念类型,使其与子管道的预期一致
inadequate_output_concept
output
字段修改为正确的概念类型
inadequate_output_multiplicity
为输出概念添加或移除
[]
circular_dependency_error
重构方法以打破循环依赖
llm_output_cannot_be_image
使用PipeImgGen而非PipeLLM进行图像生成
img_gen_input_not_text_compatible
确保PipeImgGen的输入为文本格式(使用
ImgGenPrompt
invalid_pipe_code_syntax
将管道重命名为有效的蛇形命名法(snake_case)
unknown_concept
向包中添加概念定义,或修正拼写错误
batch_item_name_collision
input_item_name
(或
batch_as
)重命名为列表名称的独特单数形式。同时更新分支管道的
inputs
以使用新的项名称。
有关错误类型的说明,请查看错误处理 — 验证错误类型

Step 3: Fix TOML Formatting Issues

步骤3:修复TOML格式问题

These aren't always reported by validation but cause problems:
Multi-line inputs — must be on a single line:
toml
undefined
这些问题并非总会被验证工具报告,但会引发异常:
多行输入 — 必须放在单行中:
toml
undefined

WRONG

错误示例

inputs = { a = "A", b = "B" }
inputs = { a = "A", b = "B" }

CORRECT

正确示例

inputs = { a = "A", b = "B" }

**Pipe ordering** — controllers before sub-pipes:
```toml
inputs = { a = "A", b = "B" }

**管道顺序** — 控制器管道优先于子管道:
```toml

CORRECT: main pipe first, then sub-pipes in execution order

正确示例:主管道在前,子管道按执行顺序排列

[pipe.main_workflow] type = "PipeSequence" steps = [ { pipe = "step_one", result = "intermediate" }, { pipe = "step_two", result = "final" } ]
[pipe.step_one] ...
[pipe.step_two] ...

**Missing required fields** — add with sensible defaults:
- `description` on every pipe and concept
- `type` on every pipe
- `output` on every pipe
[pipe.main_workflow] type = "PipeSequence" steps = [ { pipe = "step_one", result = "intermediate" }, { pipe = "step_two", result = "final" } ]
[pipe.step_one] ...
[pipe.step_two] ...

**缺失必填字段** — 添加合理的默认值:
- 每个管道和概念都要有`description`
- 每个管道都要有`type`
- 每个管道都要有`output`

Step 4: Re-validate

步骤4:重新验证

After applying fixes, re-validate:
bash
mthds-agent pipelex validate <file>.mthds -L <bundle-directory>/
Continue the fix-validate loop until
success: true
is returned. Some fixes reveal new issues — for example, fixing a
missing_input_variable
may expose an
input_stuff_spec_mismatch
on the newly added input.
If the fix-validate loop gets stuck or errors are unclear, re-run with
--log-level debug
for additional context:
bash
mthds-agent --log-level debug pipelex validate <file>.mthds -L <bundle-directory>/
应用修复后,重新验证:
bash
mthds-agent pipelex validate <file>.mthds -L <bundle-directory>/
重复“修复-验证”循环,直到返回
success: true
。部分修复可能会暴露新问题 — 例如,修复
missing_input_variable
可能会在新添加的输入上暴露
input_stuff_spec_mismatch
如果“修复-验证”循环陷入停滞或错误不明确,使用
--log-level debug
重新运行以获取更多上下文:
bash
mthds-agent --log-level debug pipelex validate <file>.mthds -L <bundle-directory>/

Step 5: Report Results

步骤5:报告结果

  • List all changes made (which pipes were modified and how)
  • Show the final validation result
  • Flag any remaining warnings or suggestions
  • 列出所有已做的更改(修改了哪些管道以及修改方式)
  • 展示最终的验证结果
  • 标记任何剩余的警告或建议

Reference

参考资料

  • CLI Prerequisites — read at skill start to check CLI availability
  • 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 when writing or modifying .mthds TOML syntax
  • Native Content Types — read when fixing type mismatches involving native concepts, to verify available attributes
  • CLI 前提条件 — 技能启动时阅读,检查CLI可用性
  • 错误处理 — 当CLI返回错误时阅读,以确定恢复方案
  • MTHDS Agent 指南 — 阅读以了解CLI命令语法或输出格式细节
  • MTHDS 语言参考 — 编写或修改.mthds TOML语法时阅读
  • 原生内容类型 — 修复涉及原生概念的类型不匹配问题时阅读,以验证可用属性