mthds-inputs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePrepare Inputs for MTHDS methods
为MTHDS方法准备输入
Prepare input data for running MTHDS method bundles. This skill is the single entry point for all input preparation needs: extracting a placeholder template, generating synthetic test data, integrating user-provided files, or any combination.
为运行MTHDS方法包准备输入数据。本功能是所有输入准备需求的统一入口:提取占位符模板、生成合成测试数据、整合用户提供的文件,或以上任意组合。
Mode Selection
模式选择
How mode is determined
模式的判定方式
-
Explicit override: If the user states a preference, always honor it:
- Automatic signals: "just do it", "go ahead", "automatic", "quick", "don't ask"
- Interactive signals: "walk me through", "help me", "guide me", "step by step", "let me decide"
-
Skill default: Each skill defines its own default based on the nature of the task.
-
Request analysis: If no explicit signal and no strong skill default, assess the request:
- Detailed, specific requirements → automatic
- Brief, ambiguous, or subjective → interactive
-
显式覆盖:如果用户明确说明偏好,始终遵循:
- 自动模式信号:"just do it"、"go ahead"、"automatic"、"quick"、"don't ask"
- 交互模式信号:"walk me through"、"help me"、"guide me"、"step by step"、"let me decide"
-
功能默认值:每个功能会根据任务性质定义自身默认模式。
-
请求分析:如果没有显式信号且无明确功能默认值,则评估请求:
- 详细、具体的需求 → 自动模式
- 简短、模糊或主观的需求 → 交互模式
Mode behavior
模式行为
Automatic mode:
- State assumptions briefly before proceeding
- Make reasonable decisions at each step
- Present the result when done
- Pause only if a critical ambiguity could lead to wasted work
Interactive mode:
- Ask clarifying questions at the start
- Present options at decision points
- Confirm before proceeding at checkpoints
- Allow the user to steer direction
自动模式:
- 执行前简要说明假设
- 在每个步骤做出合理决策
- 完成后呈现结果
- 仅当存在可能导致无效工作的关键歧义时才暂停
交互模式:
- 开始时询问澄清问题
- 在决策点提供选项
- 在检查点执行前确认
- 允许用户掌控方向
Mode switching
模式切换
- If in automatic mode and the user asks a question or gives feedback → switch to interactive for the current phase
- If in interactive mode and the user says "looks good, go ahead" or similar → switch to automatic for remaining phases
Default: Automatic.
Input strategy detection heuristics (evaluated in order):
| Signal | Strategy |
|---|---|
| User provides file paths, folder paths, or mentions "my data" / "this file" / "use these images" / "here's my PDF" | User Data (or Mixed if some inputs remain unfilled) |
| User says "test data" / "generate inputs" / "synthesize" / "fake data" / "sample data" | Synthetic |
| User says "template" / "schema" / "placeholder" / "what inputs does it need?" | Template |
No clear signal (e.g., called after | Template, then offer to populate |
Interactive additions: Ask about:
- Which user files map to which inputs (when ambiguous)
- Domain/industry context for realistic synthetic data
- Whether to generate edge cases or happy-path data
- Specific values or constraints for certain fields
- 如果处于自动模式,且用户提出问题或给出反馈 → 针对当前阶段切换为交互模式
- 如果处于交互模式,且用户说出"looks good, go ahead"或类似表述 → 针对剩余阶段切换为自动模式
默认模式:自动模式。
输入策略检测规则(按顺序评估):
| 信号 | 策略 |
|---|---|
| 用户提供文件路径、文件夹路径,或提及"my data" / "this file" / "use these images" / "here's my PDF" | 用户数据(若部分输入未填充则为混合策略) |
| 用户说出"test data" / "generate inputs" / "synthesize" / "fake data" / "sample data" | 合成策略 |
| 用户说出"template" / "schema" / "placeholder" / "what inputs does it need?" | 模板策略 |
无明确信号(例如,调用 | 模板策略,然后提供填充选项 |
交互模式补充操作:询问以下内容:
- 当存在歧义时,用户文件与哪些输入对应
- 用于生成真实合成数据的领域/行业上下文
- 是否生成边缘案例或常规路径数据
- 某些字段的特定值或约束条件
Step 0 — CLI Check (mandatory, do this FIRST)
步骤0 — CLI检查(必填,首先执行此步骤)
Run .
mthds-agent --version- If it succeeds: proceed to the next step.
- If it fails or the command is not found: STOP. Do not proceed with this skill. Tell the user:
TheCLI is required but not installed. Install it with:mthds-agentnpm install -g mthdsThen re-run this skill.
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运行。
mthds-agent --version- 如果成功:继续执行下一步。
- 如果失败或未找到命令:停止操作。不要继续执行本功能。告知用户:
必需的CLI未安装。请使用以下命令安装:mthds-agentnpm install -g mthds然后重新运行本功能。
不要手动编写文件,不要扫描现有方法,不要执行任何其他操作。CLI是验证、格式化和执行的必需工具——没有它,输出将无法正常工作。
.mthdsProcess
流程
Step 1: Identify the Target Method
步骤1:确定目标方法
Determine the bundle and its output directory (). This is usually the directory containing (e.g., ).
.mthds<output_dir>bundle.mthdsmthds-wip/pipeline_01/The file is saved directly in this directory (next to ):
inputs.jsonbundle.mthds<output_dir>/inputs.json
If data files need to be generated or copied (images, PDFs, etc.), they go in a subdirectory:
<output_dir>/inputs/
The subdirectory is only created when there are actual data files to store. Paths to these files are referenced from within .
/inputsinputs.json确定包及其输出目录()。通常为包含的目录(例如:)。
.mthds<output_dir>bundle.mthdsmthds-wip/pipeline_01/inputs.jsonbundle.mthds<output_dir>/inputs.json
如果需要生成或复制数据文件(图片、PDF等),它们将存储在子目录中:
<output_dir>/inputs/
仅当有实际数据文件需要存储时,才会创建子目录。这些文件的路径将在中引用。
/inputsinputs.jsonStep 2: Get Input Schema
步骤2:获取输入Schema
Extract the input template from the method:
bash
mthds-agent pipelex inputs pipe <bundle.mthds> -L <bundle-dir>/ [--pipe specific_pipe]Output format:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}For error handling, see Error Handling Reference.
从方法中提取输入模板:
bash
mthds-agent pipelex inputs pipe <bundle.mthds> -L <bundle-dir>/ [--pipe specific_pipe]输出格式:
json
{
"success": true,
"pipe_code": "process_document",
"inputs": {
"document": {
"concept": "native.Document",
"content": {"url": "url_value"}
},
"context": {
"concept": "native.Text",
"content": {"text": "text_value"}
}
}
}错误处理请参考错误处理参考文档。
Step 3: Choose Input Strategy
步骤3:选择输入策略
Based on the heuristics above and what the user has provided, follow the appropriate strategy:
- Template Strategy — placeholder JSON, no real data
- Synthetic Strategy — AI-generated realistic test data
- User Data Strategy — integrate user-provided files
- Mixed Strategy — user files + synthetic for the rest
Template Strategy
模板策略
The fastest path. Produces a placeholder that the user can fill in manually.
inputs.json- Take the object from Step 2's output
inputs - Save it to (next to
<output_dir>/inputs.json)bundle.mthds - Report the saved file path and show the template content
- Offer: "To populate this with realistic test data, re-run /mthds-inputs and ask for synthetic data. Or provide your own files."
最快的实现路径。生成用户可手动填充的占位符。
inputs.json- 提取步骤2输出中的对象
inputs - 将其保存到(与
<output_dir>/inputs.json同级)bundle.mthds - 报告保存的文件路径并展示模板内容
- 提供选项:"如需用真实测试数据填充,请重新运行/mthds-inputs并要求生成合成数据,或提供您自己的文件。"
Synthetic Strategy
合成策略
Generate realistic fake data tailored to the method's purpose.
生成符合方法用途的真实模拟数据。
Identify Input Types
识别输入类型
Parse the schema to identify what types of synthetic data are needed:
| Concept | Content Fields | Synthesis Method |
|---|---|---|
| | Generate realistic text matching the method context |
| | Generate appropriate numeric values |
| | Use |
| | Use document generation skills or Python |
| | Composite: text + optional images |
| | Composite: text + image list |
| | Generate structured JSON matching context |
| Custom structured | Per-field types | Recurse through structure fields |
List types ( or ): Generate multiple items. Variable lists typically need 2-5 items; fixed lists need exactly N items.
Type[]Type[N]解析Schema以确定需要生成的合成数据类型:
| 概念 | 内容字段 | 合成方式 |
|---|---|---|
| | 生成符合方法上下文的真实文本 |
| | 生成合适的数值 |
| | 使用 |
| | 使用文档生成功能或Python |
| | 组合方式:文本 + 可选图片 |
| | 组合方式:文本 + 图片列表 |
| | 生成符合上下文的结构化JSON |
| 自定义结构 | 按字段类型 | 递归处理结构字段 |
列表类型 (或):生成多个条目。可变列表通常需要2-5个条目;固定列表需要恰好N个条目。
Type[]Type[N]Generate Text Content
生成文本内容
Create realistic text that matches the method's purpose:
- If the method processes invoices, generate invoice-like text
- If it analyzes reports, generate report-style content
- Match expected length (short prompts vs long documents)
创建符合方法用途的真实文本:
- 如果方法处理发票,生成类发票文本
- 如果方法分析报告,生成报告风格内容
- 匹配预期长度(短提示 vs 长文档)
Generate Numeric Content
生成数值内容
Generate sensible values within expected ranges based on the method context.
根据方法上下文生成预期范围内的合理数值。
Generate Structured Concepts
生成结构化概念
Fill each field according to its type and description.
根据字段类型和描述填充每个字段。
Generate File Inputs
生成文件输入
When inputs require actual files (Image, Document), use the appropriate generation method. See Image Generation and Document Generation below.
Assemble and Save
组装并保存
Create the complete and save to (next to ). Any generated data files go in .
inputs.json<output_dir>/inputs.jsonbundle.mthds<output_dir>/inputs/创建完整的并保存到(与同级)。所有生成的数据文件将存储在中。
inputs.json<output_dir>/inputs.jsonbundle.mthds<output_dir>/inputs/User Data Strategy
用户数据策略
Integrate the user's own files into the method's input schema.
将用户自己的文件整合到方法的输入Schema中。
Step A: Inventory User Files
步骤A:清点用户文件
Collect all files the user has provided (explicit paths, folders, or files mentioned earlier in conversation). For each file, determine its type:
| Extension(s) | Detected Type | Maps To |
|---|---|---|
| PDF document | |
| Word document | |
| Spreadsheet | |
| Presentation | |
| JPEG image | |
| PNG image | |
| WebP image | |
| GIF image | |
| SVG image | |
| TIFF image | |
| BMP image | |
| Plain text | |
| Markdown text | |
| JSON data | |
| CSV data | |
| HTML | |
收集用户提供的所有文件(明确的路径、文件夹,或对话中提及的文件)。为每个文件确定其类型:
| 扩展名 | 检测类型 | 对应概念 |
|---|---|---|
| PDF文档 | |
| Word文档 | |
| 电子表格 | |
| 演示文稿 | |
| JPEG图片 | |
| PNG图片 | |
| WebP图片 | |
| GIF图片 | |
| SVG图片 | |
| TIFF图片 | |
| BMP图片 | |
| 纯文本 | |
| Markdown文本 | |
| JSON数据 | |
| CSV数据 | |
| HTML | |
Step B: Expand Folders
步骤B:展开文件夹
When the user provides a folder path:
- List all files in the folder (non-recursive by default, recursive if user requests)
- Filter to supported file types
- Group files by detected type
- Match to list-type inputs (,
Image[], etc.)Document[]
Example: User provides containing 5 PDFs. The method expects . Map all 5 PDFs to that list input.
./invoices/documents: Document[]当用户提供文件夹路径时:
- 列出文件夹中的所有文件(默认非递归,若用户要求则递归)
- 筛选支持的文件类型
- 按检测类型分组文件
- 匹配到列表类型输入(、
Image[]等)Document[]
示例:用户提供,其中包含5个PDF文件。方法需要。将所有5个PDF文件映射到此列表输入。
./invoices/documents: Document[]Step C: Match Files to Inputs
步骤C:匹配文件与输入
For each input variable in the schema, attempt to match user-provided files:
Matching rules (applied in order):
- Exact name match: Input variable matches a file named
invoiceinvoice.pdf - Type match (single candidate): If only one input expects and the user provided exactly one image file, match them
native.Image - Type match (multiple candidates): If multiple inputs of the same type exist:
- In automatic mode: match by name similarity (variable name vs filename)
- In interactive mode: ask the user which file goes where
- Folder to list: If a folder contains files of a single type and an input expects a list of that type, map the folder contents to that input
- Unmatched files: Report them and ask if they should be ignored or mapped to a specific input
- Unfilled inputs: After matching, any inputs still without data can be left as placeholders or filled with synthetic data (see Mixed Strategy)
对于Schema中的每个输入变量,尝试匹配用户提供的文件:
匹配规则(按顺序应用):
- 精确名称匹配:输入变量匹配名为
invoice的文件invoice.pdf - 类型匹配(单个候选):如果仅有一个输入需要,且用户恰好提供了一张图片文件,则匹配它们
native.Image - 类型匹配(多个候选):如果存在多个相同类型的输入:
- 自动模式:按名称相似度匹配(变量名 vs 文件名)
- 交互模式:询问用户文件与输入的对应关系
- 文件夹到列表:如果文件夹包含单一类型的文件,且存在该类型的列表输入,则将文件夹内容映射到该输入
- 未匹配文件:报告这些文件,并询问是否忽略或映射到特定输入
- 未填充输入:匹配完成后,任何仍无数据的输入可保留为占位符,或用合成数据填充(参考混合策略)
Step D: Copy Files to Output Directory
步骤D:复制文件到输出目录
Copy (or symlink) user files into so uses paths relative to the output directory. This keeps the pipeline directory self-contained. Only create the subdirectory if there are actual files to copy.
<output_dir>/inputs/inputs.jsoninputs/Use descriptive filenames: if the input variable is , copy to (preserving original extension).
invoice<output_dir>/inputs/invoice.pdf将用户文件复制(或创建符号链接)到,以便使用相对于输出目录的路径。这样可使流水线目录保持独立。仅当有实际文件需要复制时,才创建子目录。
<output_dir>/inputs/inputs.jsoninputs/使用描述性文件名:如果输入变量为,则复制到(保留原扩展名)。
invoice<output_dir>/inputs/invoice.pdfStep E: Build Content Objects
步骤E:构建内容对象
For each matched file, construct the proper content object:
Document input:
json
{
"concept": "native.Document",
"content": {
"url": "<output_dir>/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
}Image input:
json
{
"concept": "native.Image",
"content": {
"url": "<output_dir>/inputs/photo.jpg",
"mime_type": "image/jpeg"
}
}Text input (from or file — read the file content):
.txt.mdjson
{
"concept": "native.Text",
"content": {
"text": "<actual file content read from the .txt/.md file>"
}
}Image list input (from folder):
json
{
"concept": "native.Image",
"content": [
{"url": "<output_dir>/inputs/img_001.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_002.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_003.png", "mime_type": "image/png"}
]
}为每个匹配的文件构建正确的内容对象:
文档输入:
json
{
"concept": "native.Document",
"content": {
"url": "<output_dir>/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
}图片输入:
json
{
"concept": "native.Image",
"content": {
"url": "<output_dir>/inputs/photo.jpg",
"mime_type": "image/jpeg"
}
}文本输入(来自或文件 — 读取文件内容):
.txt.mdjson
{
"concept": "native.Text",
"content": {
"text": "<从.txt/.md文件读取的实际内容>"
}
}图片列表输入(来自文件夹):
json
{
"concept": "native.Image",
"content": [
{"url": "<output_dir>/inputs/img_001.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_002.jpg", "mime_type": "image/jpeg"},
{"url": "<output_dir>/inputs/img_003.png", "mime_type": "image/png"}
]
}Step F: Assemble and Save
步骤F:组装并保存
Combine all content objects into a single and save to (next to ).
inputs.json<output_dir>/inputs.jsonbundle.mthds将所有内容对象组合成单个,并保存到(与同级)。
inputs.json<output_dir>/inputs.jsonbundle.mthdsStep G: Report
步骤G:报告
Show the user:
- Which files were matched to which inputs
- Any unfilled inputs (offer synthetic or placeholder)
- The final content
inputs.json - Path to the saved file
向用户展示:
- 文件与输入的对应关系
- 任何未填充的输入(提供合成数据或占位符选项)
- 最终的内容
inputs.json - 保存的文件路径
Mixed Strategy
混合策略
Combines user data with synthetic generation for any remaining gaps.
- Follow User Data Strategy Steps A-E to match user files
- For each unfilled input, apply Synthetic Strategy
- Assemble the complete combining both sources
inputs.json - Report which inputs came from user data and which were synthesized
Image Generation
图片生成
Use the Pipelex pipeline to generate test images.
synthesize_imageCommand:
First, create an input file (e.g., ):
<output_dir>/image_request.jsonjson
{
"request": {
"concept": "synthetic_data.ImageRequest",
"content": {
"category": "<category>",
"description": "<optional description>"
}
}
}Then run:
bash
mthds-agent pipelex run pipe pipelex/builder/synthetic_inputs/synthesize_image.mthds --inputs <output_dir>/image_request.jsonImage Categories:
| Category | Use For | Example Description |
|---|---|---|
| Real-world photos, product images, portraits | "A professional headshot of a business person" |
| UI mockups, app screens, web pages | "A mobile banking app dashboard showing account balance" |
| Data visualizations, graphs, plots | "A bar chart showing quarterly sales by region" |
| Technical diagrams, flowcharts, architecture | "A system architecture diagram with microservices" |
| Scanned papers, receipts, forms | "A scanned invoice from a hardware store" |
| Handwritten notes, signatures | "Handwritten meeting notes on lined paper" |
Output: The pipeline saves the generated image to and returns the file path.
<output_dir>/inputs/For image synthesis error handling, see Error Handling Reference.
使用 Pipelex流水线生成测试图片。
synthesize_image命令:
首先,创建输入文件(例如:):
<output_dir>/image_request.jsonjson
{
"request": {
"concept": "synthetic_data.ImageRequest",
"content": {
"category": "<category>",
"description": "<可选描述>"
}
}
}然后运行:
bash
mthds-agent pipelex run pipe pipelex/builder/synthetic_inputs/synthesize_image.mthds --inputs <output_dir>/image_request.json图片类别:
| 类别 | 用途 | 示例描述 |
|---|---|---|
| 真实照片、产品图片、肖像 | "商务人士的专业头像" |
| UI原型、应用界面、网页 | "显示账户余额的移动银行应用仪表盘" |
| 数据可视化、图表、图形 | "按区域划分的季度销售额柱状图" |
| 技术图表、流程图、架构图 | "包含微服务的系统架构图" |
| 扫描文档、收据、表单 | "五金店的扫描发票" |
| 手写笔记、签名 | "写在横格纸上的手写会议笔记" |
输出:流水线将生成的图片保存到并返回文件路径。
<output_dir>/inputs/图片合成的错误处理请参考错误处理参考文档。
Document Generation
文档生成
Generate test documents based on the document type needed.
根据所需的文档类型生成测试文档。
PDF Documents
PDF文档
is a dependency ofreportlab— always available, no additional installation needed.pipelex
是reportlab的依赖项 — 始终可用,无需额外安装。pipelex
Basic PDF (Canvas API)
基础PDF(Canvas API)
python
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("<output_dir>/inputs/test_document.pdf", pagesize=letter)
width, height = letterpython
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("<output_dir>/inputs/test_document.pdf", pagesize=letter)
width, height = letterAdd text
添加文本
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")
Add a line
添加线条
c.line(100, height - 140, 400, height - 140)
c.line(100, height - 140, 400, height - 140)
Save
保存
c.save()
undefinedc.save()
undefinedMulti-Page PDF (Platypus)
多页PDF(Platypus)
python
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []python
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []Add content
添加内容
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))
body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())
title = Paragraph("Report Title", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))
body = Paragraph("This is the body of the report. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())
Page 2
第2页
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Content for page 2", styles['Normal']))
Build PDF
构建PDF
doc.build(story)
undefineddoc.build(story)
undefinedProfessional Reports with Tables
带表格的专业报告
python
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colorspython
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib import colorsSample data
样本数据
data = [
['Product', 'Q1', 'Q2', 'Q3', 'Q4'],
['Widgets', '120', '135', '142', '158'],
['Gadgets', '85', '92', '98', '105']
]
data = [
['Product', 'Q1', 'Q2', 'Q3', 'Q4'],
['Widgets', '120', '135', '142', '158'],
['Gadgets', '85', '92', '98', '105']
]
Create PDF with table
创建带表格的PDF
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf")
elements = []
doc = SimpleDocTemplate("<output_dir>/inputs/test_report.pdf")
elements = []
Add title
添加标题
styles = getSampleStyleSheet()
title = Paragraph("Quarterly Sales Report", styles['Title'])
elements.append(title)
styles = getSampleStyleSheet()
title = Paragraph("Quarterly Sales Report", styles['Title'])
elements.append(title)
Add table with advanced styling
添加带高级样式的表格
table = Table(data)
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 14),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black)
]))
elements.append(table)
doc.build(elements)
**Last resort** — use a public test PDF URL:
```json
{
"url": "https://www.w3.org/WAI/WCAG21/Techniques/pdf/img/table-word.pdf",
"mime_type": "application/pdf"
}table = Table(data)
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 14),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black)
]))
elements.append(table)
doc.build(elements)
**最后手段** — 使用公开测试PDF URL:
```json
{
"url": "https://www.w3.org/WAI/WCAG21/Techniques/pdf/img/table-word.pdf",
"mime_type": "application/pdf"
}Word Documents (DOCX)
Word文档(DOCX)
If skill is available:
example-skills:docxUse the /docx skill to create a Word document with the following content:
[Describe the document content, structure, and formatting]
Save to: <output_dir>/inputs/<filename>.docxIf skill is NOT available, create using Python:
python
undefined如果功能可用:
example-skills:docx使用/docx功能创建包含以下内容的Word文档:
[描述文档内容、结构和格式]
保存到:<output_dir>/inputs/<filename>.docx如果功能不可用,使用Python创建:
python
undefinedRequires: pip install python-docx
依赖:pip install python-docx
from docx import Document
doc = Document()
doc.add_heading('Test Document', 0)
doc.add_paragraph('This is synthetic test content for method testing.')
from docx import Document
doc = Document()
doc.add_heading('Test Document', 0)
doc.add_paragraph('This is synthetic test content for method testing.')
Add more content as needed
根据需要添加更多内容
doc.save('<output_dir>/inputs/test_document.docx')
undefineddoc.save('<output_dir>/inputs/test_document.docx')
undefinedSpreadsheets (XLSX)
电子表格(XLSX)
If skill is available:
example-skills:xlsxUse the /xlsx skill to create a spreadsheet with the following data:
[Describe columns, rows, and sample data]
Save to: <output_dir>/inputs/<filename>.xlsxIf skill is NOT available, create using Python:
python
undefined如果功能可用:
example-skills:xlsx使用/xlsx功能创建包含以下数据的电子表格:
[描述列、行和样本数据]
保存到:<output_dir>/inputs/<filename>.xlsx如果功能不可用,使用Python创建:
python
undefinedRequires: pip install openpyxl
依赖:pip install openpyxl
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 'Column1'
ws['B1'] = 'Column2'
ws['A2'] = 'Value1'
ws['B2'] = 'Value2'
wb.save('<output_dir>/inputs/test_spreadsheet.xlsx')
---
**Fallback Strategy:**
1. For PDFs: use `reportlab` (always available via pipelex) with the patterns above
2. For DOCX/XLSX: use the `/docx` or `/xlsx` skill (install from the Anthropic example-skills marketplace if not available)
3. For any format: use public test file URLs as fallback
4. As last resort, ask user to provide test files
---from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 'Column1'
ws['B1'] = 'Column2'
ws['A2'] = 'Value1'
ws['B2'] = 'Value2'
wb.save('<output_dir>/inputs/test_spreadsheet.xlsx')
---
** fallback策略**:
1. 对于PDF:使用`reportlab`(通过pipelex始终可用),采用上述模式
2. 对于DOCX/XLSX:使用`/docx`或`/xlsx`功能(若不可用,从Anthropic example-skills市场安装)
3. 对于任何格式:使用公开测试文件URL作为备用
4. 最后手段:要求用户提供测试文件
---Validate & Run
验证与运行
After assembling the inputs, confirm readiness:
Inputs are ready.has been saved with real values — no placeholders remain.inputs.json
Then offer to run:
bash
undefined组装输入后,确认准备就绪:
输入已准备完成。已保存真实值 — 无占位符剩余。inputs.json
然后提供运行选项:
bash
undefinedDry run with the prepared inputs (directory mode auto-detects bundle, inputs, library dir)
使用准备好的输入进行试运行(目录模式自动检测包、输入和库目录)
mthds-agent pipelex run pipe <bundle-dir>/ --dry-run
mthds-agent pipelex run pipe <bundle-dir>/ --dry-run
Full run (uses actual AI/extraction models)
完整运行(使用实际AI/提取模型)
mthds-agent pipelex run pipe <bundle-dir>/
---mthds-agent pipelex run pipe <bundle-dir>/
---Native Concept Content Structures
原生概念内容结构
Text
文本
json
{"text": "The actual text content"}json
{"text": "实际文本内容"}Number
数字
json
{"number": 42}json
{"number": 42}Image
图片
json
{
"url": "/path/to/image.jpg",
"caption": "Optional description",
"mime_type": "image/jpeg"
}json
{
"url": "/path/to/image.jpg",
"caption": "可选描述",
"mime_type": "image/jpeg"
}Document
文档
json
{
"url": "/path/to/document.pdf",
"mime_type": "application/pdf"
}json
{
"url": "/path/to/document.pdf",
"mime_type": "application/pdf"
}TextAndImages
文本与图片
json
{
"text": {"text": "Main text content"},
"images": [
{"url": "/path/to/img1.png", "caption": "Figure 1"}
]
}json
{
"text": {"text": "主要文本内容"},
"images": [
{"url": "/path/to/img1.png", "caption": "图1"}
]
}Page
页面
json
{
"text_and_images": {
"text": {"text": "Page content..."},
"images": []
},
"page_view": null
}json
{
"text_and_images": {
"text": {"text": "页面内容..."},
"images": []
},
"page_view": null
}JSON
JSON
json
{"json_obj": {"key": "value", "nested": {"data": 123}}}json
{"json_obj": {"key": "value", "nested": {"data": 123}}}Complete Examples
完整示例
Example 1: Template for a Haiku writer
示例1:俳句生成器的模板
Method: Haiku pipeline expecting
theme: Textbash
mthds-agent pipelex inputs pipe mthds-wip/pipeline_01/bundle.mthds -L mthds-wip/pipeline_01/Save the from the output directly to .
inputsmthds-wip/pipeline_01/inputs.json方法:需要的俳句流水线
theme: Textbash
mthds-agent pipelex inputs pipe mthds-wip/pipeline_01/bundle.mthds -L mthds-wip/pipeline_01/将输出中的直接保存到。
inputsmthds-wip/pipeline_01/inputs.jsonExample 2: Synthetic data for an image analysis pipeline
示例2:图片分析流水线的合成数据
Method: Image analyzer expecting and
image: Imageanalysis_prompt: Text- Get schema, identify needs: test photograph + instruction text
- Generate image via with category
synthesize_image.mthdsphotograph - Write analysis prompt text matching the method context
- Assemble:
json
{
"image": {
"concept": "native.Image",
"content": {
"url": "mthds-wip/pipeline_01/inputs/city_street.jpg",
"mime_type": "image/jpeg"
}
},
"analysis_prompt": {
"concept": "native.Text",
"content": {
"text": "Analyze this street scene. Count visible people and describe the atmosphere."
}
}
}方法:需要和的图片分析器
image: Imageanalysis_prompt: Text- 获取Schema,确定需求:测试照片 + 指令文本
- 使用生成
synthesize_image.mthds类别的图片photograph - 编写符合方法上下文的分析提示文本
- 组装:
json
{
"image": {
"concept": "native.Image",
"content": {
"url": "mthds-wip/pipeline_01/inputs/city_street.jpg",
"mime_type": "image/jpeg"
}
},
"analysis_prompt": {
"concept": "native.Text",
"content": {
"text": "分析此街景。统计可见人数并描述氛围。"
}
}
}Example 3: User-provided invoice PDF
示例3:用户提供的发票PDF
Method: Invoice processor expecting and
invoice: Documentinstructions: TextUser says: "Use my file "
~/documents/invoice_march.pdf- Get schema: needs (Document) +
invoice(Text)instructions - Inventory: user provided (PDF = Document type)
invoice_march.pdf - Match: maps to
invoice_march.pdfinput (name similarity + type match)invoice - Copy:
cp ~/documents/invoice_march.pdf mthds-wip/pipeline_01/inputs/invoice.pdf - Unfilled: has no user file. Generate synthetic text: "Extract all line items, totals, and vendor information from this invoice."
instructions - Assemble:
json
{
"invoice": {
"concept": "native.Document",
"content": {
"url": "mthds-wip/pipeline_01/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
},
"instructions": {
"concept": "native.Text",
"content": {
"text": "Extract all line items, totals, and vendor information from this invoice."
}
}
}方法:需要和的发票处理器
invoice: Documentinstructions: Text用户说:“使用我的文件”
~/documents/invoice_march.pdf- 获取Schema:需要(Document) +
invoice(Text)instructions - 清点:用户提供了(PDF = Document类型)
invoice_march.pdf - 匹配:映射到
invoice_march.pdf输入(名称相似度 + 类型匹配)invoice - 复制:
cp ~/documents/invoice_march.pdf mthds-wip/pipeline_01/inputs/invoice.pdf - 未填充:无用户文件。生成合成文本:“从此发票中提取所有行项目、总计和供应商信息。”
instructions - 组装:
json
{
"invoice": {
"concept": "native.Document",
"content": {
"url": "mthds-wip/pipeline_01/inputs/invoice.pdf",
"mime_type": "application/pdf"
}
},
"instructions": {
"concept": "native.Text",
"content": {
"text": "从此发票中提取所有行项目、总计和供应商信息。"
}
}
}Example 4: Folder of images for batch processing
示例4:用于批量处理的图片文件夹
Method: Batch image captioner expecting
images: Image[]User says: "Use the photos in "
./product-photos/- Get schema: needs (Image[])
images - Expand folder: contains
./product-photos/,shoe.jpg,hat.pngbag.jpg - Copy all to
<output_dir>/inputs/ - Assemble:
json
{
"images": {
"concept": "native.Image",
"content": [
{"url": "mthds-wip/pipeline_01/inputs/shoe.jpg", "mime_type": "image/jpeg"},
{"url": "mthds-wip/pipeline_01/inputs/hat.png", "mime_type": "image/png"},
{"url": "mthds-wip/pipeline_01/inputs/bag.jpg", "mime_type": "image/jpeg"}
]
}
}方法:需要的批量图片标注器
images: Image[]用户说:“使用中的照片”
./product-photos/- 获取Schema:需要(Image[])
images - 展开文件夹:包含
./product-photos/、shoe.jpg、hat.pngbag.jpg - 将所有文件复制到
<output_dir>/inputs/ - 组装:
json
{
"images": {
"concept": "native.Image",
"content": [
{"url": "mthds-wip/pipeline_01/inputs/shoe.jpg", "mime_type": "image/jpeg"},
{"url": "mthds-wip/pipeline_01/inputs/hat.png", "mime_type": "image/png"},
{"url": "mthds-wip/pipeline_01/inputs/bag.jpg", "mime_type": "image/jpeg"}
]
}
}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 concept definitions and syntax
- Native Content Types — read for the full attribute reference of each native content type when assembling input JSON
- 错误处理 — 当CLI返回错误时,阅读此文以确定恢复方式
- MTHDS Agent指南 — 阅读此文以了解CLI命令语法或输出格式细节
- MTHDS语言参考 — 阅读此文以了解概念定义和语法
- 原生内容类型 — 组装输入JSON时,阅读此文以了解每个原生内容类型的完整属性参考