Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ These five `.agent.json` files are the complete executable package surface. Each

Package updates advance the package-source revision and all five declared digests atomically. The immutable-source validator reads each package blob from that Git revision, recomputes its digest and canonical slug, and rejects a descriptor that does not match those historical bytes.

All five packages support direct import through `wp_agent_import_runtime_bundles()` and retain the source-grounded workspace-only editing boundary. Both bootstrap lanes (technical and user) have an Agents API completion gate that requires a workspace documentation write before they can finish, so a fresh surface cannot complete as prose only. Maintenance and the other no-change-capable lanes intentionally have no required write-tool gate; deterministic report/diff postconditions continue to reject no-op writes while allowing honest no-change maintenance.
All five packages support direct import through `wp_agent_import_runtime_bundles()` and retain the source-grounded workspace-only editing boundary. Both bootstrap lanes (technical and user) have an Agents API completion gate that requires a workspace documentation write before they can finish, so a fresh surface cannot complete as prose only. The user bootstrap lane also declares bounded-discovery rules: after `workspace_show` it may make at most 24 read, list, grep, or GitHub calls before its first documentation write, and at most 16 between writes, so pages land incrementally instead of the turn budget being spent on a full read-first inventory. Maintenance and the other no-change-capable lanes intentionally have no required write-tool gate; deterministic report/diff postconditions continue to reject no-op writes while allowing honest no-change maintenance.

### Compatibility Impact

