diff --git a/README.md b/README.md index 4b149d8..6231c72 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,21 @@ [中文](zh/README.md) | English -This repository publishes bilingual downstream workflow-document templates, the canonical -`workflow-docs-sync` Skill, and its installer. Chinese under `zh/` is the semantic source; `en/` is derived. - -Invoke the Skill once with only the target Git repository, `zh` or `en`, and whether a draft PR should be -created after success: +Copy this exact instruction into Codex while it is open in the target project: ```text -Use $workflow-docs-sync for /absolute/path/to/repository in English. -Do not create a draft PR. +Use $skill-installer to install https://github.com/wlvh/coding-workflow/tree/main/zh/skills/workflow-docs-sync, then immediately use $workflow-docs-sync to synchronize the current project's documentation and create a draft pull request. If the newly installed Skill is not registered in the current session, read SKILL.md from the installation directory returned by the installer and continue in the same turn; do not stop to request a restart. ``` -The repository root contains CI and GitHub infrastructure. Downstream `.github/` templates live under the -language directories and are installed without that leading language prefix. +It infers the current Git root and request language, preserves an unclean original worktree through an +external clean worktree, and creates only a draft PR. A newly installed Skill is read from the installer’s +actual returned directory when the current session has not registered it yet. + +This repository publishes bilingual downstream workflow-document templates, the canonical +`workflow-docs-sync` Skill, and its installer. Chinese under `zh/` is the semantic source; `en/` is derived. + +Detailed behavior and optional repository installation are in the [中文指南](zh/README.md#一句话开始) and +[English guide](en/README.md#one-line-start). For source ownership, edit locations, and validation commands, use the -[Chinese maintainer map](zh/README.md#维护者地图). English template and directory guidance is available in -[en/README.md](en/README.md). +[Chinese maintainer map](zh/README.md#维护者地图). diff --git a/en/README.md b/en/README.md index 02474a6..5390460 100644 --- a/en/README.md +++ b/en/README.md @@ -6,32 +6,94 @@ This directory provides English templates derived from the Chinese semantic sour language-, framework-, and project-neutral. The canonical `workflow-docs-sync` Skill remains under `zh/skills/workflow-docs-sync/` and reads English templates from the pinned upstream commit. -## Quick Start +## One-line start -Invoke the Skill once with the target Git repository, `zh` or `en`, and whether to create a draft PR after -success: +Copy this exact instruction into Codex while it is open in the target project: ```text -Use $workflow-docs-sync for /absolute/path/to/repository in English. -Do not create a draft PR. +Use $skill-installer to install https://github.com/wlvh/coding-workflow/tree/main/zh/skills/workflow-docs-sync, then immediately use $workflow-docs-sync to synchronize the current project's documentation and create a draft pull request. If the newly installed Skill is not registered in the current session, read SKILL.md from the installation directory returned by the installer and continue in the same turn; do not stop to request a restart. ``` +The instruction above is for first-time installation; once the Skill is installed, in another project directly ask `$workflow-docs-sync` to synchronize the current project's documentation and create a draft pull request. + +The user does not provide an absolute target path, `zh` / `en`, a branch name, upstream SHA, or installation +path, and does not need to clean the target worktree first. A successful system `$skill-installer` run prints +`Installed workflow-docs-sync to `. If the current session has not registered the +Skill, use that actual directory from this successful run, read its complete `SKILL.md`, resolve scripts from +the same directory, and continue in the current turn. Do not guess an installation path or wait for another +turn. + +## Defaults + +- Target: use the Git root containing Codex's current working directory. Ask only when the current directory + is not in a Git repository. +- Language: an explicit `zh` / `en` wins; otherwise a Chinese request selects `zh` and any other language + selects `en`. +- PR: an explicit request not to create a PR selects false. Mentioning PR, opening, creating, or submitting a + pull request selects true. No mention selects false. The Skill never marks a PR Ready or merges it. +- Worktree: when a PR is requested, always create an external clean worktree and a unique branch from the + committed HEAD captured at invocation. The Skill does not change ordinary, staged, untracked, or ignored + content in the original worktree, or stash, clean, commit, or overwrite user changes there. + Before the final report, it compares the captured NUL-delimited status and staged entries, then rechecks + type, mode, regular-file SHA-256, or symlink target only for non-clean paths enumerated by the invocation-time + status and ignored-path snapshot. It does not hash the whole repository or compare raw Git index-file bytes. + New ignored paths created concurrently are outside the original set; any other difference proves concurrent + change, not that the Agent caused it. + +The final report states that the sync and PR use the invocation-time committed HEAD and exclude uncommitted +changes from the original worktree. + +A repository with no commit is a `BLOCKER`. If documentation sync passes but the remote, authentication, +push permission, or PR creation fails, the Skill preserves the external worktree, branch, commit, and +out-of-repository PR body. It reports `Documentation sync: PASS`, `Publication: PR_BLOCKED`, and +`Overall: PARTIAL` instead of claiming that a PR exists. + +## Repository installer (optional) + +This path is for maintainers or for installing both Codex and Claude copies; it is not the one-line entrypoint +above. Clone the canonical repository and verify that this upstream checkout is clean. That clean requirement +does not apply to the target project being synchronized: + +```bash +git clone --depth 1 https://github.com/wlvh/coding-workflow.git +cd coding-workflow + +git status --porcelain=v1 --untracked-files=all +python3 zh/scripts/install_skills.py --upstream-dir "$PWD" +``` + +`git status` should print nothing. If it prints an entry, stop and inspect the canonical checkout. A +successful JSON result lists actions for both `~/.agents/skills/workflow-docs-sync/` and +`~/.claude/skills/workflow-docs-sync/`. + +To review and share the Skill as part of a target project, run this from the canonical checkout root: + +```bash +python3 zh/scripts/install_skills.py \ + --scope repo \ + --target-repo "/absolute/path/to/target-repository" \ + --upstream-dir "$PWD" +``` + +The repo-scope target must be exactly a clean Git repository root. Review the resulting Git diff, then commit +it according to the target project's policy. Both scopes replace an existing Skill with the same name, +remove only the obsolete `workflow-docs-sync-review`, store no source state, and do not update automatically. +Studio can also load the canonical `zh/skills/workflow-docs-sync/` directly. + +## Synchronization boundary + The Skill pins target HEAD and upstream SHA, reconstructs facts from current code, configuration, tests, committed artifacts, reproducible results, and necessary Git history, then makes only the document changes those facts require. Existing documents and upstream templates are hypotheses, not evidence. Architecture, Capability / User Behavior, Testing, and Governance are coverage dimensions, not a fixed -agent topology. The main agent is the only target-workspace writer. Test environments follow actual +agent topology. The main agent is the only execution-worktree writer. Test environments follow actual commands, side effects, CI capabilities, and project policy. Review prefers a fresh-context, blind-first independent reviewer. When cognitive isolation is unavailable, the result is reported honestly as self-review. The deterministic checker proves final repository state only, not investigation, test, or review history. -The installer copies only the canonical Skill. Before any target mutation it rejects symlinks, frontmatter -without standard delimiters, and ignored source residue that would otherwise be copied; it stores no source -receipt. - ## Template Contract Markdown project-fill slots use ``; JSON uses strings prefixed with diff --git a/tests/test_workflow_docs_sync.py b/tests/test_workflow_docs_sync.py index d81aa99..29e12ea 100644 --- a/tests/test_workflow_docs_sync.py +++ b/tests/test_workflow_docs_sync.py @@ -37,6 +37,22 @@ ("claude", Path(".claude/skills")), ) OBSOLETE_SKILL = "workflow-docs-sync-review" +ZH_FIRST_USE_PROMPT = ( + "用 $skill-installer 安装 " + "https://github.com/wlvh/coding-workflow/tree/main/zh/skills/" + "workflow-docs-sync,然后立即用 $workflow-docs-sync 同步当前项目文档并创建 " + "draft PR;如果当前会话尚未注册新 Skill,直接读取安装器返回目录中的 " + "SKILL.md 继续执行,不要停下来要求重启。" +) +EN_FIRST_USE_PROMPT = ( + "Use $skill-installer to install https://github.com/wlvh/coding-workflow/" + "tree/main/zh/skills/workflow-docs-sync, then immediately use " + "$workflow-docs-sync to synchronize the current project's documentation " + "and create a draft pull request. If the newly installed Skill is not " + "registered in the current session, read SKILL.md from the installation " + "directory returned by the installer and continue in the same turn; do not " + "stop to request a restart." +) def run_command( @@ -1337,6 +1353,36 @@ def test_scenario_5_repository_distribution_contract() -> None: root_agents = REPO_ROOT / "AGENTS.md" assert root_agents.is_file() and not root_agents.is_symlink() + # 两种公开 prompt 必须位于对应首次使用入口,避免英文入口回退为中文。 + assert ZH_FIRST_USE_PROMPT != EN_FIRST_USE_PROMPT + readme_prompts = ( + ( + REPO_ROOT / "zh/README.md", + "## 一句话开始", + "## 默认行为", + ZH_FIRST_USE_PROMPT, + ), + ( + REPO_ROOT / "en/README.md", + "## One-line start", + "## Defaults", + EN_FIRST_USE_PROMPT, + ), + ( + REPO_ROOT / "README.md", + "Copy this exact instruction into Codex", + "This repository publishes", + EN_FIRST_USE_PROMPT, + ), + ) + for readme, entry_start, entry_end, prompt in readme_prompts: + readme_text = readme.read_text(encoding="utf-8") + assert readme_text.count(prompt) == 1 + start_index = readme_text.index(entry_start) + end_index = readme_text.index(entry_end) + entry_text = readme_text[start_index:end_index] + assert f"```text\n{prompt}\n```" in entry_text + skill_symlinks = sorted( path.relative_to(SKILL_ROOT).as_posix() for path in SKILL_ROOT.rglob("*") @@ -1457,6 +1503,15 @@ def test_scenario_5_repository_distribution_contract() -> None: skill_text = (SKILL_ROOT / "SKILL.md").read_text(encoding="utf-8") assert canonical_anchor not in skill_text + openai_text = (SKILL_ROOT / "agents/openai.yaml").read_text( + encoding="utf-8" + ) + assert openai_text.count("allow_implicit_invocation: false") == 1 + assert "allow_implicit_invocation: true" not in openai_text + assert "当前 Git 根" in openai_text + assert "按当前请求语言选择 zh 或 en" in openai_text + assert "只有用户明确要求时才创建 draft PR" in openai_text + # 机械兜底只覆盖本次真实误植过的八份下游模板与五个精确 token。 internal_context_tokens = ( "disposable clone", @@ -1538,3 +1593,13 @@ def test_scenario_5_repository_distribution_contract() -> None: "finish-submit", ): assert removed_command not in help_result.stdout + + # 默认推断留在 Agent 合同;公开机械 CLI 继续要求显式目标和语言。 + prepare_help = run_command( + args=[sys.executable, str(SYNC_SCRIPT), "prepare", "--help"], + cwd=REPO_ROOT, + environment=None, + ) + assert prepare_help.returncode == 0 + for option in ("--target-repo", "--upstream-dir", "--language {zh,en}"): + assert option in prepare_help.stdout diff --git a/zh/README.md b/zh/README.md index f7edd89..0c88e13 100644 --- a/zh/README.md +++ b/zh/README.md @@ -5,37 +5,88 @@ 本目录提供真正跨语言、跨框架、跨项目的中文核心模板、开发工作流和 canonical `workflow-docs-sync` Skill。 -## Quick Start +## 一句话开始 -用户只调用一次 Skill,只提供目标 Git 仓库、`zh` 或 `en`,以及成功后是否创建 draft PR: +在目标项目的 Codex 中复制这一句: ```text -使用 $workflow-docs-sync 同步 /目标仓库绝对路径,语言 zh,结束后不要创建 draft PR。 +用 $skill-installer 安装 https://github.com/wlvh/coding-workflow/tree/main/zh/skills/workflow-docs-sync,然后立即用 $workflow-docs-sync 同步当前项目文档并创建 draft PR;如果当前会话尚未注册新 Skill,直接读取安装器返回目录中的 SKILL.md 继续执行,不要停下来要求重启。 ``` +上述指令用于首次安装;已经安装后,在其他项目中直接要求 `$workflow-docs-sync` 同步当前项目文档并创建 draft PR。 + +用户不需要提供目标绝对路径、`zh` / `en`、分支名、上游 SHA 或安装路径,也不需要预先清理 +目标工作树。系统 `$skill-installer` 成功时输出 +`Installed workflow-docs-sync to `;当前会话尚未注册 Skill 时,以该次成功 +输出中的真实目录为准,完整读取其中的 `SKILL.md`,从同一目录解析脚本并在本轮继续。不要猜测 +固定安装目录,也不要等待下一轮。 + +## 默认行为 + +- 目标仓库:默认使用 Codex 当前工作目录所属的 Git 根;只有当前目录不在 Git 仓库中时才询问。 +- 语言:显式 `zh` / `en` 优先;否则中文请求使用 `zh`,其他语言请求使用 `en`。 +- PR:明确说不创建 PR 时不创建;提到 PR、提 PR、创建/提交 PR 或 open/create pull request 时 + 创建 draft PR;未提及则不创建。永不自动标记 Ready 或合并。 +- 工作树:请求 PR 时,无论原工作树是否 clean,都从调用时 committed HEAD 在仓库外创建 clean + worktree 和唯一新分支。Skill 不改动原工作树中的普通、staged、untracked 或 ignored 内容,也不 + stash、clean、commit 或覆盖用户修改;最终报告前会重新比较 NUL 分隔的 status 与 staged + entries,并只对调用前 status/ignored 枚举出的非 clean 路径复核类型、mode、普通文件 SHA-256 + 或 symlink target,不扫描整棵仓库,也不比较原始 Git index 文件。调用期间新增的 ignored 路径 + 不在原集合内;其他差异只证明发生了并发变化,不归因于 Agent。 + +最终报告会明确写: + +```text +本次同步与 PR 基于调用时的 committed HEAD;原工作树中的未提交修改未进入调查或 PR。 +``` + +仓库没有 commit 时会报告 `BLOCKER`。同步已经通过、但 remote、认证、push 权限或 PR 创建 +失败时,保留外部 worktree、分支、commit 和仓库外 PR body,并报告 +`Documentation sync: PASS`、`Publication: PR_BLOCKED`、`Overall: PARTIAL`,不会谎称 PR 已创建。 + +## 仓库自带安装器(可选) + +以下是维护者或需要同时安装 Codex / Claude 副本时的可选路径,不是上述一句话入口。先克隆 +canonical 仓库并确认这个上游 checkout clean;这里的 clean 要求不适用于待同步的目标项目: + +```bash +git clone --depth 1 https://github.com/wlvh/coding-workflow.git +cd coding-workflow + +git status --porcelain=v1 --untracked-files=all +python3 zh/scripts/install_skills.py --upstream-dir "$PWD" +``` + +`git status` 应无输出;如果有输出,停止安装并先检查 canonical checkout。成功 JSON 同时列出 +`~/.agents/skills/workflow-docs-sync/` 与 `~/.claude/skills/workflow-docs-sync/` 两项 action。 + +需要把 Skill 作为目标项目的一部分审查和共享时,在 canonical checkout 根目录运行: + +```bash +python3 zh/scripts/install_skills.py \ + --scope repo \ + --target-repo "/目标仓库绝对路径" \ + --upstream-dir "$PWD" +``` + +repo scope 的目标路径必须恰好是 clean Git 根目录;审查生成的 Git diff 后,再按目标项目政策 +提交。两种 scope 都会覆盖已有同名 Skill,并精确移除废弃的 `workflow-docs-sync-review`,不会 +保存来源状态或自动更新。Studio 也可直接加载 canonical `zh/skills/workflow-docs-sync/`。 + +## 同步边界 + Skill 固定目标 HEAD 与上游 SHA,从当前代码、配置、测试、committed artifacts、可重复运行 结果和必要 Git 历史全量重建事实,再只做事实要求的最小文档改写。现有文档与上游模板都是 hypotheses,不是证据。 Architecture、Capability / User Behavior、Testing、Governance 是覆盖维度,不是固定 Agent -拓扑。主 Agent 是目标工作区唯一写入者;测试环境由项目命令、副作用、CI 和项目政策决定。 +拓扑。主 Agent 是执行 worktree 的唯一写入者;测试环境由项目命令、副作用、CI 和项目政策 +决定。 复核优先使用 fresh-context、blind-first independent reviewer。平台不能提供认知隔离时, 最终结果诚实标记 self-review。确定性 checker 只验证最终仓库状态,不证明调查、测试或复核 历史。 -## Skill 安装 - -Studio 可直接加载 canonical `zh/skills/workflow-docs-sync/`。个人或团队安装只复制这一个 -Skill,不保存来源状态;安装器会在任何目标 mutation 前拒绝 symlink、缺少标准分隔的 -frontmatter 和会被复制的 ignored source residue: - -```bash -python3 zh/scripts/install_skills.py --upstream-dir -python3 zh/scripts/install_skills.py --scope repo \ - --target-repo <目标仓库> --upstream-dir -``` - ## Template Contract Markdown project-fill slot 使用 ``,JSON 使用 diff --git a/zh/skills/workflow-docs-sync/SKILL.md b/zh/skills/workflow-docs-sync/SKILL.md index 3f3f9d3..ca0e3a7 100644 --- a/zh/skills/workflow-docs-sync/SKILL.md +++ b/zh/skills/workflow-docs-sync/SKILL.md @@ -1,6 +1,6 @@ --- name: workflow-docs-sync -description: 从目标 Git 仓库的代码、配置、测试和 committed artifacts 重建事实,最小必要改写 wlvh/coding-workflow 的九份核心工作流文档,运行项目真实测试,并以 fresh-context independent review 或诚实 self-review 收口。用户要求同步、补齐或核对 architecture、capability、interact、business guide、testing 或 governance 文档时使用;一次调用只接收目标仓库、zh/en 语言和成功后是否创建 draft PR。 +description: 从当前或用户显式指定的 Git 根重建项目事实,按请求语言默认选择 zh/en,最小必要改写 wlvh/coding-workflow 的九份核心工作流文档并运行真实测试;只有用户明确要求 PR 时,才基于调用时 committed HEAD 在仓库外 clean worktree 创建 draft PR。用户要求同步、补齐或核对 architecture、capability、interact、business guide、testing 或 governance 文档时使用。 --- # Workflow Docs Sync @@ -8,17 +8,120 @@ description: 从目标 Git 仓库的代码、配置、测试和 committed artifa 一次调用完成事实重建、必要文档改写、真实测试、复核和机械检查。现有文档与上游模板都是 待验证声明,不是项目事实来源。主 Agent 是目标工作区唯一写入者。 -## 输入与固定边界 +## 安装后同轮继续 -- 要求目标仓库的 Git 根目录。 -- 语言必须由用户选择,且仅允许 `zh` 或 `en`。 -- 只有用户明确要求时,才在全部 gate 成功后创建 draft PR。 -- 不要求用户提供上游 checkout、SHA、内部命令、Agent 数量或执行顺序。 +当用户在同一条指令中先用 `$skill-installer` 安装本 Skill,再要求立即同步时: -按以下方式准备: +1. 运行安装器 helper。如果它只因默认目标已存在而失败,不覆盖或删除旧目录;用 `--dest + ` 在原 Git 根和任何执行 worktree 外的唯一新目录重试。 +2. 只消费 helper 本次成功输出。对本 Skill,固定前缀是 `Installed workflow-docs-sync to `; + 其后整段文本是安装根。相对路径按安装命令的工作目录立即解析为绝对路径。 +3. 当前会话若已经注册这次返回目录对应的 `$workflow-docs-sync`,显式调用它;否则完整读取安装根中的 + `SKILL.md`,把该文件所在目录作为 ``,从该目录解析 `scripts/sync_docs.py`,并在 + 当前轮继续执行本文件全部流程。 +4. 不得猜测 `~/.codex`、`$CODEX_HOME` 或其他固定安装路径,也不得要求重启、打开新会话或等待 + 下一轮。只有重试后仍得不到本次成功输出及其可验证 Skill 根时才报告 `BLOCKER`;不得把 + 错误中的候选路径冒充本次成功安装结果。 + +## 默认推断,不追问 + +### 目标仓库 + +按以下优先级解析: + +1. 用户显式给出的目标路径;用 `git -C rev-parse --show-toplevel` 归一化为 Git 根。 +2. 否则在当前工作目录执行 `git rev-parse --show-toplevel`,使用其所属 Git 根。 + +只有当前工作目录不在 Git 仓库中,且用户也未提供可解析路径时,才允许询问目标路径。 + +### 语言 + +按以下优先级解析: + +1. 用户显式指定的 `zh` 或 `en`。 +2. 否则由 Agent 按当前请求的自然语言判断:中文请求使用 `zh`,其他语言请求使用 `en`。 + +不得新增语言探测脚本、配置、marker 或状态文件。`sync_docs.py --language` 仍是必填参数,由 +Agent 将上述结果显式传入。 + +### PR 意图 + +按以下优先级解析: + +1. 用户明确说不创建 PR,结果为 `false`。 +2. 否则用户提到 PR、提 PR、创建 PR、提交 PR、`open pull request` 或 + `create pull request`,结果为 `true`。 +3. 未提及,结果为 `false`。 + +`true` 只允许在全部 gate 成功后创建 draft PR;不得自动标记 Ready 或合并。除真正不可恢复的 +`BLOCKER` 外,不得要求用户补充目标绝对路径、语言、分支名、上游 SHA、安装路径、内部命令、 +Agent 数量或执行顺序。 + +## 选择执行工作树 + +先固定解析后的原 Git 根和调用时提交: + +```bash +git -C rev-parse --verify 'HEAD^{commit}' +``` + +仓库没有任何 commit 时报告 `BLOCKER`,不得要求用户先 commit 或 stash。 + +### PR 意图为 true + +无论原工作树是否 clean,都必须: + +1. 在仓库外建立原工作树调用前快照。对原工作树的 Git 读取设置 + `GIT_OPTIONAL_LOCKS=0`,避免只读检查刷新 index。快照必须同时包含: + + - 以下三条命令的 NUL 分隔原始输出: + + ```bash + git -C status --porcelain=v1 -z --untracked-files=all + git -C ls-files --stage -z + git -C ls-files --others --ignored --exclude-standard -z + ``` + + - 取 status 的全部 pathname(rename/copy 的两个 pathname 均计入)与 ignored 输出的并集, + 固定为调用前保护集合。只对该集合逐项使用不跟随 symlink 的 `lstat`,记录相对路径、类型和 + mode;对普通文件记录原始 bytes 的 SHA-256,对 symlink 记录 link target,不存在则记录 + missing sentinel。不保存文件内容副本,不枚举或 hash 整棵仓库。 + +2. 在原仓库之外创建临时根,从调用时 `HEAD` 创建唯一、有意义的新分支和 clean linked + worktree。不得从之后变化的分支 tip、`main` 或 `origin/main` 重建起点。 +3. 只在外部 worktree 中调查、编辑、测试、stage、commit 和发布。除上述不可逆内容摘要用于 + 隔离证明外,不得读取或复制原工作树的 dirty bytes;摘要和 metadata 不得作为项目事实 + 证据或进入 PR。不得在原工作树 stash、clean、reset、commit、覆盖或运行 `prepare`。 +4. 任何最终报告前(包括发布失败时),对调用前保护集合用同一算法复核,并重新运行、逐 byte + 比较 status 与 `ls-files --stage` 的 NUL 分隔输出。调用前 clean 的 tracked 路径变化与新增 + 非 ignored 路径由最终 status 检出;预先存在的 dirty、untracked、ignored 内容变化由定向复核 + 检出。不要重新全量比较 ignored 枚举,因此调用期间新增的无关 ignored 路径不误报。检测到 + 差异时登记 `BLOCKER` 并报告边界变化,不得在没有证据时归因于 Agent、用户、IDE 或其他进程。 + +最终报告必须原样包含: + +```text +本次同步与 PR 基于调用时的 committed HEAD;原工作树中的未提交修改未进入调查或 PR。 +``` + +### PR 意图为 false + +当前工作树满足 `prepare` 的 dirty allowlist,且后续编辑不会制造 editable path 的 +index/worktree 分叉时,可以直接运行。若 `prepare` 因同步范围外 dirty path 或 editable path +分叉拒绝,或预期编辑会制造分叉,则不追问用户清理;从同一调用时 committed HEAD 在仓库外 +创建 clean worktree 并完整重跑。`prepare` 的此类前置失败不得改变原工作树;其他失败按实际 +证据登记 `BLOCKER`,不得一概用 worktree 掩盖。 + +只要使用外部 worktree,事实调查就只能消费其中的 committed HEAD,不得混入原工作树的未提交 +内容。 + +## 固定上游并准备 + +选定 `` 后,按以下方式准备: 1. 如果当前 Skill 位于 canonical `wlvh/coding-workflow` Git 根目录,复用该 checkout。 -2. 否则在目标仓库外临时 shallow clone `https://github.com/wlvh/coding-workflow.git`;网络失败 +2. 否则在目标仓库和外部执行 worktree 之外临时 shallow clone + `https://github.com/wlvh/coding-workflow.git`;网络失败 时停止,不回退到缓存模板。 3. 调用: @@ -180,7 +283,57 @@ whitespace 检查。 - 修改文档及代码、配置、测试或 artifact 证据; - 每条测试的 exact command、scope、result、not-run reason、环境与隔离方式; - review finding、修复、复核结果和 open decisions; -- mechanical check 结果,并明确它只证明最终状态。 +- mechanical check 结果,并明确它只证明最终状态; +- 使用外部 worktree 时的调用时 committed HEAD 和原工作树快照比较结果。 + +`check` 必须在 commit 前通过;不得用 commit 后的新 HEAD 绕过固定的 `expected_target_head`。 + +## Draft PR 发布 + +PR 意图为 `false` 时不 commit、push 或创建 PR,最终把 publication 标记为 `NOT_REQUESTED`。 + +PR 意图为 `true` 时,只有调查、测试、review、原工作树状态边界和上述 `check` 全部通过后, +才按顺序执行: + +1. 从最终 diff 得到本轮实际修改的九份核心文档子集,用显式路径逐个 stage;不得使用 + `git add -A`,不得包含代码、配置、测试残留、PR body 或其他非权威路径。 +2. 用 `git diff --cached --name-only` 读回 staged 路径,确认精确等于预期子集,再运行: + + ```bash + git diff --cached --check + ``` + +3. 创建一个有意义的 commit;没有文档 diff 时不得制造空 commit 或虚假 PR。 +4. 解析真实 remote、远端默认 base 和唯一 head branch,push 该新分支。 +5. 只创建 draft PR,不标记 Ready、不合并。创建后从远端读回 PR number、base、head、head SHA、 + Draft 状态和 changed files;任一不一致都登记 `BLOCKER`。 + +PR body 必须是仓库外的临时 Markdown 文件,并准确记录: + +- base/head 与调用时 committed HEAD; +- changed files; +- findings、修复与 open decisions; +- exact tests 及 PASS、FAIL、`NOT_RUN` 或 `BLOCKED`; +- 真实 review mode 和 reviewer 证据; +- final `check` 结果及其机械证明边界; +- 以下原工作树边界原句: + + ```text + 本次同步与 PR 基于调用时的 committed HEAD;原工作树中的未提交修改未进入调查或 PR。 + ``` + +commit、push 和 draft PR 创建交给通用 GitHub 发布能力,`sync_docs.py` 不参与发布。 + +若无 remote、无认证、无 push 权限或 PR 创建失败,保留外部 worktree、branch、commit 和仓库外 +PR body,不反问用户,不删除可恢复现场。最终状态必须原样写: + +```text +Documentation sync: PASS +Publication: PR_BLOCKED +Overall: PARTIAL +``` -用户要求 draft PR 时,只有上述流程成功后才使用仓库外临时 Markdown body;commit、push 和 -draft PR 创建交给通用 GitHub 发布能力,同步脚本不参与发布。 +同时输出基于已解析 worktree、remote、repo、base、head 和 body 路径的可直接执行 push 与 +draft PR 创建命令。无法解析的外部身份必须在命令中明确标为 required blocker,不得猜测 URL、 +repo 或权限,也不得声称 PR 已创建。只有 PR 创建成功、远端读回一致且原工作树定向保护集合、 +status 与 staged entries 复核通过后,才可以移除外部 worktree;publication blocked 时必须保留。 diff --git a/zh/skills/workflow-docs-sync/agents/openai.yaml b/zh/skills/workflow-docs-sync/agents/openai.yaml index c981af5..42c4c67 100644 --- a/zh/skills/workflow-docs-sync/agents/openai.yaml +++ b/zh/skills/workflow-docs-sync/agents/openai.yaml @@ -1,7 +1,7 @@ interface: display_name: "工作流文档同步" - short_description: "全量重建项目事实、最小改写并复核九份核心工作流文档" - default_prompt: "使用 $workflow-docs-sync 同步目标仓库的工作流文档。" + short_description: "默认同步当前 Git 根,按请求语言选模板,按明确意图创建 draft PR" + default_prompt: "使用 $workflow-docs-sync 同步当前 Git 根的工作流文档;按当前请求语言选择 zh 或 en,只有用户明确要求时才创建 draft PR。" policy: allow_implicit_invocation: false