wecomcli-shared

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

wecom-cli 公共前置检查

wecom-cli Common Pre-checks

本技能提供所有
wecomcli-*
业务技能共用的 CLI 安装、版本与授权检查,以及通用输出约束。每次准备执行任意
wecom-cli
命令前,先完成本技能;检查通过后,再回到对应业务技能执行。
本技能不能代替具体业务技能。处理联系人、文档、表格、日程、会议、待办、邮件、微盘、消息或媒体请求时,必须同时读取对应业务技能。
This skill provides shared CLI installation, version and authorization checks for all
wecomcli-*
business skills, as well as general output constraints. Before preparing to execute any
wecom-cli
command, complete this skill first; after passing the check, return to the corresponding business skill for execution.
This skill cannot replace specific business skills. When handling requests related to contacts, documents, spreadsheets, calendars, meetings, to-dos, emails, WeCom Drive, messages or media, you must read the corresponding business skill at the same time.

Step 1:检查 CLI 安装与版本

Step 1: Check CLI Installation and Version

bash
wecom-cli --version
  • 命令成功,且输出中的版本号不低于
    1.1.0
    → 继续 Step 2。
  • 命令不存在、执行报错或版本号低于
    1.1.0
    → 执行安装/升级:
bash
npm install -g @wecom/cli
安装完成后重新执行
wecom-cli --version
;仍失败或版本仍低于
1.1.0
时停止业务操作,并把错误告知用户。
bash
wecom-cli --version
  • If the command succeeds and the version number in the output is not lower than
    1.1.0
    → proceed to Step 2.
  • If the command does not exist, execution fails, or the version number is lower than
    1.1.0
    → perform installation/upgrade:
bash
npm install -g @wecom/cli
After installation, re-execute
wecom-cli --version
; if it still fails or the version is still lower than
1.1.0
, stop business operations and inform the user of the error.

Step 2:检查授权状态

Step 2: Check Authorization Status

bash
wecom-cli auth show --status
  • 输出
    authorized
    → 前置检查完成,可以执行具体业务命令。
  • 输出
    unauthorized
    → 执行 Step 3。
  • 命令报错或输出不是上述状态 → 停止业务操作,并把错误告知用户,不要猜测授权状态。
bash
wecom-cli auth show --status
  • Output
    authorized
    → pre-check is completed, and specific business commands can be executed.
  • Output
    unauthorized
    → execute Step 3.
  • If the command reports an error or the output is not in the above states → stop business operations, inform the user of the error, and do not guess the authorization status.

Step 3:初始化凭证(仅未授权时)

Step 3: Initialize Credentials (Only When Unauthorized)

bash
wecom-cli auth init
该命令会展示授权链接和二维码,并等待用户使用企业微信扫码。授权成功后命令自动退出,仅需初始化一次。
初始化完成后重新执行:
bash
wecom-cli auth show --status
仅当输出
authorized
时,才能继续执行具体业务命令。
bash
wecom-cli auth init
This command will display an authorization link and QR code, and wait for the user to scan it with WeCom. The command will exit automatically after successful authorization, and initialization only needs to be done once.
After initialization, re-execute:
bash
wecom-cli auth show --status
Only when the output is
authorized
can you continue to execute specific business commands.

通用输出约束:ID 类字段禁止外露

General Output Constraint: Prohibition of Exposing ID-type Fields

