Skip to content

Commit 2c556da

Browse files
authored
Adopt Docs Agent completion contract (#124)
1 parent c56b96d commit 2c556da

5 files changed

Lines changed: 42 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ jobs:
1919
- uses: actions/checkout@v4
2020
with:
2121
repository: Automattic/docs-agent
22-
ref: 972ceb8a9ebcfafa1f88edc4fba173065415698a
22+
ref: a39d9db230eb9e0b72ed84465f4d61bd8dda1bab
2323
path: .producer/docs-agent
2424
- uses: actions/checkout@v4
2525
with:
2626
repository: Automattic/wp-codebox
27-
ref: 6457dcae4cb8cf8e76cd174377de8cbee3ee12cb
27+
ref: 12a5bb19a97b89d0a78b502fc71adede5b122359
2828
path: .producer/wp-codebox
2929
- uses: pnpm/action-setup@v4
3030
with:

.github/workflows/developer-docs-agent.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,33 @@ concurrency:
2727
jobs:
2828
developer-docs-agent:
2929
name: Maintain Developer Docs
30-
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@972ceb8a9ebcfafa1f88edc4fba173065415698a
30+
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@a39d9db230eb9e0b72ed84465f4d61bd8dda1bab
3131
with:
3232
audience: technical
3333
run_kind: ${{ github.event.inputs.run_kind || 'maintenance' }}
3434
require_pr: ${{ github.event_name == 'workflow_dispatch' }}
3535
base_ref: trunk
3636
docs_branch: docs-agent/build-with-wordpress-developer-docs
3737
writable_paths: README.md,docs/**,plugins/**/README.md
38+
bootstrap_contract: |
39+
{
40+
"required_paths": ["README.md", "docs/README.md"],
41+
"required_globs": [{"pattern": "docs/**/*.md", "min_count": 3}],
42+
"entry_points": [{"path": "README.md", "must_link_to": ["docs/README.md"]}]
43+
}
44+
source_delta: |
45+
[
46+
{
47+
"id": "figma-studio-handoff-diagnostics",
48+
"source_refs": [
49+
"https://github.com/Automattic/build-with-wordpress/pull/100",
50+
"plugins/figma-to-wordpress-studio/src/payload.ts",
51+
"plugins/figma-to-wordpress-studio/src/ui.ts",
52+
"plugins/figma-to-wordpress-studio/tests/generate-artifact.test.mjs"
53+
],
54+
"requires_documentation_change": true
55+
}
56+
]
3857
verification_commands: |
3958
[
4059
"pnpm install --frozen-lockfile",

.github/workflows/skills-agent.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ concurrency:
1717
jobs:
1818
skills-agent:
1919
name: Maintain Live Skills
20-
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@main
20+
uses: Automattic/docs-agent/.github/workflows/maintain-docs.yml@a39d9db230eb9e0b72ed84465f4d61bd8dda1bab
2121
with:
2222
audience: skills
2323
base_ref: trunk
2424
docs_branch: docs-agent/build-with-wordpress-skills
2525
writable_paths: skills/**,plugins/**/skills/**,plugins/**/README.md
26+
source_delta: '[{"id":"skills-source","source_refs":["skills/**","scripts/**","plugins/**/skills/**"],"requires_documentation_change":false}]'
2627
verification_commands: |
2728
[
2829
"pnpm install --frozen-lockfile",

docs/contributor-workflows.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ Manual documentation runs default to maintenance and should make the smallest so
156156
- `workflow_dispatch` offers `run_kind` choices of `maintenance` (the default) and `bootstrap`; pushes to `trunk` run with `run_kind: maintenance`.
157157
- `docs_branch` is `docs-agent/build-with-wordpress-developer-docs` and `base_ref` is `trunk`.
158158
- writable documentation paths are limited to `README.md`, `docs/**`, and `plugins/**/README.md`.
159-
- Docs Agent selects its native package from the reusable workflow revision pinned in this file: `Automattic/docs-agent/.github/workflows/maintain-docs.yml@972ceb8a9ebcfafa1f88edc4fba173065415698a`.
159+
- Docs Agent selects its native package from the reusable workflow revision pinned in this file: `Automattic/docs-agent/.github/workflows/maintain-docs.yml@a39d9db230eb9e0b72ed84465f4d61bd8dda1bab`.
160+
- maintenance is bounded to the known Figma Studio handoff diagnostics drift from [PR #100](https://github.com/Automattic/build-with-wordpress/pull/100) and requires an evidence-backed documentation update; bootstrap requires `README.md`, `docs/README.md`, at least three topic pages, and a README link to the docs index.
160161
- manual `workflow_dispatch` runs set `require_pr: true`; push-triggered maintenance runs do not require a PR and may finish with no changes when the documentation already matches source behavior.
161162
- verification commands are `pnpm install --frozen-lockfile`, `pnpm build`, and `pnpm verify`.
162163
- the developer-docs drift check is scoped to non-documentation paths: `git diff --exit-code -- . ':(top,exclude)README.md' ':(top,glob,exclude)docs/**' ':(top,glob,exclude)plugins/**/README.md'`. This means the build must not produce uncommitted generated-package or source changes outside the workflow's writable documentation paths.
@@ -165,9 +166,9 @@ When changing the docs workflow, keep this contract aligned with the repository
165166

166167
### Skills workflow contract
167168

168-
`skills-agent.yml` uses the same reusable Docs Agent workflow with `audience: skills` from `Automattic/docs-agent/.github/workflows/maintain-docs.yml@main`. It is triggered manually and on a weekly Monday schedule, writes only to `skills/**`, generated skill copies under `plugins/**/skills/**`, and plugin README files, and runs the same install, build, and verify commands as the developer-docs workflow. Its drift check is intentionally broad: `git diff --exit-code`, so generated skill package output must be committed after the build. The workflow does not pass `run_kind` or `require_pr`; the native skills lane should make the smallest source-grounded skill update needed or finish with no changes when skills are current. Keep this workflow focused on live skill content; generated package structure and developer documentation belong in the technical docs workflow and the generator/verifier source.
169+
`skills-agent.yml` uses the same pinned reusable Docs Agent workflow with `audience: skills`. It is triggered manually and on a weekly Monday schedule, writes only to `skills/**`, generated skill copies under `plugins/**/skills/**`, and plugin README files, and runs the same install, build, and verify commands as the developer-docs workflow. Its bounded source delta covers the live skill sources, package generator scripts, and packaged skill outputs, and permits an evidence-backed no-change result when those surfaces are current. Its drift check is intentionally broad: `git diff --exit-code`, so generated skill package output must be committed after the build. The workflow does not pass `run_kind` or `require_pr`; the native skills lane should make the smallest source-grounded skill update needed or finish with no changes when skills are current. Keep this workflow focused on live skill content; generated package structure and developer documentation belong in the technical docs workflow and the generator/verifier source.
169170

170-
The `CI` workflow provides automated validation for pull requests and pushes to `trunk` and `feat/native-docs-agent`. It checks out Docs Agent at `972ceb8a9ebcfafa1f88edc4fba173065415698a` and WP Codebox at `6457dcae4cb8cf8e76cd174377de8cbee3ee12cb`, installs pnpm 10.8.1, runs `pnpm test`, then runs `pnpm build` and `pnpm verify`. The workflow contract test rejects producer revision, reusable workflow, secret forwarding, writable path, verification command, drift check, or schema drift. This repository does not currently require the workflow as a merge gate.
171+
The `CI` workflow provides automated validation for pull requests and pushes to `trunk` and `feat/native-docs-agent`. It checks out Docs Agent at `a39d9db230eb9e0b72ed84465f4d61bd8dda1bab` and the accepted WP Codebox reusable-workflow producer at `12a5bb19a97b89d0a78b502fc71adede5b122359`, installs pnpm 10.8.1, runs `pnpm test`, then runs `pnpm build` and `pnpm verify`. The workflow contract test rejects producer revision, reusable workflow, source-delta, bootstrap, secret forwarding, writable path, verification command, drift check, or schema drift. This repository does not currently require the workflow as a merge gate.
171172

172173
## Pull request checklist
173174

tests/docs-agent-workflows.test.mjs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { readFile } from "node:fs/promises"
44
import { resolve } from "node:path"
55

66
const root = resolve(new URL("..", import.meta.url).pathname)
7-
const docsAgentRevision = "972ceb8a9ebcfafa1f88edc4fba173065415698a"
8-
const docsAgentPackageRevision = "85443eb91c12b2759d8e207f1ae4421407b4cc5e"
9-
const wpCodeboxProducerRevision = "6457dcae4cb8cf8e76cd174377de8cbee3ee12cb"
10-
const wpCodeboxWorkflowRef = "v0.12.28"
7+
const docsAgentRevision = "a39d9db230eb9e0b72ed84465f4d61bd8dda1bab"
8+
const docsAgentPackageRevision = "85f0d162a7d499fdc1286891371342727d084c88"
9+
const wpCodeboxProducerRevision = "12a5bb19a97b89d0a78b502fc71adede5b122359"
10+
const wpCodeboxWorkflowRef = wpCodeboxProducerRevision
11+
const wpCodeboxReleaseRef = "v0.12.29"
1112
const docsAgentDir = process.env.DOCS_AGENT_DIR
1213
const wpCodeboxDir = process.env.WP_CODEBOX_DIR
1314

@@ -24,7 +25,7 @@ const docsAgentWorkflow = await readFile(resolve(docsAgentDir, ".github/workflow
2425
const wpCodeboxContract = await readJson(wpCodeboxDir, "contracts/run-agent-task-reusable-workflow-interface.v1.json")
2526
assert.equal(wpCodeboxContract.schema, "wp-codebox/reusable-workflow-interface/v1")
2627
assert.match(docsAgentWorkflow, new RegExp(`uses: Automattic/wp-codebox/.github/workflows/run-agent-task.yml@${wpCodeboxWorkflowRef}`))
27-
assert.match(docsAgentWorkflow, new RegExp(`wp_codebox_release_ref: ${wpCodeboxWorkflowRef}`))
28+
assert.match(docsAgentWorkflow, new RegExp(`wp_codebox_release_ref: ${wpCodeboxReleaseRef}`))
2829
assert.match(docsAgentWorkflow, new RegExp(`DOCS_AGENT_PACKAGE_REVISION: ${docsAgentPackageRevision}`))
2930
assert.match(docsAgentWorkflow, /OPENAI_API_KEY: \$\{\{ secrets\.OPENAI_API_KEY \}\}/)
3031
assert.match(docsAgentWorkflow, /ACCESS_TOKEN: \$\{\{ github\.token \}\}/)
@@ -48,14 +49,18 @@ const workflows = [
4849
revision: docsAgentRevision,
4950
writablePaths: "README.md,docs/**,plugins/**/README.md",
5051
driftCheck: "git diff --exit-code -- . ':(top,exclude)README.md' ':(top,glob,exclude)docs/**' ':(top,glob,exclude)plugins/**/README.md'",
52+
sourceDelta: /"id": "figma-studio-handoff-diagnostics"[\s\S]*"https:\/\/github\.com\/Automattic\/build-with-wordpress\/pull\/100"[\s\S]*"requires_documentation_change": true/,
53+
bootstrapContract: true,
5154
},
5255
{
5356
path: ".github/workflows/skills-agent.yml",
5457
audience: "skills",
5558
runKind: false,
56-
revision: "main",
59+
revision: docsAgentRevision,
5760
writablePaths: "skills/**,plugins/**/skills/**,plugins/**/README.md",
5861
driftCheck: "git diff --exit-code",
62+
sourceDelta: /"id":"skills-source".*"requires_documentation_change":false/,
63+
bootstrapContract: false,
5964
},
6065
]
6166

@@ -84,6 +89,7 @@ for (const workflow of workflows) {
8489
assert.match(source, /pnpm verify/)
8590
assert.match(source, /validation_dependencies: npm install --global pnpm@10\.8\.1/)
8691
assert.ok(source.includes(`"command": "${workflow.driftCheck}"`), `${workflow.path} must use its scoped drift check`)
92+
assert.match(source, workflow.sourceDelta, `${workflow.path} must declare its bounded source delta`)
8793
assert.match(source, /permissions:\n contents: write\n pull-requests: write\n issues: write/)
8894
assert.match(source, /OPENAI_API_KEY: \$\{\{ secrets\.OPENAI_API_KEY \}\}/)
8995
assert.match(source, /EXTERNAL_PACKAGE_SOURCE_POLICY: \$\{\{ secrets\.EXTERNAL_PACKAGE_SOURCE_POLICY \}\}/)
@@ -97,9 +103,11 @@ for (const workflow of workflows) {
97103
assert.match(dispatchInputs, / run_kind:\n description: Documentation run mode\n required: false\n default: maintenance\n type: choice\n options:\n - maintenance\n - bootstrap/)
98104
assert.match(source, /run_kind: \$\{\{ github\.event\.inputs\.run_kind \|\| 'maintenance' \}\}/)
99105
assert.match(source, /require_pr: \$\{\{ github\.event_name == 'workflow_dispatch' \}\}/)
106+
assert.match(source, /bootstrap_contract:[\s\S]*"required_paths": \["README\.md", "docs\/README\.md"\][\s\S]*"pattern": "docs\/\*\*\/\*\.md"[\s\S]*"path": "README\.md", "must_link_to": \["docs\/README\.md"\]/)
100107
} else {
101108
assert.doesNotMatch(source, /^ run_kind:/m)
102109
assert.doesNotMatch(source, /^ require_pr:/m)
110+
assert.doesNotMatch(source, /^ bootstrap_contract:/m)
103111
}
104112
}
105113

0 commit comments

Comments
 (0)