pflow-commit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
On any failure (non-zero exit from a Shell command OR an
error
field in JSON output) print
⚠️ <error message>
and stop immediately.
任何失败情况(Shell命令返回非零值或JSON输出中包含
error
字段)下,打印
⚠️ <error message>
并立即停止。

Steps

步骤

  1. Get the context:
    .agents/skills/pflow-commit/scripts/git-commit-context.sh
    . If the output is
    No changes detected.
    , tell the user there is nothing to commit and stop.
  2. Compose MESSAGE (see format below) using ONLY the step-1 output — no other sources.
  3. Run the commit command in escalated execution mode from the start (for
    .git
    write access):
    .agents/skills/pflow-commit/scripts/git-commit-push.sh --message "MESSAGE"
    . The script prints JSON:
    {commit_hash, branch_name, push_status}
    on success, or
    {…, error:{step, message}}
    on failure. If
    error
    is present, print
    ⚠️ <error.message>
    and stop.
  4. Reply exactly, substituting values from the JSON:
    text
    ✅ Commit message:
    MESSAGE
    
    ✅ Committed and pushed:
    Hash: <commit_hash> | Branch: <branch_name> | Status: <push_status>
  1. 获取上下文:执行
    .agents/skills/pflow-commit/scripts/git-commit-context.sh
    。如果输出为
    No changes detected.
    ,告知用户没有内容可提交并停止。
  2. 仅使用步骤1的输出来编写提交信息MESSAGE(格式见下文)——不得使用其他来源的信息。
  3. 从一开始就以提升权限的执行模式运行提交命令(以获取
    .git
    写入权限):
    .agents/skills/pflow-commit/scripts/git-commit-push.sh --message "MESSAGE"
    。脚本执行成功时会输出JSON:
    {commit_hash, branch_name, push_status}
    ;失败时会输出
    {…, error:{step, message}}
    。如果存在
    error
    字段,打印
    ⚠️ <error.message>
    并停止。
  4. 严格按照以下格式回复,替换JSON中的对应值:
    text
    ✅ Commit message:
    MESSAGE
    
    ✅ Committed and pushed:
    Hash: <commit_hash> | Branch: <branch_name> | Status: <push_status>

Gotchas

注意事项

  • git-commit-push.sh
    runs
    git add -A
    — the commit includes ALL working-tree changes, not just the ones your message describes. Account for this when composing the text.
  • The script now prechecks
    .git
    write access and stale
    index.lock
    ; if it fails, rerun in escalated execution context.
  • The step-1 output is the ONLY input. Do not enrich or verify it: no reading files, no
    git
    commands, no grep/search, no conversation history, no sub-agents. If the context is incomplete or truncated, write the message from what it does contain — describe only what is visible and stay generic about the rest. Never ask the user for more context.
  • The context from step 1 is truncated: at most 50 lines per file and 600 lines total. Large diffs are shown only partially — don't draw conclusions about the cut-off part.
  • push_status
    :
    pushed
    (upstream already existed) or
    pushed_with_upstream
    (created via
    git push -u origin <branch>
    ).
  • The push script does not write git errors to stderr — they go into the JSON
    error
    field. Always check it (step 3), otherwise a failed commit/push goes unnoticed.
  • git-commit-push.sh
    会执行
    git add -A
    ——提交会包含工作树中的所有变更,而不仅仅是提交信息中描述的内容。编写文本时要考虑到这一点。
  • 脚本现在会预先检查
    .git
    写入权限和过期的
    index.lock
    ;如果检查失败,需在提升权限的执行环境中重新运行。
  • 步骤1的输出是唯一输入来源。不得补充或验证该输入:不得读取文件、执行
    git
    命令、进行grep/搜索、查看对话历史或调用子Agent。如果上下文不完整或被截断,仅根据现有内容编写提交信息——只描述可见部分,其余部分保持通用表述。切勿向用户索要更多上下文。
  • 步骤1的上下文会被截断:每个文件最多显示50行,总计最多600行。大型差异仅会部分显示——不要对被截断的内容做出推断。
  • push_status
    的取值:
    pushed
    (上游分支已存在)或
    pushed_with_upstream
    (通过
    git push -u origin <branch>
    创建上游分支)。
  • 推送脚本不会将Git错误写入stderr——错误信息会存入JSON的
    error
    字段。务必检查该字段(步骤3),否则提交/推送失败可能会被忽略。

Message format (Conventional Commits)

提交信息格式(Conventional Commits)

<type>[(scope)][!]: <description>
plus an optional blank line, body, and footer(s).
  • Language: the entire message (description, body, and footers) MUST always be written in English — regardless of the conversation language — unless the user explicitly requests another language.
  • Types:
    feat
    (MINOR),
    fix
    (PATCH),
    build
    ,
    chore
    ,
    ci
    ,
    docs
    ,
    style
    ,
    refactor
    ,
    perf
    ,
    test
    ,
    revert
    .
  • Breaking change:
    !
    in the header or a
    BREAKING CHANGE: ...
    footer (MAJOR).
  • scope
    — only when it adds value. Pick the narrowest correct type; split unrelated types into separate commits.
  • Description — short, in English, imperative mood ("add", not "added").
Examples:
feat: add user page
·
fix(parser): handle empty input
·
feat!: remove legacy auth flow
<type>[(scope)][!]: <description>
,可选择性添加空行、正文和页脚。
  • 语言要求:整个提交信息(描述、正文和页脚)必须始终使用英文——无论对话使用何种语言——除非用户明确要求使用其他语言。
  • 类型:
    feat
    (MINOR版本)、
    fix
    (PATCH版本)、
    build
    、
    chore
    、
    ci
    、
    docs
    、
    style
    、
    refactor
    、
    perf
    、
    test
    、
    revert
    。
  • 破坏性变更:在标题中添加
    !
    或在页脚中添加
    BREAKING CHANGE: ...
    (对应MAJOR版本)。
  • scope
    ——仅在能增加信息价值时使用。选择最精准的类型;将不相关的类型拆分为单独的提交。
  • 描述——简短、英文、祈使语气(使用“add”而非“added”)。
示例:
feat: add user page
·
fix(parser): handle empty input
·
feat!: remove legacy auth flow