From bc82c0f2ca17c860b0db965b77b1030511e463c5 Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Mon, 30 Nov 2026 13:56:36 -0600 Subject: [PATCH 1/3] feat(docs): host searchable community bundle directory Generate bundle discovery and detail pages from the community catalog, refresh documentation weekly, and keep submission maintenance catalog-only. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../workflows/add-community-bundle.lock.yml | 6 +- .github/workflows/add-community-bundle.md | 34 +- .github/workflows/docs.yml | 9 + docs/.gitignore | 1 + docs/README.md | 26 +- docs/assets/bundle-catalog.css | 175 +++++++ docs/assets/bundle-catalog.js | 66 +++ docs/bundles/publishing.md | 8 +- docs/community/bundles.md | 9 +- docs/docfx.json | 1 + docs/generate_bundles.py | 308 +++++++++++ tests/test_bundle_documentation.py | 493 ++++++++++++++++++ tests/test_github_workflows.py | 2 +- tests/test_preset_documentation.py | 2 +- 14 files changed, 1089 insertions(+), 51 deletions(-) create mode 100644 docs/assets/bundle-catalog.css create mode 100644 docs/assets/bundle-catalog.js create mode 100644 docs/generate_bundles.py create mode 100644 tests/test_bundle_documentation.py diff --git a/.github/workflows/add-community-bundle.lock.yml b/.github/workflows/add-community-bundle.lock.yml index 96e229675d..133aa0e187 100644 --- a/.github/workflows/add-community-bundle.lock.yml +++ b/.github/workflows/add-community-bundle.lock.yml @@ -1,4 +1,4 @@ -# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"8f2183d49bd078f40c1d155c981ab0d24de6fd6f594982ef9c34e29d3bf00ff6","body_hash":"8587a966010fc745aa232dcbaa49570f95884ca912fc85c83a7a8d730ce2677c","compiler_version":"v0.88.7","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.80"}} +# gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"0da214f83380ab4eb1f21ef8b36b78a02634c7a8ceb94c0421d168d1117f12c1","body_hash":"9b34fa6e2982c9ef1efaa5697d9681a06066916bff690758c9c10e44dc9776e0","compiler_version":"v0.88.7","strict":true,"agent_id":"copilot","engine_versions":{"copilot":"1.0.80"}} # gh-aw-manifest: {"version":1,"secrets":["COPILOT_GITHUB_TOKEN","GH_AW_CI_TRIGGER_TOKEN","GH_AW_DEFAULT_OTLP_HEADERS","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/cache/restore","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/cache/save","sha":"55cc8345863c7cc4c66a329aec7e433d2d1c52a9","version":"v6.1.0"},{"repo":"actions/checkout","sha":"3d3c42e5aac5ba805825da76410c181273ba90b1","version":"v7.0.1"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"820762786026740c76f36085b0efc47a31fe5020","version":"v7.0.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"5e508589e03a7757a7e05b26e834292f5445bfb6","version":"v0.88.7"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.28.14","digest":"sha256:f7df036c86575527b61f3f7df91c4412349a12b2a74988d929eafa2999230c98","pinned_image":"ghcr.io/github/gh-aw-firewall/agent:0.28.14@sha256:f7df036c86575527b61f3f7df91c4412349a12b2a74988d929eafa2999230c98"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.14","digest":"sha256:6f95e2234dd9bd6333a8ff28ccea7ecf0204acd4a09108723844dbd2bf6268c5","pinned_image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.28.14@sha256:6f95e2234dd9bd6333a8ff28ccea7ecf0204acd4a09108723844dbd2bf6268c5"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.28.14","digest":"sha256:2ce8df3abf3e9b76e9c0cf5863da41f1ab3f89b20ad14b988806ab89e7bf2cd5","pinned_image":"ghcr.io/github/gh-aw-firewall/squid:0.28.14@sha256:2ce8df3abf3e9b76e9c0cf5863da41f1ab3f89b20ad14b988806ab89e7bf2cd5"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.4.18","digest":"sha256:85b940556a8faa4e1fdbef124bfd75f2c4ebd855a10b88a1c3b6f3e97f6f1a53","pinned_image":"ghcr.io/github/gh-aw-mcpg:v0.4.18@sha256:85b940556a8faa4e1fdbef124bfd75f2c4ebd855a10b88a1c3b6f3e97f6f1a53"},{"image":"ghcr.io/github/gh-aw-node","digest":"sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23","pinned_image":"ghcr.io/github/gh-aw-node@sha256:0daa8971fa4732b647150cb6524a6b0804b68d5d24f6f58b5dd1af23bd63fb23"},{"image":"ghcr.io/github/github-mcp-server:v1.11.0","digest":"sha256:fbec75de11c255213fa08d80fb166abe73d851fff631c51c0079872967720699","pinned_image":"ghcr.io/github/github-mcp-server:v1.11.0@sha256:fbec75de11c255213fa08d80fb166abe73d851fff631c51c0079872967720699"}],"mcp_servers":[{"name":"github","tools":["get_commit","get_file_contents","get_latest_release","get_release_by_tag","get_tag","issue_read","list_branches","list_commits","list_issue_types","list_issues","list_releases","list_starred_repositories","list_tags","search_code","search_issues","search_repositories"]},{"name":"safeoutputs","tools":["add_comment","add_labels","create_pull_request","missing_data","missing_tool","noop","remove_labels"]}]} # This file was automatically generated by gh-aw (v0.88.7). DO NOT EDIT. To debug this workflow, load the skill at https://github.com/github/gh-aw/blob/main/debug.md # @@ -573,7 +573,7 @@ jobs: env: GH_AW_FILE_ROOT: "${{ runner.temp }}/gh-aw" GH_AW_FILE_CONFIG: "{\"files\":[{\"path\":\"safeoutputs/config.json\",\"content_env\":\"GH_AW_SAFE_OUTPUTS_CONFIG\"}]}" - GH_AW_SAFE_OUTPUTS_CONFIG: "{\"add_comment\":{\"max\":2},\"add_labels\":{\"allowed\":[\"bundle-submission\",\"validation-passed\",\"validation-failed\",\"needs-info\"],\"issue_intent\":false,\"max\":3},\"create_pull_request\":{\"allowed_files\":[\"bundles/catalog.community.json\",\"docs/community/bundles.md\"],\"draft\":true,\"labels\":[\"bundle-submission\",\"automated\"],\"max\":1,\"max_patch_files\":100,\"max_patch_size\":4096,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"CONTRIBUTING.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"blocked\",\"title_prefix\":\"[bundle] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"remove_labels\":{\"allowed\":[\"validation-passed\",\"validation-failed\",\"needs-info\"]},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_CONFIG: "{\"add_comment\":{\"max\":2},\"add_labels\":{\"allowed\":[\"bundle-submission\",\"validation-passed\",\"validation-failed\",\"needs-info\"],\"issue_intent\":false,\"max\":3},\"create_pull_request\":{\"allowed_files\":[\"bundles/catalog.community.json\"],\"draft\":true,\"labels\":[\"bundle-submission\",\"automated\"],\"max\":1,\"max_patch_files\":100,\"max_patch_size\":4096,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"CONTRIBUTING.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"blocked\",\"title_prefix\":\"[bundle] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"remove_labels\":{\"allowed\":[\"validation-passed\",\"validation-failed\",\"needs-info\"]},\"report_incomplete\":{}}" with: script: | const path = require('path'); @@ -2007,7 +2007,7 @@ jobs: GH_AW_ALLOWED_DOMAINS: "api.snapcraft.io,archive.ubuntu.com,azure.archive.ubuntu.com,codeload.github.com,crl.geotrust.com,crl.globalsign.com,crl.identrust.com,crl.sectigo.com,crl.thawte.com,crl.usertrust.com,crl.verisign.com,crl3.digicert.com,crl4.digicert.com,crls.ssl.com,github.com,json-schema.org,json.schemastore.org,keyserver.ubuntu.com,ocsp.digicert.com,ocsp.geotrust.com,ocsp.globalsign.com,ocsp.identrust.com,ocsp.sectigo.com,ocsp.ssl.com,ocsp.thawte.com,ocsp.usertrust.com,ocsp.verisign.com,packagecloud.io,packages.cloud.google.com,packages.microsoft.com,ppa.launchpad.net,raw.githubusercontent.com,release-assets.githubusercontent.com,s.symcb.com,s.symcd.com,security.ubuntu.com,ts-crl.ws.symantec.com,ts-ocsp.ws.symantec.com,www.googleapis.com" GITHUB_SERVER_URL: ${{ github.server_url }} GITHUB_API_URL: ${{ github.api_url }} - GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"add_comment\":{\"max\":2},\"add_labels\":{\"allowed\":[\"bundle-submission\",\"validation-passed\",\"validation-failed\",\"needs-info\"],\"issue_intent\":false,\"max\":3},\"create_pull_request\":{\"allowed_files\":[\"bundles/catalog.community.json\",\"docs/community/bundles.md\"],\"draft\":true,\"labels\":[\"bundle-submission\",\"automated\"],\"max\":1,\"max_patch_files\":100,\"max_patch_size\":4096,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"CONTRIBUTING.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"blocked\",\"title_prefix\":\"[bundle] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"remove_labels\":{\"allowed\":[\"validation-passed\",\"validation-failed\",\"needs-info\"]},\"report_incomplete\":{}}" + GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG: "{\"add_comment\":{\"max\":2},\"add_labels\":{\"allowed\":[\"bundle-submission\",\"validation-passed\",\"validation-failed\",\"needs-info\"],\"issue_intent\":false,\"max\":3},\"create_pull_request\":{\"allowed_files\":[\"bundles/catalog.community.json\"],\"draft\":true,\"labels\":[\"bundle-submission\",\"automated\"],\"max\":1,\"max_patch_files\":100,\"max_patch_size\":4096,\"protect_top_level_dot_folders\":true,\"protected_files\":[\"package.json\",\"bun.lockb\",\"bunfig.toml\",\"deno.json\",\"deno.jsonc\",\"deno.lock\",\"global.json\",\"NuGet.Config\",\"Directory.Packages.props\",\"mix.exs\",\"mix.lock\",\"go.mod\",\"go.sum\",\"stack.yaml\",\"stack.yaml.lock\",\"pom.xml\",\"build.gradle\",\"build.gradle.kts\",\"settings.gradle\",\"settings.gradle.kts\",\"gradle.properties\",\"package-lock.json\",\"yarn.lock\",\"pnpm-lock.yaml\",\"npm-shrinkwrap.json\",\"requirements.txt\",\"Pipfile\",\"Pipfile.lock\",\"pyproject.toml\",\"setup.py\",\"setup.cfg\",\"Gemfile\",\"Gemfile.lock\",\"uv.lock\",\"CODEOWNERS\",\"DESIGN.md\",\"CONTRIBUTING.md\",\"SECURITY.md\",\"CODE_OF_CONDUCT.md\",\"AGENTS.md\"],\"protected_files_policy\":\"blocked\",\"title_prefix\":\"[bundle] \"},\"create_report_incomplete_issue\":{},\"missing_data\":{},\"missing_tool\":{},\"noop\":{\"max\":1,\"report-as-issue\":\"false\"},\"remove_labels\":{\"allowed\":[\"validation-passed\",\"validation-failed\",\"needs-info\"]},\"report_incomplete\":{}}" GH_AW_CI_TRIGGER_TOKEN: ${{ secrets.GH_AW_CI_TRIGGER_TOKEN }} with: github-token: ${{ secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/add-community-bundle.md b/.github/workflows/add-community-bundle.md index 5a4517ed2f..8ac668008b 100644 --- a/.github/workflows/add-community-bundle.md +++ b/.github/workflows/add-community-bundle.md @@ -51,7 +51,6 @@ safe-outputs: max: 1 allowed-files: - bundles/catalog.community.json - - docs/community/bundles.md protected-files: policy: blocked exclude: @@ -392,24 +391,12 @@ Validate the complete file: python3 -c "import json; json.load(open('bundles/catalog.community.json')); print('Valid JSON')" ``` -## Step 5 - Update Community Documentation +## Step 5 - Catalog-Generated Community Documentation -Add or update the bundle in `docs/community/bundles.md`. Keep rows alphabetical -by bundle name: - -```text -| | | `` | | | []() | -``` - -Before rendering the row, convert every user-derived display value to -single-line plain text: collapse CR/LF sequences to spaces, remove control -characters, and backslash-escape `\`, `|`, backticks, `*`, `_`, `[`, `]`, `<`, -and `>`. Use the validated HTTPS GitHub repository URL unchanged only as the -Markdown link destination. - -Render component counts compactly, omitting zero-valued component types. Use -`None` when no companion catalogs are needed and `Documented` otherwise; the -repository README remains the source for the actual URLs. +The documentation build generates the community bundle directory and detail +pages directly from the catalog. Do not edit `docs/community/bundles.md` or +generated documentation. The repository README remains the source for required +component catalog URLs and setup commands. ## Step 6 - Create a Draft Pull Request @@ -417,7 +404,7 @@ Create one draft pull request. This repository-owned gh-aw maintenance workflow does not perform the contributor open-PR count check or request confirmation. After successful validation and -allowed catalog/docs file updates, emit the configured draft `create_pull_request` +allowed catalog updates, emit the configured draft `create_pull_request` safe output regardless of the submitter's or filing account's open PR count. - New entry branch: @@ -427,8 +414,8 @@ safe output regardless of the submitter's or filing account's open PR count. - New title: `Add bundle to community catalog` - Update title: `Update bundle to v` -The commit and PR description must summarize the catalog and documentation -changes, list the validation results, include +The commit and PR description must summarize the catalog changes, list the +validation results, include `Closes #${{ github.event.issue.number }}`, and mention the submitter with `cc @`. @@ -440,9 +427,8 @@ Assisted-by: GitHub Copilot (model: , autonomous) ## Important Rules -- Modify only `bundles/catalog.community.json` and - `docs/community/bundles.md`. -- Keep JSON entries sorted by ID and documentation rows sorted by name. +- Modify only `bundles/catalog.community.json`. +- Keep JSON entries sorted by ID; documentation is generated at build time. - Never set a community bundle's `verified` field to true. - Never add, enable, or change the policy of a submitted catalog. - Never describe validation as a security audit or endorsement. diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index de3025a3e7..3603554743 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,11 +8,15 @@ on: paths: - 'docs/**' - 'presets/catalog.community.json' + - 'bundles/catalog.community.json' - '.github/workflows/docs.yml' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: + schedule: + - cron: "17 4 * * 1" + # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read @@ -49,6 +53,11 @@ jobs: env: GH_TOKEN: ${{ github.token }} + - name: Generate community bundle documentation + run: python3 docs/generate_bundles.py --fetch-stars + env: + GH_TOKEN: ${{ github.token }} + - name: Build with DocFX run: | cd docs diff --git a/docs/.gitignore b/docs/.gitignore index c5abf40617..36f571cdfc 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -4,6 +4,7 @@ obj/ .docfx/ _generated/ community/presets/ +community/bundles/ # Temporary files *.tmp diff --git a/docs/README.md b/docs/README.md index 467783a2a7..78523ecbe8 100644 --- a/docs/README.md +++ b/docs/README.md @@ -12,10 +12,11 @@ To build the documentation locally: dotnet tool install -g docfx ``` -2. Generate the community preset directory from the local catalog: +2. Generate the community preset and bundle directories from the local catalogs: ```bash python3 docs/generate_presets.py --fetch-stars + python3 docs/generate_bundles.py --fetch-stars ``` 3. Build the documentation: @@ -27,18 +28,19 @@ To build the documentation locally: 4. Open your browser to `http://localhost:8080` to view the documentation. -Run the generator again after editing `presets/catalog.community.json`. -It creates the ignored `_generated/preset-directory.md` include and -`community/presets/*.md` detail pages, removing pages for deleted entries. +Run the corresponding generator again after editing `presets/catalog.community.json` +or `bundles/catalog.community.json`. They create the ignored +`_generated/preset-directory.md` and `_generated/bundle-directory.md` includes and +`community/presets/*.md` and `community/bundles/*.md` detail pages, removing pages for deleted entries. Do not edit these generated files. The directory uses only catalog metadata: -building it does not fetch or execute third-party preset content. With +building it does not fetch or execute third-party preset or bundle content. With `--fetch-stars`, it reads star counts from the GitHub API once per repository. Set `GH_TOKEN` or `GITHUB_TOKEN` for authenticated API limits; the deployment workflow uses its repository token. Counts reflect the last build, and shared repositories have the same count. Failed lookups produce warnings and show "Stars unavailable", never an invented zero. Omit `--fetch-stars` -for an offline build with unavailable counts. Its search, tag, -and sort controls enhance a complete static listing, which remains readable +for an offline build with unavailable counts. Search, tag, role/team (bundles), +and sort controls enhance complete static listings, which remain readable without JavaScript. ## Structure @@ -126,9 +128,11 @@ the site homepage. Process command references and authentication remain under ## Deployment -Documentation, community preset catalog, and docs workflow changes on the +Documentation, community preset or bundle catalog, and docs workflow changes on the upstream `main` branch trigger the normal GitHub Pages deployment. Each build -generates the preset directory and detail pages and refreshes repository star -counts before running DocFX. Manual runs use the same path; there is no separate -weekly schedule. The workflow is defined in `.github/workflows/docs.yml` and +generates the preset and bundle directories and detail pages and refreshes repository star +counts before running DocFX. A weekly run on Mondays at 04:17 UTC refreshes +the site and its build-time star counts, using the same path as manual runs. +It does not write star counts back to the catalogs. +The workflow is defined in `.github/workflows/docs.yml` and runs only in the upstream repository. diff --git a/docs/assets/bundle-catalog.css b/docs/assets/bundle-catalog.css new file mode 100644 index 0000000000..e737bd8d57 --- /dev/null +++ b/docs/assets/bundle-catalog.css @@ -0,0 +1,175 @@ +.bundle-catalog, +.bundle-detail { + --bundle-muted: var(--bs-secondary-color, #59636e); + --bundle-border: var(--bs-border-color, #d1d9e0); +} + +.bundle-controls { + display: grid; + grid-template-columns: repeat(2, minmax(8rem, 1fr)) minmax(9rem, 1fr) auto; + align-items: end; + gap: 1rem; + margin: 2rem 0 1rem; +} + +.bundle-catalog [hidden] { + display: none !important; +} + +.bundle-search { + grid-column: 1 / -1; +} + +.bundle-controls label { + display: block; + margin-bottom: 0.4rem; + font-weight: 600; +} + +.bundle-controls input, +.bundle-controls select, +.bundle-reset { + min-height: 2.75rem; + width: 100%; + padding: 0.5rem 0.75rem; + border: 1px solid var(--bundle-border); + border-radius: 0.375rem; + color: var(--bs-body-color, #1f2328); + background: var(--bs-body-bg, #fff); + font: inherit; +} + +.bundle-controls input::placeholder { + color: var(--bundle-muted); + opacity: 1; +} + +.bundle-reset:hover { + background: var(--bs-tertiary-bg, #f6f8fa); +} + +.bundle-controls :focus-visible, +.bundle-catalog a:focus-visible, +.bundle-detail a:focus-visible { + outline: 2px solid var(--bs-link-color, #0969da); + outline-offset: 3px; +} + +.bundle-result-count, +.bundle-entry-meta { + color: var(--bundle-muted); + font-size: 0.9rem; +} + +.bundle-results { + list-style: none; + padding: 0; + margin: 0 0 2rem; +} + +.bundle-entry { + padding: 1.5rem 0; + border-top: 1px solid var(--bundle-border); +} + +.bundle-entry-heading { + display: flex; + align-items: baseline; + justify-content: space-between; + gap: 1rem; +} + +.bundle-entry-heading h2 { + margin: 0 0 0.5rem; + border: 0; + font-size: 1.2rem; +} + +.bundle-entry p { + margin: 0 0 0.75rem; +} + +.bundle-version { + color: var(--bundle-muted); + font-size: 0.85rem; + white-space: nowrap; +} + +.bundle-entry-stats { + display: flex; + align-items: baseline; + flex-shrink: 0; + gap: 1rem; +} + +.bundle-stars { + font-size: 0.85rem; + white-space: nowrap; +} + +.bundle-entry-stats span.bundle-stars { + color: var(--bundle-muted); +} + +.bundle-tags { + display: flex; + flex-wrap: wrap; + gap: 0.4rem; +} + +.bundle-tag { + padding: 0.15rem 0.55rem; + border: 1px solid var(--bundle-border); + border-radius: 1rem; + font-size: 0.8rem; +} + +.bundle-metadata { + display: grid; + grid-template-columns: minmax(9rem, 1fr) minmax(0, 3fr); + gap: 0.75rem 1.5rem; + margin: 1.5rem 0 2rem; +} + +.bundle-metadata dt, +.bundle-metadata dd { + margin: 0; +} + +.bundle-detail, +.bundle-entry { + overflow-wrap: anywhere; +} + +.bundle-source-links { + display: flex; + flex-wrap: wrap; + gap: 0.75rem 1.5rem; +} + +@media (max-width: 900px) { + .bundle-controls { + grid-template-columns: 1fr 1fr; + } +} + +@media (max-width: 480px) { + .bundle-controls, + .bundle-metadata { + grid-template-columns: 1fr; + } + + .bundle-metadata { + gap: 0.25rem; + } + + .bundle-metadata dd { + margin-bottom: 0.75rem; + } + + .bundle-entry-heading { + flex-direction: column; + gap: 0; + margin-bottom: 0.5rem; + } +} diff --git a/docs/assets/bundle-catalog.js b/docs/assets/bundle-catalog.js new file mode 100644 index 0000000000..8360218a90 --- /dev/null +++ b/docs/assets/bundle-catalog.js @@ -0,0 +1,66 @@ +(() => { + const catalog = document.querySelector("[data-bundle-catalog]"); + if (!catalog) return; + + const form = catalog.querySelector("[data-bundle-controls]"); + const query = form.elements.namedItem("q"); + const tag = form.elements.namedItem("tag"); + const role = form.elements.namedItem("role"); + const sort = form.elements.namedItem("sort"); + const list = catalog.querySelector(".bundle-results"); + const entries = Array.from(list.children); + const status = catalog.querySelector("[data-bundle-status]"); + const empty = catalog.querySelector("[data-bundle-empty]"); + const searchable = entries.map((entry) => ({ + entry, + text: entry.dataset.bundleSearch.toLocaleLowerCase(), + tags: JSON.parse(entry.dataset.bundleTags), + role: entry.dataset.bundleRole, + })); + const params = new URLSearchParams(window.location.search); + query.value = params.get("q") || ""; + tag.value = params.get("tag") || ""; + if (!tag.value) tag.value = ""; + role.value = params.get("role") || ""; + if (!role.value) role.value = ""; + sort.value = params.get("sort") === "za" ? "za" : "az"; + + function update() { + const words = query.value.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean); + let visible = 0; + for (const item of searchable) { + const matches = words.every((word) => item.text.includes(word)) + && (!tag.value || item.tags.includes(tag.value)) + && (!role.value || item.role === role.value); + item.entry.hidden = !matches; + if (matches) visible += 1; + } + const ordered = sort.value === "za" ? [...entries].reverse() : entries; + for (const entry of ordered) list.append(entry); + status.textContent = `${visible} of ${entries.length} bundles`; + empty.hidden = visible !== 0; + + const next = new URL(window.location.href); + for (const [key, value] of [["q", query.value], ["tag", tag.value], ["role", role.value], ["sort", sort.value === "za" ? "za" : ""]]) { + if (value) next.searchParams.set(key, value); + else next.searchParams.delete(key); + } + window.history.replaceState(null, "", next); + } + + form.addEventListener("input", update); + form.addEventListener("change", update); + form.addEventListener("submit", (event) => { + event.preventDefault(); + update(); + }); + form.addEventListener("reset", () => { + query.value = ""; + tag.value = ""; + role.value = ""; + sort.value = "az"; + update(); + }); + update(); + form.hidden = false; +})(); diff --git a/docs/bundles/publishing.md b/docs/bundles/publishing.md index 948a8afb6a..d2eecb3bd5 100644 --- a/docs/bundles/publishing.md +++ b/docs/bundles/publishing.md @@ -3,7 +3,8 @@ Publish a versioned bundle artifact, test its distribution path, then submit metadata through a Bundle Submission issue. Use the same issue flow for new entries, version updates, and repairs. Do not hand-edit the community catalog -or its documentation table as a substitute for submission. +as a substitute for submission. The documentation directory is generated from +the catalog, not maintained separately. Community publication is not code certification. Maintainers check metadata, links, artifact consistency, and submitted installation evidence; they do not @@ -120,10 +121,11 @@ mismatching checksum fails validation; it is not silently replaced. and testing attestations. It does not execute downloaded content or audit the code. 4. On success, automation proposes a draft pull request updating - `bundles/catalog.community.json` and `docs/community/bundles.md`. It records + `bundles/catalog.community.json`. It records the actual downloaded archive's SHA-256 and keeps `verified: false`. 5. A maintainer reviews the catalog changes and merges them when approved. - The entry becomes discoverable with `specify bundle search`. + The entry becomes discoverable with `specify bundle search` and appears in + the generated community directory and detail pages on the documentation site. Confirmed submission defects receive `validation-failed` with correction details. Permission, network, or tooling blockers are reported as blocked, diff --git a/docs/community/bundles.md b/docs/community/bundles.md index 911e1cbfd8..e6fabc06ba 100644 --- a/docs/community/bundles.md +++ b/docs/community/bundles.md @@ -7,14 +7,7 @@ Bundles compose existing Spec Kit components — extensions, presets, workflows, Accepted community bundle entries are published in [`bundles/catalog.community.json`](https://github.com/github/spec-kit/blob/main/bundles/catalog.community.json) and listed below. The built-in community source is discovery-only: `specify bundle search` and `specify bundle info` can inspect entries, but installing by ID requires explicitly adding a vetted, install-allowed catalog. Explicit catalogs use a higher default precedence than the built-in community source. To submit a bundle for metadata validation, follow the [publishing guide](../bundles/publishing.md) and file a [Bundle Submission](https://github.com/github/spec-kit/issues/new?template=bundle_submission.yml) issue. -| Bundle | Purpose | Role or team | Provides | Required catalogs | URL | -|--------|---------|--------------|----------|-------------------|-----| -| Agentstandards Multi-Vendor Architecture | Installs a Codex-orchestrated, multi-vendor architecture council, its hard task gate, and the supporting Spec Kit workflow. | `architecture-governance` | 1 extension, 1 preset, 1 workflow | Documented | [agentstandards](https://github.com/bbjwz/agentstandards) | -| SicarioSpec Security & Governance Bundle | Secure-by-default governance bundle for GitHub Spec Kit. Enforces data classification, threat modeling, and code-owned verification gates. | `security-engineer` | 1 extension, 11 presets | Documented | [sicario-spec](https://github.com/dfirs1car1o/sicario-spec) | -| Spec Kit for Azure DevOps | The ado extension plus the ado-lifecycle workflow: an ADO story to Done with a human gate on every board or PR change. | `developer` | 1 extension, 1 workflow | Documented | [spec-kit-ado](https://github.com/praveenlavu/spec-kit-ado) | -| Spec Kit for GitHub Projects | The ghp extension and the ghp-lifecycle workflow together: GitHub issue to Done through Spec Kit, with a human sign-off before every write. | `developer` | 1 extension, 1 workflow | Documented | [spec-kit-ghp](https://github.com/praveenlavu/spec-kit-ghp) | -| Spec Kit lifecycle for Jira | A Jira story to Done through Spec Kit, with a human sign-off before every Jira or PR write. | `developer` | 1 extension, 1 workflow | Documented | [spec-kit-jira](https://github.com/praveenlavu/spec-kit-jira) | -| SpecAssay | Durable-ID promotion for stock Spec Kit: templates, Gate 2 refusal, and trace-manifest emission. | `developer` | 1 extension, 1 preset | Documented | [specassay](https://github.com/rdryfoos/specassay) | +[!INCLUDE [Community bundle directory](../_generated/bundle-directory.md)] ## See also diff --git a/docs/docfx.json b/docs/docfx.json index 43b2eecb07..8eb15f90da 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -7,6 +7,7 @@ "toc.yml", "community/*.md", "community/presets/*.md", + "community/bundles/*.md", "bundles/*.md", "extensions/*.md", "guides/*.md", diff --git a/docs/generate_bundles.py b/docs/generate_bundles.py new file mode 100644 index 0000000000..787f2dd1cb --- /dev/null +++ b/docs/generate_bundles.py @@ -0,0 +1,308 @@ +"""Generate the community bundle directory and DocFX detail pages from the catalog.""" + +import argparse +import html +import json +import os +import re +import sys +from concurrent.futures import ThreadPoolExecutor +from http.client import HTTPException +from pathlib import Path +from urllib.parse import urlsplit +from urllib.request import Request, urlopen + + +ROOT = Path(__file__).resolve().parent.parent +COMPONENTS = ("extensions", "presets", "steps", "workflows") + + +def text(value: object, context: str) -> str: + if not isinstance(value, str) or not value.strip(): + raise ValueError(f"{context} must be a non-empty string") + return value + + +def escape_metadata(value: str) -> str: + # Literal blank lines end raw HTML blocks in DocFX's Markdown parser. + return html.escape(value).replace("\r", " ").replace("\n", " ") + + +def url(value: object, context: str) -> str: + value = text(value, context) + parsed = urlsplit(value) + if ( + parsed.scheme != "https" + or not parsed.hostname + or parsed.username is not None + or parsed.password is not None + or any(character.isspace() or ord(character) < 32 for character in value) + ): + raise ValueError(f"{context} must be an HTTPS URL without credentials or whitespace") + return value + + +def unique_keys(pairs: list[tuple]) -> dict: + result = {} + for key, value in pairs: + if key in result: + raise ValueError(f"duplicate catalog key: {key}") + result[key] = value + return result + + +def load_bundles(catalog_path: Path) -> list[dict]: + catalog = json.loads(catalog_path.read_text(encoding="utf-8"), object_pairs_hook=unique_keys) + if not isinstance(catalog, dict) or catalog.get("schema_version") != "1.0": + raise ValueError("bundle catalog must be an object with schema_version 1.0") + entries = catalog.get("bundles") + if not isinstance(entries, dict): + raise ValueError("bundle catalog must contain a bundles object") + for bundle_id, entry in entries.items(): + if not re.fullmatch(r"[a-z0-9](?:[a-z0-9._-]*[a-z0-9])?", bundle_id): + raise ValueError(f"invalid bundle ID: {bundle_id}") + if not isinstance(entry, dict) or entry.get("id") != bundle_id: + raise ValueError(f"{bundle_id}: entry ID must match its catalog key") + for field in ("name", "description", "author", "version", "license", "role"): + text(entry.get(field), f"{bundle_id}.{field}") + for field in ("repository", "download_url"): + url(entry.get(field), f"{bundle_id}.{field}") + if "documentation" in entry: + url(entry["documentation"], f"{bundle_id}.documentation") + requires = entry.get("requires") + if not isinstance(requires, dict): + raise ValueError(f"{bundle_id}.requires must be an object") + text(requires.get("speckit_version"), f"{bundle_id}.requires.speckit_version") + provided = entry.get("provides") + if not isinstance(provided, dict): + raise ValueError(f"{bundle_id}.provides must be an object") + for kind in COMPONENTS: + count = provided.get(kind, 0) + if not isinstance(count, int) or isinstance(count, bool) or count < 0: + raise ValueError(f"{bundle_id}.provides.{kind} must be a non-negative integer") + tags = entry.get("tags") + if not isinstance(tags, list): + raise ValueError(f"{bundle_id}.tags must be a list") + for tag in tags: + text(tag, f"{bundle_id}.tags") + for field in ("updated_at", "sha256"): + if field in entry: + text(entry[field], f"{bundle_id}.{field}") + integration = entry.get("integration") + if integration is not None: + if not isinstance(integration, dict): + raise ValueError(f"{bundle_id}.integration must be an object") + text(integration.get("id"), f"{bundle_id}.integration.id") + if entry.get("verified") is not False: + raise ValueError(f"{bundle_id}.verified must be false for a community bundle") + return sorted(entries.values(), key=lambda entry: (entry["name"].casefold(), entry["id"])) + + +def contributions(entry: dict) -> str: + return ", ".join( + f"{count} {kind[:-1] if count == 1 else kind}" + for kind in COMPONENTS + if (count := entry["provides"].get(kind, 0)) + ) or "No components listed" + + +def repository_stars(bundles: list[dict]) -> dict[str, int | None]: + token = os.environ.get("GH_TOKEN") or os.environ.get("GITHUB_TOKEN") + headers = { + "Accept": "application/vnd.github+json", + "User-Agent": "spec-kit-bundle-documentation", + "X-GitHub-Api-Version": "2022-11-28", + } + if token: + headers["Authorization"] = f"Bearer {token}" + + repositories = {} + for entry in bundles: + repository = entry["repository"] + parsed = urlsplit(repository) + path = parsed.path.strip("/").removesuffix(".git") + if ( + parsed.netloc.lower() != "github.com" + or parsed.query + or parsed.fragment + or not re.fullmatch(r"[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+", path) + ): + print(f"Warning: stars unavailable for {repository}: not a GitHub repository URL", file=sys.stderr) + repositories[repository] = None + else: + repositories[repository] = path.casefold() + + def fetch(repository: str) -> int | None: + request = Request(f"https://api.github.com/repos/{repository}", headers=headers) + try: + with urlopen(request, timeout=10) as response: + data = json.load(response) + count = data.get("stargazers_count") if isinstance(data, dict) else None + if not isinstance(count, int) or isinstance(count, bool) or count < 0: + raise ValueError("GitHub response has no valid stargazers_count") + return count + except (OSError, ValueError, HTTPException) as exc: + print(f"Warning: stars unavailable for {repository}: {exc}", file=sys.stderr) + return None + + unique = sorted({repository for repository in repositories.values() if repository is not None}) + with ThreadPoolExecutor(max_workers=6) as pool: + counts = dict(zip(unique, pool.map(fetch, unique))) + return { + repository: counts.get(key) if key is not None else None + for repository, key in repositories.items() + } + + +def star_badge(entry: dict, count: int | None) -> str: + if count is None: + return 'Stars unavailable' + repository = entry["repository"].rstrip("/").removesuffix(".git") + return ( + f'' + f' {count:,}' + ) + + +def directory(bundles: list[dict], stars: dict[str, int | None]) -> str: + escape = escape_metadata + tags = sorted({tag for entry in bundles for tag in entry["tags"]}, key=str.casefold) + roles = sorted({entry["role"] for entry in bundles}, key=str.casefold) + options = "".join(f'' for tag in tags) + role_options = "".join(f'' for role in roles) + rows = [] + for entry in bundles: + search = " ".join( + [entry[field] for field in ("id", "name", "description", "author", "role")] + + entry["tags"] + [contributions(entry)] + ) + badges = "".join(f'{escape(tag)}' for tag in entry["tags"]) + rows.append( + f'
  • ' + f'

    ' + f'{escape(entry["name"])}

    ' + f'{escape(entry["version"])}{star_badge(entry, stars.get(entry["repository"]))}
    ' + f'

    {escape(entry["description"])}

    ' + f'' + f'
    {badges}
  • ' + ) + return f""" + + +
    + +

    {len(bundles)} bundles

    + +
      {"".join(rows)}
    +
    +""" + + +def detail(entry: dict, stars: int | None) -> str: + escape = escape_metadata + metadata = { + "Bundle ID": entry["id"], + "Catalog version": entry["version"], + "Role or team": entry["role"], + "Author": entry["author"], + "Repository stars": f"{stars:,}" if stars is not None else "Unavailable", + "License": entry["license"], + "Requires Spec Kit": entry["requires"]["speckit_version"], + "Integration target": (entry.get("integration") or {}).get("id", "Not specified"), + "Provides": contributions(entry), + "Tags": ", ".join(entry["tags"]) or "None listed", + "Updated": entry.get("updated_at", "Not provided"), + } + definitions = "".join( + f"
    {escape(label)}
    {escape(value)}
    " for label, value in metadata.items() + ) + checksum = ( + f'

    Catalog SHA-256: {escape(entry["sha256"])}

    ' + if entry.get("sha256") else "

    No SHA-256 digest is listed in this catalog entry.

    " + ) + documentation = ( + f'Author documentation' + if entry.get("documentation") else "" + ) + return f""" + + +
    +

    Back to community bundles

    +

    {escape(entry["name"])}

    +

    {escape(entry["description"])}

    + +

    Bundle details

    + +

    Review before installing

    +

    This bundle is independently maintained. Maintainers check catalog metadata only; +they do not review, audit, endorse, or support the bundle code or the components it installs. +You must vet the bundle manifest, component catalogs, source repositories, and exact +release before installation.

    +

    The community catalog is discovery-only. Installing by ID requires explicitly +adding a vetted, install-allowed bundle catalog. Bundle installation does not +register or trust companion component catalogs; inspect the author's README +for required catalogs and setup instructions.

    +

    After vetting, download the catalog-listed +release archive for version {escape(entry["version"])} and follow the +artifact installation instructions.

    +{checksum} +

    A digest checks archive integrity; it is not evidence of code review or safety.

    +

    See also

    + +
    +""" + + +def generate(catalog_path: Path, docs_path: Path, *, fetch_stars: bool = False) -> int: + bundles = load_bundles(catalog_path) + stars = repository_stars(bundles) if fetch_stars else {} + pages = {f"{entry['id']}.md": detail(entry, stars.get(entry["repository"])) for entry in bundles} + listing = directory(bundles, stars) + details_path = docs_path / "community" / "bundles" + details_path.mkdir(parents=True, exist_ok=True) + for stale in details_path.glob("*.md"): + if stale.name not in pages: + stale.unlink() + for name, content in pages.items(): + (details_path / name).write_text(content, encoding="utf-8") + include_path = docs_path / "_generated" + include_path.mkdir(parents=True, exist_ok=True) + (include_path / "bundle-directory.md").write_text(listing, encoding="utf-8") + return len(bundles) + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--catalog", type=Path, default=ROOT / "bundles/catalog.community.json") + parser.add_argument("--docs", type=Path, default=ROOT / "docs") + parser.add_argument("--fetch-stars", action="store_true", help="Fetch GitHub repository star counts at build time") + args = parser.parse_args() + try: + count = generate(args.catalog, args.docs, fetch_stars=args.fetch_stars) + except (ValueError, OSError) as exc: + parser.exit(1, f"Bundle documentation generation failed: {exc}\n") + print(f"Generated directory and detail pages for {count} community bundles.") + + +if __name__ == "__main__": + main() diff --git a/tests/test_bundle_documentation.py b/tests/test_bundle_documentation.py new file mode 100644 index 0000000000..beb5c83635 --- /dev/null +++ b/tests/test_bundle_documentation.py @@ -0,0 +1,493 @@ +"""Catalog-derived documentation, invalid inputs, and docs deployment wiring.""" + +import copy +import importlib.util +import io +import json +import shutil +import subprocess +import sys +from html.parser import HTMLParser +from http.client import IncompleteRead +from pathlib import Path + +import pytest +import yaml + + +ROOT = Path(__file__).resolve().parent.parent +GENERATOR = ROOT / "docs/generate_bundles.py" +spec = importlib.util.spec_from_file_location("generate_bundles", GENERATOR) +generator = importlib.util.module_from_spec(spec) +spec.loader.exec_module(generator) + + +class DirectoryParser(HTMLParser): + def __init__(self): + super().__init__() + self.entries = [] + self.links = [] + self.scripts = [] + + def handle_starttag(self, tag, attrs): + attrs = dict(attrs) + if tag == "li" and attrs.get("class") == "bundle-entry": + self.entries.append(attrs) + if tag == "a": + self.links.append(attrs["href"]) + if tag == "script": + self.scripts.append(attrs.get("src")) + + +@pytest.fixture +def catalog(tmp_path): + entry = { + "id": "sample", + "name": "Sample Bundle", + "description": "Adds useful context", + "author": "Contributor", + "version": "1.2.3", + "license": "MIT", + "role": "developer", + "verified": False, + "repository": "https://github.com/example/bundles", + "documentation": "https://github.com/example/bundles/blob/v1.2.3/sample/README.md", + "download_url": "https://github.com/example/bundles/releases/download/sample-v1.2.3/sample.zip", + "requires": { + "speckit_version": ">=1.0.0", + }, + "provides": {"extensions": 1, "presets": 2, "steps": 0, "workflows": 1}, + "tags": ["context", "planning"], + } + data = {"schema_version": "1.0", "bundles": {"sample": entry}} + path = tmp_path / "catalog.json" + path.write_text(json.dumps(data), encoding="utf-8") + return data, path, tmp_path / "docs" + + +def test_real_catalog_has_one_page_and_static_link_per_entry(tmp_path): + catalog_path = ROOT / "bundles/catalog.community.json" + entries = json.loads(catalog_path.read_text(encoding="utf-8"))["bundles"] + assert generator.generate(catalog_path, tmp_path) == len(entries) + listing = (tmp_path / "_generated/bundle-directory.md").read_text(encoding="utf-8") + parsed = DirectoryParser() + parsed.feed(listing) + assert len(parsed.entries) == len(entries) + assert set(parsed.links) == {f"bundles/{bundle_id}.md" for bundle_id in entries} + assert all("hidden" not in entry for entry in parsed.entries) + assert {page.stem for page in (tmp_path / "community/bundles").glob("*.md")} == set(entries) + for bundle_id, entry in entries.items(): + detail = (tmp_path / f"community/bundles/{bundle_id}.md").read_text(encoding="utf-8") + assert generator.html.escape(entry["name"]) in detail + assert generator.html.escape(entry["download_url"]) in detail + assert "do not review, audit, endorse, or support" in detail + assert "after vetting" in detail.lower() + assert "--install-allowed" not in detail + + +def test_generation_is_deterministic_and_removes_deleted_pages(catalog): + data, path, docs = catalog + other = copy.deepcopy(data["bundles"]["sample"]) + other.update(id="other", name="Another Bundle") + data["bundles"]["other"] = other + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + first = (docs / "_generated/bundle-directory.md").read_bytes() + assert first.index(b"Another Bundle") < first.index(b"Sample Bundle") + generator.generate(path, docs) + assert (docs / "_generated/bundle-directory.md").read_bytes() == first + del data["bundles"]["other"] + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + assert not (docs / "community/bundles/other.md").exists() + assert (docs / "community/bundles/sample.md").is_file() + + +def test_untrusted_metadata_is_text_not_markup_or_markdown(catalog): + data, path, docs = catalog + entry = data["bundles"]["sample"] + payload = '\n\n\r\n![x](javascript:alert(1)) & |' + entry.update(name=payload, description=payload, author=payload, tags=[payload]) + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + for generated in ( + docs / "_generated/bundle-directory.md", + docs / "community/bundles/sample.md", + ): + source = generated.read_text(encoding="utf-8") + assert payload not in source + assert generator.escape_metadata(payload) in source + listing = (docs / "_generated/bundle-directory.md").read_text(encoding="utf-8") + detail = (docs / "community/bundles/sample.md").read_text(encoding="utf-8") + parsed = DirectoryParser() + parsed.feed(listing) + assert parsed.scripts == ["../assets/bundle-catalog.js"] + assert json.loads(parsed.entries[0]["data-bundle-tags"]) == [payload] + assert generator.escape_metadata(payload) in detail + assert "