pkg
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseManage MTHDS packages
管理MTHDS包
Initialize, add dependencies, lock, install, update, and validate MTHDS packages using the CLI.
mthds使用 CLI初始化、添加依赖、锁定、安装、更新及验证MTHDS包。
mthdsProcess
操作流程
Prerequisite: See CLI Prerequisites
前提条件:查看CLI 前提条件
1. Initialize a package
1. 初始化包
Create a manifest:
METHODS.tomlbash
mthds package init --directory <pkg-dir>Use to overwrite an existing manifest:
--forcebash
mthds package init --force --directory <pkg-dir>创建清单文件:
METHODS.tomlbash
mthds package init --directory <pkg-dir>使用参数覆盖已有的清单文件:
--forcebash
mthds package init --force --directory <pkg-dir>2. Configure exports
2. 配置导出项
Exports declare which pipes the package makes available to consumers. They are organized by domain in :
METHODS.tomltoml
[exports.restaurant_analysis]
pipes = ["present_restaurant", "extract_menu", "analyze_menu"]To configure exports:
- Read the bundle(s) in the package to find the domain codes and pipe codes defined inside them
.mthds - Edit to add an
METHODS.tomlsection for each domain, listing the pipe codes to export[exports.<domain>]
Rules:
- The of each bundle is auto-exported — you do not need to list it unless you want to be explicit
main_pipe - Concepts are always public and do not need to be listed in exports
- Each section requires a
[exports.<domain>]key with a list of pipe code stringspipes
导出项用于声明包向使用者开放的管道。它们在中按领域进行组织:
METHODS.tomltoml
[exports.restaurant_analysis]
pipes = ["present_restaurant", "extract_menu", "analyze_menu"]配置导出项的步骤:
- 读取包中的包文件,找到其中定义的领域代码和管道代码
.mthds - 编辑,为每个领域添加
METHODS.toml章节,并列出要导出的管道代码[exports.<domain>]
规则:
- 每个包文件的会自动导出——除非你想明确声明,否则无需列出
main_pipe - 概念始终是公开的,无需在导出项中列出
- 每个章节需要包含
[exports.<domain>]键,其值为管道代码字符串组成的列表pipes
3. Add dependencies
3. 添加依赖
Add a dependency to the manifest:
bash
mthds package add <address> --directory <pkg-dir>Options:
| Flag | Purpose | Example |
|---|---|---|
| Set a local alias for the dependency | |
| Pin a specific version | |
| Use a local path dependency | |
向清单文件中添加依赖:
bash
mthds package add <address> --directory <pkg-dir>选项:
| 标志 | 用途 | 示例 |
|---|---|---|
| 为依赖设置本地别名 | |
| 固定依赖的特定版本 | |
| 使用本地路径依赖 | |
4. Lock dependencies
4. 锁定依赖
Resolve all dependencies and generate a lockfile:
bash
mthds package lock --directory <pkg-dir>解析所有依赖并生成锁定文件:
bash
mthds package lock --directory <pkg-dir>5. Install from lockfile
5. 从锁定文件安装
Install dependencies from the existing lockfile:
bash
mthds package install --directory <pkg-dir>从已有的锁定文件安装依赖:
bash
mthds package install --directory <pkg-dir>6. Update dependencies
6. 更新依赖
Re-resolve dependencies and update the lockfile:
bash
mthds package update --directory <pkg-dir>重新解析依赖并更新锁定文件:
bash
mthds package update --directory <pkg-dir>7. List package manifest
7. 列出包清单
Display the current package manifest:
bash
mthds package list --directory <pkg-dir>显示当前的包清单:
bash
mthds package list --directory <pkg-dir>8. Validate package manifest
8. 验证包清单
Validate the package manifest:
METHODS.tomlbash
mthds package validate --directory <pkg-dir>Options:
| Flag | Purpose | Example |
|---|---|---|
| Validate all packages in the workspace | |
| Specify the runner for validation | |
Target a specific package:
bash
mthds package validate <target> --directory <pkg-dir>Note:validates themthds package validatepackage manifest. To validateMETHODS.tomlbundle semantics, use.mthds(see /check skill).mthds-agent pipelex validate
验证包清单:
METHODS.tomlbash
mthds package validate --directory <pkg-dir>选项:
| 标志 | 用途 | 示例 |
|---|---|---|
| 验证工作区中的所有包 | |
| 指定用于验证的运行器 | |
指定目标包进行验证:
bash
mthds package validate <target> --directory <pkg-dir>注意:用于验证mthds package validate包清单。若要验证METHODS.toml包文件的语义,请使用.mthds(查看/check技能)。mthds-agent pipelex validate
The --directory
option
--directory--directory
选项
--directoryAll commands accept (short: ) to target a package directory other than the shell's current working directory. This is essential when the agent's CWD differs from the package location.
mthds package--directory <path>-dbash
undefined所有命令都支持(简写:),用于指定包目录而非当前Shell的工作目录。当Agent的当前工作目录与包所在位置不同时,该选项至关重要。
mthds package--directory <path>-dbash
undefinedFrom any directory, target a specific package
从任意目录,指定目标包
mthds package init --directory mthds-wip/restaurant_presenter/
mthds package validate --directory mthds-wip/restaurant_presenter/
If `--directory` is omitted, commands default to the current working directory.mthds package init --directory mthds-wip/restaurant_presenter/
mthds package validate --directory mthds-wip/restaurant_presenter/
若省略`--directory`,命令默认使用当前工作目录。Common Workflows
常见工作流
Starting a new package:
- — create the manifest
mthds package init --directory <pkg-dir> - Read bundles in the package to extract domain codes and pipe codes
.mthds - Edit to set the correct address, description, and
METHODS.tomlsections[exports.<domain>] - — validate the manifest
mthds package validate --directory <pkg-dir>
Adding dependencies to an existing package:
- — add the dependency
mthds package add <address> --directory <pkg-dir> - — resolve and lock
mthds package lock --directory <pkg-dir> - — install from lockfile
mthds package install --directory <pkg-dir>
Updating dependencies:
- — re-resolve and update lockfile
mthds package update --directory <pkg-dir> - — install updated deps
mthds package install --directory <pkg-dir>
创建新包:
- — 创建清单文件
mthds package init --directory <pkg-dir> - 读取包中的包文件,提取领域代码和管道代码
.mthds - 编辑,设置正确的地址、描述和
METHODS.toml章节[exports.<domain>] - — 验证清单文件
mthds package validate --directory <pkg-dir>
为已有包添加依赖:
- — 添加依赖
mthds package add <address> --directory <pkg-dir> - — 解析并锁定依赖
mthds package lock --directory <pkg-dir> - — 从锁定文件安装
mthds package install --directory <pkg-dir>
更新依赖:
- — 重新解析并更新锁定文件
mthds package update --directory <pkg-dir> - — 安装更新后的依赖
mthds package install --directory <pkg-dir>
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
- CLI 前提条件 — 启动技能时查看,检查CLI是否可用
- 错误处理 — 当CLI返回错误时查看,确定恢复方案
- MTHDS Agent指南 — 查看CLI命令语法或输出格式详情