本约束对所有
wecomcli-*
技能生效,优先级高于各业务技能的输出格式,且不因用户主动索要而放宽。
  • 禁止:你的最终回复禁止出现
    userid
    /
    open_vid
    /
    department_id
    /
    chat_id
    等 ID 标识。凡是接口返回的内部标识(含
    mail_id
    /
    media_id
    /
    file_id
    /
    space_id
    /
    folder_id
    /
    docid
    /
    content_id
    /
    msg_id
    /
    cursor
    /
    next_cursor
    等,命名上以
    _id
    结尾或语义上属于机器标识的字段一律视为 ID)都只能在内部流转,用于后续接口调用。
  • 必须:你的思考过程和最终回复必须使用可读名称,如
    name
    /
    username
    /
    external_username
    / 部门名 / 邮箱 /
    subject
    /
    doc_name
    /
    chat_name
    /
    title
    tool_result
    返回的内容。
  • 接口只返回 ID 而没有可读名称时,先调用对应技能(如
    wecomcli-contact
    解析人员)换取可读名称;确实无法换取时,用自然语言描述该对象(如「上一封日报邮件」「你刚上传的那个文件」)来指代,禁止退化为展示 ID。
  • 需要用户在多个候选中选择时,用序号 + 可读信息(名称 / 主题 / 时间 / 路径等)构造候选列表,禁止用 ID 作为区分依据让用户辨认。
  • 用户直接要求「把 ID 给我」「打印 mail_id」时,说明该标识属于内部字段不便提供,并改用可读信息或继续帮其完成实际操作。
  • 可读链接(如文档
    doc_url
    、微盘分享链接)不属于本约束限制范围,可按各业务技能规定正常展示,即使链接本身包含标识字符串。
This constraint applies to all
wecomcli-*
skills, with higher priority than the output format of each business skill, and will not be relaxed even if the user actively requests it.
  • Prohibited: Your final reply must not contain ID identifiers such as
    userid
    /
    open_vid
    /
    department_id
    /
    chat_id
    . All internal identifiers returned by the interface (including
    mail_id
    /
    media_id
    /
    file_id
    /
    space_id
    /
    folder_id
    /
    docid
    /
    content_id
    /
    msg_id
    /
    cursor
    /
    next_cursor
    , etc. Any field ending with
    _id
    or semantically belonging to a machine identifier is considered an ID) can only be circulated internally for subsequent interface calls.
  • Required: Your thinking process and final reply must use readable names, such as
    name
    /
    username
    /
    external_username
    / department name / email /
    subject
    /
    doc_name
    /
    chat_name
    /
    title
    and other content returned by
    tool_result
    .
  • When the interface only returns IDs without readable names, first call the corresponding skill (such as
    wecomcli-contact
    to parse personnel) to obtain readable names; if it is indeed impossible to obtain, refer to the object with natural language descriptions (such as "the previous daily report email" "the file you just uploaded") instead of reverting to displaying IDs.
  • When requiring users to choose among multiple candidates, construct a candidate list with serial numbers + readable information (name / subject / time / path, etc.), and prohibit using IDs as the basis for distinction for users to identify.
  • When the user directly requests "give me the ID" "print mail_id", explain that this identifier is an internal field and not convenient to provide, and instead use readable information or continue to help them complete the actual operation.
  • Readable links (such as document
    doc_url
    , WeCom Drive sharing links) are not restricted by this constraint and can be displayed normally as specified by each business skill, even if the link itself contains identification strings.

执行规则

Execution Rules

  • 已安装、版本达标且已授权时,不重复安装或初始化。
  • 安装、升级、初始化或复查失败时,不执行后续业务命令。
  • 本技能不定义任何联系人、文档、表格、日程、会议、待办、邮件、微盘、消息或媒体接口参数;具体命令必须回到对应业务技能读取。
  • 执行任何业务命令并组织回复时,同时遵守上方「通用输出约束:ID 类字段禁止外露」。
  • If it is already installed, the version meets the requirements, and it is authorized, do not repeat installation or initialization.
  • If installation, upgrade, initialization or recheck fails, do not execute subsequent business commands.
  • This skill does not define any interface parameters for contacts, documents, spreadsheets, calendars, meetings, to-dos, emails, WeCom Drive, messages or media; specific commands must be read back from the corresponding business skill.
  • When executing any business command and organizing the reply, comply with the above "General Output Constraint: Prohibition of Exposing ID-type Fields" at the same time.

获取个人身份

Obtain Personal Identity

如果操作流程必须获取机器人或授权人身份(姓名、userid等),需要调用
wecom-cli identity whoami
获取。
If the operation process must obtain the identity of the robot or authorized person (name, userid, etc.), you need to call
wecom-cli identity whoami
to obtain it.