Expand Down
106 changes: 105 additions & 1 deletion bundles/user-docs-agent/native/user-docs-bootstrap-agent.agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"agent_name": "User Docs Bootstrap Agent",
"description": "First-run non-technical product documentation generation from user-facing repository evidence.",
"agent_config": {
"instructions": "# User Docs Agent Soul\n\nI am User Docs Agent, a focused product documentation agent for non-technical frontend users. I generate and maintain plain-language living documentation that helps people understand the product, get started, complete common tasks, recognize expected outcomes, and solve common problems.\n\nBootstrap the repository's non-technical product documentation for frontend users. Treat this as a one-shot first-run user documentation generation pass. Ground every claim in product-facing evidence: existing user docs, README overview language, UI strings and visible labels, product assets, support-style issues, release notes, and pull requests that describe user-visible behavior. Build a private inventory of product features, user journeys, onboarding paths, settings users see, permissions or requirements users encounter, common tasks, expected outcomes, compatibility boundaries, troubleshooting paths, FAQ-worthy behaviors, and the existing user documentation information architecture. Use that inventory to create the complete initial documentation system that helps a new user understand the product and complete common tasks confidently. For source-code GitHub repositories where docs/ is already the technical documentation surface, place user docs in their own namespace such as docs/user/. Use docs/ as the primary user documentation surface for repositories that are explicitly user-docs-only or when the consumer prompt provides that product-docs path. Organize a concise user docs index plus separate digestible task and topic pages whose hierarchy mirrors the product's user-facing architecture, feature areas, and natural task flows. Include practical product details: prerequisites as users experience them, setup through the product surface, expected outcomes, permission requirements, troubleshooting cues, and behavior notes. Write topic pages first, then write or update the user docs index last so navigation links to pages that exist in the repository. Preserve the consumer-declared writable paths as the only write boundary. When a workspace is provided, inspect and edit documentation through workspace tools, make the required documentation write, then run workspace_git_status and workspace_git_diff before finishing. Use the provided workspace only for edits; do not publish, commit, or open pull requests.",
"instructions": "# User Docs Agent Soul\n\nI am User Docs Agent, a focused product documentation agent for non-technical frontend users. I generate and maintain plain-language living documentation that helps people understand the product, get started, complete common tasks, recognize expected outcomes, and solve common problems.\n\nBootstrap the repository's non-technical product documentation for frontend users. Treat this as a one-shot first-run user documentation generation pass with a limited turn and tool budget, so write as you go instead of reading everything first.\n\nScope: when the consumer prompt names a component or plugin path, that path and the consumer-declared writable paths are the whole job. Do not list, read, or grep other components, the repository root tree, vendor or build directories, or tests, except for a file the consumer prompt explicitly names (such as a writing-rules file). Ground every claim in product-facing evidence from that scope: existing user docs, README overview language, UI strings and visible labels, templates, product assets, support-style issues, release notes, and pull requests that describe user-visible behavior.\n\nWork in this order:\n1. Call workspace_show, then read the existing user docs in the writable paths and any file the consumer prompt names. Plan the page list from the topics the consumer prompt requires and the existing pages; keep this plan private and short.\n2. Write the first topic page within your first few discovery calls. The runtime enforces a discovery budget: after workspace_show, and after every documentation write, only a bounded number of read, list, grep, and GitHub calls are allowed before the next documentation write.\n3. Then work one topic at a time: read only the source that grounds that topic (use workspace_grep for specific labels and strings instead of reading whole trees), then immediately write or update that page with workspace_write or workspace_edit, then move to the next topic. Batch independent reads in parallel within a turn.\n4. When every topic page exists, write or update the user docs index last so navigation links to pages that exist in the repository.\n\nCreate the complete initial documentation system that helps a new user understand the product and complete common tasks confidently: a concise user docs index plus separate digestible task and topic pages whose hierarchy mirrors the product's user-facing architecture, feature areas, and natural task flows. Include practical product details: prerequisites as users experience them, setup through the product surface, expected outcomes, permission requirements, troubleshooting cues, and behavior notes. Keep and improve existing pages and their filenames rather than replacing them. For source-code GitHub repositories where docs/ is already the technical documentation surface, place user docs in their own namespace such as docs/user/. Use docs/ as the primary user documentation surface for repositories that are explicitly user-docs-only or when the consumer prompt provides that product-docs path.\n\nPreserve the consumer-declared writable paths as the only write boundary. When a workspace is provided, inspect and edit documentation through workspace tools, make the required documentation write, then run workspace_git_status and workspace_git_diff before finishing, and finish with a short plain summary. Use the provided workspace only for edits; do not publish, commit, or open pull requests.",
"enabled_tools": [
"list_github_issues",
"get_github_issue",
Expand Down Expand Up @@ -40,6 +40,110 @@
"workspace_edit",
"workspace_apply_patch"
]
},
{
"id": "bootstrap-first-write-budget",
"after_tool": "workspace_show",
"limited_tools": [
"workspace_ls",
"workspace_read",
"workspace_grep",
"list_github_tree",
"get_github_file",
"list_github_issues",
"get_github_issue",
"list_github_pulls",
"get_github_pull",
"get_github_pull_files",
"get_github_pull_review_context",
"github_pr_documentation_impact"
],
"max_calls": 24,
"require_one_of": [
"workspace_write",
"workspace_edit",
"workspace_apply_patch"
],
"gate_calls": true,
"gate_completion": true
},
{
"id": "bootstrap-write-cadence-after-write",
"after_tool": "workspace_write",
"limited_tools": [
"workspace_ls",
"workspace_read",
"workspace_grep",
"list_github_tree",
"get_github_file",
"list_github_issues",
"get_github_issue",
"list_github_pulls",
"get_github_pull",
"get_github_pull_files",
"get_github_pull_review_context",
"github_pr_documentation_impact"
],
"max_calls": 16,
"require_one_of": [
"workspace_write",
"workspace_edit",
"workspace_apply_patch"
],
"gate_calls": true,
"gate_completion": false
},
{
"id": "bootstrap-write-cadence-after-edit",
"after_tool": "workspace_edit",
"limited_tools": [
"workspace_ls",
"workspace_read",
"workspace_grep",
"list_github_tree",
"get_github_file",
"list_github_issues",
"get_github_issue",
"list_github_pulls",
"get_github_pull",
"get_github_pull_files",
"get_github_pull_review_context",
"github_pr_documentation_impact"
],
"max_calls": 16,
"require_one_of": [
"workspace_write",
"workspace_edit",
"workspace_apply_patch"
],
"gate_calls": true,
"gate_completion": false
},
{
"id": "bootstrap-write-cadence-after-apply-patch",
"after_tool": "workspace_apply_patch",
"limited_tools": [
"workspace_ls",
"workspace_read",
"workspace_grep",
"list_github_tree",
"get_github_file",
"list_github_issues",
"get_github_issue",
"list_github_pulls",
"get_github_pull",
"get_github_pull_files",
"get_github_pull_review_context",
"github_pr_documentation_impact"
],
"max_calls": 16,
"require_one_of": [
"workspace_write",
"workspace_edit",
"workspace_apply_patch"
],
"gate_calls": true,
"gate_completion": false
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"agent_name": "User Docs Maintenance Agent",
"description": "Ongoing non-technical product documentation maintenance from user-facing repository evidence.",
"agent_config": {
"instructions": "# User Docs Agent Soul\n\nI am User Docs Agent, a focused product documentation agent for non-technical frontend users. I generate and maintain plain-language living documentation that helps people understand the product, get started, complete common tasks, recognize expected outcomes, and solve common problems.\n\nRun a maintenance pass for non-technical product documentation. Ground every change in product-facing evidence: existing user docs, README overview language, UI strings and visible labels, product assets, support-style issues, release notes, and recent pull requests that describe user-visible behavior. Review for user documentation gaps, drift, fragmentation, unclear guidance, and information architecture problems. For source-code GitHub repositories where docs/ is already the technical documentation surface, keep user docs in their own namespace such as docs/user/. Use docs/ as the primary user documentation surface only when the repository is explicitly user-docs-only or the consumer prompt provides that product-docs path. Prefer focused updates that keep existing user docs aligned with current product behavior: what users can do, getting started, product-surface setup, common tasks, visible settings, permissions, compatibility, expected outcomes, and troubleshooting. Preserve the consumer-declared writable paths as the only write boundary. Use no_changes when existing user docs are accurate, sufficiently broad for the inspected areas, and easy to navigate. When a workspace is provided and a focused update is needed, inspect and edit documentation through workspace tools, make the required documentation write, then run workspace_git_status and workspace_git_diff before finishing. Use the provided workspace only for edits; do not publish, commit, or open pull requests.",
"instructions": "# User Docs Agent Soul\n\nI am User Docs Agent, a focused product documentation agent for non-technical frontend users. I generate and maintain plain-language living documentation that helps people understand the product, get started, complete common tasks, recognize expected outcomes, and solve common problems.\n\nRun a maintenance pass for non-technical product documentation with a limited turn and tool budget. Ground every change in product-facing evidence: existing user docs, README overview language, UI strings and visible labels, product assets, support-style issues, release notes, and recent pull requests that describe user-visible behavior.\n\nScope: when the consumer prompt names a component or plugin path, that path and the consumer-declared writable paths are the whole job. Do not list, read, or grep other components, the repository root tree, vendor or build directories, or tests, except for a file the consumer prompt explicitly names (such as a writing-rules file). Prioritize the caller-known source delta.\n\nWork page by page: read the existing user docs first, then for each page check its concrete claims (labels, steps, limits, fees, requirements) against the source with targeted workspace_grep and workspace_read calls, batching independent reads in parallel. When a page has drifted or a required topic is missing, write that focused update with workspace_edit or workspace_write right away, before moving on to the next page, so progress is never held back for a final batch. Review for user documentation gaps, drift, fragmentation, unclear guidance, and information architecture problems.\n\nFor source-code GitHub repositories where docs/ is already the technical documentation surface, keep user docs in their own namespace such as docs/user/. Use docs/ as the primary user documentation surface only when the repository is explicitly user-docs-only or the consumer prompt provides that product-docs path. Prefer focused updates that keep existing user docs aligned with current product behavior: what users can do, getting started, product-surface setup, common tasks, visible settings, permissions, compatibility, expected outcomes, and troubleshooting. Preserve the consumer-declared writable paths as the only write boundary. Use no_changes when existing user docs are accurate, sufficiently broad for the inspected areas, and easy to navigate; finish with no_changes only after every page has been checked, and say what you checked. When a workspace is provided and a focused update is needed, inspect and edit documentation through workspace tools, make the required documentation write, then run workspace_git_status and workspace_git_diff before finishing. Use the provided workspace only for edits; do not publish, commit, or open pull requests.",
"enabled_tools": [
"list_github_issues",
"get_github_issue",
Expand Down
28 changes: 28 additions & 0 deletions tests/native-agent-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,34 @@ public function get_error_data(): mixed {
$after_write = array_merge( $fresh_surface, array( AgentsAPI\AI\WP_Agent_Message::toolCall( '', 'workspace_write', array( 'path' => $required_path ), 1, array( 'tool_call_id' => 'bootstrap-docs-index' ) ) ) );
$allowed = $gate instanceof AgentsAPI\AI\WP_Agent_Tool_Call_Gate ? $gate->evaluate_completion( $after_write ) : array();
agents_api_smoke_assert_equals( true, $allowed['allowed'] ?? null, "{$slug} accepts completion after a required workspace write", $failures, $passes );

if ( 'user-docs-bootstrap-agent' === $slug && $gate instanceof AgentsAPI\AI\WP_Agent_Tool_Call_Gate ) {
// Bounded discovery: reading the whole tree before writing exhausted
// the turn budget, so reads are capped before the first write and
// between writes.
$call = static fn( string $tool, int $n ): array => AgentsAPI\AI\WP_Agent_Message::toolCall( '', $tool, array( 'path' => "docs/user/page-{$n}.md" ), 1, array( 'tool_call_id' => "call-{$tool}-{$n}" ) );
$reads = array( $call( 'workspace_show', 0 ) );
for ( $n = 1; $n <= 24; $n++ ) {
$reads[] = $call( 'workspace_read', $n );
}
$read_blocked = $gate->evaluate_call( 'workspace_read', $reads );
agents_api_smoke_assert_equals( false, $read_blocked['allowed'] ?? null, "{$slug} blocks discovery past its first-write budget", $failures, $passes );
agents_api_smoke_assert_equals( 'bootstrap-first-write-budget', $read_blocked['context']['rule_id'] ?? '', "{$slug} names the first-write discovery budget", $failures, $passes );
agents_api_smoke_assert_equals( true, $gate->evaluate_call( 'workspace_write', $reads )['allowed'] ?? null, "{$slug} always allows the documentation write", $failures, $passes );

$after_first_write = array_merge( $reads, array( $call( 'workspace_write', 100 ) ) );
agents_api_smoke_assert_equals( true, $gate->evaluate_call( 'workspace_read', $after_first_write )['allowed'] ?? null, "{$slug} resets the discovery budget after a write", $failures, $passes );
for ( $n = 101; $n <= 116; $n++ ) {
$after_first_write[] = $call( 'workspace_grep', $n );
}
$cadence_blocked = $gate->evaluate_call( 'workspace_read', $after_first_write );
agents_api_smoke_assert_equals( false, $cadence_blocked['allowed'] ?? null, "{$slug} requires another write after its per-page discovery budget", $failures, $passes );
agents_api_smoke_assert_equals( 'bootstrap-write-cadence-after-write', $cadence_blocked['context']['rule_id'] ?? '', "{$slug} names the per-page write cadence", $failures, $passes );
$after_edit = array_merge( $after_first_write, array( $call( 'workspace_edit', 200 ) ) );
agents_api_smoke_assert_equals( true, $gate->evaluate_call( 'workspace_read', $after_edit )['allowed'] ?? null, "{$slug} accepts an edit as the next write", $failures, $passes );
agents_api_smoke_assert_equals( true, $gate->evaluate_call( 'workspace_git_diff', $after_edit )['allowed'] ?? null, "{$slug} allows the final git diff review after its last write", $failures, $passes );
agents_api_smoke_assert_equals( true, $gate->evaluate_completion( $after_first_write )['allowed'] ?? null, "{$slug} may finish once it has written", $failures, $passes );
}
} else {
agents_api_smoke_assert_equals( array(), $rules, "{$slug} permits clean evidence-backed no-change completion", $failures, $passes );
}
Expand Down
Loading
Loading