From 6bedcf1f36c747cf9ac464c41eb67a1c5d402529 Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Tue, 1 Dec 2026 14:59:16 -0600 Subject: [PATCH 1/2] feat(docs): generate community integrations directory Render an honest empty state and catalog-derived adapter pages, reuse existing documentation deployment and weekly star refresh, and cover populated fixtures without changing the catalog or runtime. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/docs.yml | 6 + docs/.gitignore | 1 + docs/README.md | 22 +- docs/assets/integration-catalog.js | 60 ++++ docs/community/integrations.md | 9 +- docs/docfx.json | 1 + docs/generate_integrations.py | 262 ++++++++++++++++ docs/integrations/contributing.md | 7 + tests/test_integration_documentation.py | 390 ++++++++++++++++++++++++ 9 files changed, 746 insertions(+), 12 deletions(-) create mode 100644 docs/assets/integration-catalog.js create mode 100644 docs/generate_integrations.py create mode 100644 tests/test_integration_documentation.py diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 25e2e2ff39..6c1f3e4b43 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,6 +8,7 @@ on: paths: - 'docs/**' - 'extensions/catalog.community.json' + - 'integrations/catalog.community.json' - 'presets/catalog.community.json' - 'bundles/catalog.community.json' - 'workflows/catalog.community.json' @@ -56,6 +57,11 @@ jobs: env: GH_TOKEN: ${{ github.token }} + - name: Generate community integration documentation + run: python3 docs/generate_integrations.py --fetch-stars + env: + GH_TOKEN: ${{ github.token }} + - name: Generate community preset documentation run: python3 docs/generate_presets.py --fetch-stars env: diff --git a/docs/.gitignore b/docs/.gitignore index 44aa499e96..025f5bdf7d 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -5,6 +5,7 @@ obj/ _generated/ community/presets/ community/extensions/ +community/integrations/ community/bundles/ community/workflows/ community/workflow-steps/ diff --git a/docs/README.md b/docs/README.md index 7e127b6a65..a8286e7080 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 extension, preset, bundle, workflow, and workflow step directories from the local catalogs: +2. Generate the community extension, integration, preset, bundle, workflow, and workflow step directories from the local catalogs: ```bash python3 docs/generate_extensions.py --fetch-stars + python3 docs/generate_integrations.py --fetch-stars python3 docs/generate_presets.py --fetch-stars python3 docs/generate_bundles.py --fetch-stars python3 docs/generate_workflows.py --fetch-stars @@ -31,17 +32,17 @@ To build the documentation locally: 4. Open your browser to `http://localhost:8080` to view the documentation. -Run the corresponding generator again after editing `extensions/catalog.community.json`, `presets/catalog.community.json`, +Run the corresponding generator again after editing `extensions/catalog.community.json`, `integrations/catalog.community.json`, `presets/catalog.community.json`, `bundles/catalog.community.json`, `workflows/catalog.community.json`, or `workflows/step-catalog.community.json`. They create -the ignored `_generated/extension-directory.md`, `_generated/preset-directory.md`, `_generated/bundle-directory.md`, +the ignored `_generated/extension-directory.md`, `_generated/integration-directory.md`, `_generated/preset-directory.md`, `_generated/bundle-directory.md`, `_generated/workflow-directory.md`, and `_generated/workflow-step-directory.md` -includes and `community/extensions/*.md`, `community/presets/*.md`, `community/bundles/*.md`, +includes and `community/extensions/*.md`, `community/integrations/*.md`, `community/presets/*.md`, `community/bundles/*.md`, `community/workflows/*.md`, and `community/workflow-steps/*.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 extension, preset, bundle, workflow, or -executable step-package content. Extension and step pages reuse the workflow directory's +building it does not fetch or execute third-party extension, integration, preset, bundle, workflow, or +executable step-package content. Extension, integration, and step pages reuse the workflow directory's stylesheet and build-time star lookup; only workflows have integration filters. 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 @@ -51,6 +52,9 @@ and show "Stars unavailable", never an invented zero. Omit `--fetch-stars` for an offline build with unavailable counts. Search, tag, role/team (bundles), category/effect (extensions), declared integration (workflows), and sort controls enhance complete static listings, which remain readable without JavaScript. +An empty integration catalog shows contribution and built-in integration links +instead of search/filter controls; adding the first entry generates the listing +and detail page automatically. ## Structure @@ -123,7 +127,7 @@ the site homepage. Process command references and authentication remain under - `bundles/catalogs.md` - Bundle catalogs, policies, and release history - `bundles/publishing.md` - Bundle publishing and catalog submission guide - `community/extensions.md` - Catalog-generated community extension directory -- `community/integrations.md` - Community integration discovery and contribution +- `community/integrations.md` - Catalog-generated community integration directory - `community/workflows.md` - Community workflow listing and contribution - `community/workflow-steps.md` - Catalog-generated community step directory - `workflow-steps/decision.md` - Version-specific Decision 0.9.0 dependency notes @@ -138,9 +142,9 @@ the site homepage. Process command references and authentication remain under ## Deployment -Documentation, community preset, bundle, workflow, or workflow step catalog, and docs workflow changes on the +Documentation, community extension, integration, preset, bundle, workflow, or workflow step catalog, and docs workflow changes on the upstream `main` branch trigger the normal GitHub Pages deployment. Each build -generates the preset, bundle, workflow, and workflow step directories and detail pages and refreshes repository star +generates the extension, integration, preset, bundle, workflow, and workflow step 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. diff --git a/docs/assets/integration-catalog.js b/docs/assets/integration-catalog.js new file mode 100644 index 0000000000..131ec01c8d --- /dev/null +++ b/docs/assets/integration-catalog.js @@ -0,0 +1,60 @@ +(() => { + const catalog = document.querySelector("[data-integration-catalog]"); + if (!catalog) return; + + const form = catalog.querySelector("[data-integration-controls]"); + const query = form.elements.namedItem("q"); + const tag = form.elements.namedItem("tag"); + const sort = form.elements.namedItem("sort"); + const list = catalog.querySelector(".workflow-results"); + const entries = Array.from(list.children); + const status = catalog.querySelector("[data-integration-status]"); + const empty = catalog.querySelector("[data-integration-empty]"); + const searchable = entries.map((entry) => ({ + entry, + text: entry.dataset.integrationSearch.toLocaleLowerCase(), + tags: JSON.parse(entry.dataset.integrationTags), + })); + const params = new URLSearchParams(window.location.search); + query.value = params.get("q") || ""; + tag.value = params.get("tag") || ""; + if (!tag.value) tag.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)); + 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} integrations`; + empty.hidden = visible !== 0; + + const next = new URL(window.location.href); + for (const [key, value] of [["q", query.value], ["tag", tag.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 = ""; + sort.value = "az"; + update(); + }); + update(); + form.hidden = false; +})(); diff --git a/docs/community/integrations.md b/docs/community/integrations.md index 26345ebd4c..4db408c069 100644 --- a/docs/community/integrations.md +++ b/docs/community/integrations.md @@ -11,9 +11,12 @@ independently maintained external adapters. ## Available integrations -The [community integration catalog](https://github.com/github/spec-kit/blob/main/integrations/catalog.community.json) -currently contains no entries. Built-in integrations ship with the CLI and are -listed separately in the integration directory. +[!INCLUDE [Community integration directory](../_generated/integration-directory.md)] + +This directory is generated from the +[community integration catalog](https://github.com/github/spec-kit/blob/main/integrations/catalog.community.json). +Built-in integrations ship with the CLI and are listed separately in the +[integration directory](../integrations/index.md). Inspect the sources active in your project and search their metadata: diff --git a/docs/docfx.json b/docs/docfx.json index f72b07a638..e768798fc4 100644 --- a/docs/docfx.json +++ b/docs/docfx.json @@ -8,6 +8,7 @@ "community/*.md", "community/presets/*.md", "community/extensions/*.md", + "community/integrations/*.md", "community/bundles/*.md", "community/workflows/*.md", "community/workflow-steps/*.md", diff --git a/docs/generate_integrations.py b/docs/generate_integrations.py new file mode 100644 index 0000000000..5f5a794a1e --- /dev/null +++ b/docs/generate_integrations.py @@ -0,0 +1,262 @@ +"""Generate the community integration directory and external adapter detail pages.""" + +import argparse +import json +import re +from ipaddress import ip_address +from pathlib import Path +from urllib.parse import urlsplit + +if __package__: + from . import generate_workflows as shared +else: + import generate_workflows as shared + + +ROOT = Path(__file__).resolve().parent.parent +escape = shared.escape_metadata + + +def tools(entry: dict) -> list[str]: + values = entry.get("requires", {}).get("tools", []) + if values is None: + return [] + if not isinstance(values, list): + raise ValueError(f"{entry['id']}.requires.tools must be a list") + result = [] + for tool in values: + if not isinstance(tool, dict): + raise ValueError(f"{entry['id']}: tool requirement must be an object") + name = shared.text(tool.get("name"), "tool name") + if "version" in tool: + if not isinstance(tool["version"], str): + raise ValueError("tool version must be a string") + if tool["version"]: + name += " " + tool["version"] + if "required" in tool and not isinstance(tool["required"], bool): + raise ValueError("tool required must be a boolean") + if not tool.get("required", True): + name += " (optional)" + result.append(name) + return result + + +def archive_url(value: object, context: str) -> None: + parsed = urlsplit(shared.text(value, context)) + if parsed.scheme == "http": + host = parsed.hostname + loopback = host == "localhost" + if host and not loopback: + try: + loopback = ip_address(host).is_loopback + except ValueError: + loopback = False + if loopback: + shared.url(parsed._replace(scheme="https").geturl(), context) + return + shared.url(value, context) + + +def load_integrations(catalog_path: Path) -> list[dict]: + catalog = json.loads(catalog_path.read_text(encoding="utf-8"), object_pairs_hook=shared.unique_keys) + if not isinstance(catalog, dict) or catalog.get("schema_version") != "1.0": + raise ValueError("integration catalog must be an object with schema_version 1.0") + entries = catalog.get("integrations") + if not isinstance(entries, dict): + raise ValueError("integration catalog must contain an integrations object") + result = [] + for key, metadata in entries.items(): + if ( + not re.fullmatch(r"[a-z0-9][a-z0-9-]*", key) + or key in {"con", "prn", "aux", "nul"} + or re.fullmatch(r"(com|lpt)[1-9]", key) + ): + raise ValueError(f"invalid external integration ID: {key}") + if not isinstance(metadata, dict) or metadata.get("id", key) != key: + raise ValueError(f"{key}: entry ID must match its catalog key") + entry = {**metadata, "id": key} + for field in ("name", "description", "version"): + shared.text(entry.get(field), f"{key}.{field}") + for field in ("author", "license"): + if field in entry: + shared.text(entry[field], f"{key}.{field}") + if "repository" in entry: + shared.url(entry["repository"], f"{key}.repository") + if "download_url" in entry: + archive_url(entry["download_url"], f"{key}.download_url") + requires = entry.get("requires", {}) + if not isinstance(requires, dict): + raise ValueError(f"{key}.requires must be an object") + if "speckit_version" in requires: + shared.text(requires["speckit_version"], f"{key}.requires.speckit_version") + tools(entry) + tags = entry.get("tags", []) + if not isinstance(tags, list): + raise ValueError(f"{key}.tags must be a list") + for tag in tags: + shared.text(tag, f"{key}.tags") + if "sha256" in entry and ( + not isinstance(entry["sha256"], str) + or not re.fullmatch(r"[a-fA-F0-9]{64}", entry["sha256"]) + ): + raise ValueError(f"{key}.sha256 must contain 64 hexadecimal digits") + result.append(entry) + return sorted(result, key=lambda entry: (entry["name"].casefold(), entry["name"], entry["id"])) + + +def directory(entries: list[dict], stars: dict[str, int | None]) -> str: + header = "\n" + if not entries: + return header + """

No community integrations yet

+

External adapters added to the community catalog will appear here. +For agents that ship with the CLI, browse the built-in integrations. +To contribute an external adapter, follow the catalog submission guide.

+""" + tags = sorted({tag for entry in entries for tag in entry.get("tags", [])}, + key=lambda tag: (tag.casefold(), tag)) + options = "".join(f'' for tag in tags) + rows = [] + for entry in entries: + search = " ".join( + [entry[field] for field in ("id", "name", "description")] + + [entry.get("author", "")] + entry.get("tags", []) + tools(entry) + ) + badges = "".join(f'{escape(tag)}' for tag in entry.get("tags", [])) + rows.append( + f'
  • ' + f'

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

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

    {escape(entry["description"])}

    ' + f'

    Author: {escape(entry.get("author", "Not provided"))}

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

    {len(entries)} integrations

    + + +
    +""" + + +def detail(entry: dict, stars: int | None) -> str: + metadata = { + "Integration ID": entry["id"], + "Catalog version": entry["version"], + "Author": entry.get("author", "Not provided"), + "Repository stars": f"{stars:,}" if stars is not None else "Unavailable", + "License": entry.get("license", "Not provided"), + "Requires Spec Kit": entry.get("requires", {}).get("speckit_version", "Not specified"), + "Tool requirements": ", ".join(tools(entry)) or "None listed", + "Tags": ", ".join(entry.get("tags", [])) or "None listed", + } + definitions = "".join(f"
    {escape(label)}
    {escape(value)}
    " + for label, value in metadata.items()) + repository = ( + f'Source repository' + if entry.get("repository") else "Source repository: Not provided" + ) + archive = ( + f'

    Review the catalog-listed package archive ' + f'for version {escape(entry["version"])} before installation.

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

    No package archive URL is listed. External installation requires a reachable " + "package archive in an install-allowed catalog; a repository link is not enough.

    " + ) + checksum = ( + f'

    Catalog SHA-256: {escape(entry["sha256"])}. ' + "The installer checks this digest when supplied by the selected catalog.

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

    No SHA-256 digest is listed. Obtain and verify an integrity digest from " + "a source you trust before installation.

    " + ) + return f""" + + +
    +

    Back to community integrations

    +

    {escape(entry["name"])}

    +

    {escape(entry["description"])}

    +

    {repository}

    +

    External adapter details

    +
    {definitions}
    +

    Requirements and tags are author-declared metadata, not enforced permissions or +a sandbox. Missing metadata does not imply compatibility or absence of side effects. +Repository stars reflect the last documentation build, not a safety assessment.

    +

    Review before installing or using

    +

    This adapter is independently maintained. Maintainers check catalog metadata only; +they do not review, audit, endorse, or support adapter implementations. +You must vet the exact release, Python code, dependencies, credentials, network access, +generated files, commands, hooks, and side effects before installation and use.

    +

    External adapters adapt the host's commands and extension/preset contributions; +they do not redistribute a core command inventory. A package needs root +integration.yml and __init__.py exporting an +IntegrationBase subclass. Adapter Python executes with your user permissions.

    +

    The default community catalog is discovery-only. A listing is not installation +permission. Inspect specify integration catalog list and project configuration: +search and info use the active catalog stack, not exclusively this source. +Install only through a separately vetted, explicitly install-allowed catalog. +Neither --force nor --trust-integration bypasses source policy.

    +{archive} +{checksum} +

    A digest checks archive integrity, not code safety. There is no direct-URL or local +installation route. After reviewing the source and selected catalog's current release, +follow the external adapter installation guide. +Installation prompts before downloading/importing Python; do not pre-authorize +execution with --trust-integration before reviewing the code.

    +

    Historical catalog releases are metadata only, not installable versions. +Test unfamiliar adapters in a disposable project.

    +

    See also

    + +
    +""" + + +def generate(catalog_path: Path, docs_path: Path, *, fetch_stars: bool = False) -> int: + entries = load_integrations(catalog_path) + stars = shared.repository_stars(entries) if fetch_stars else {} + pages = {f"{entry['id']}.md": detail(entry, stars.get(entry.get("repository"))) for entry in entries} + listing = directory(entries, stars) + details_path = docs_path / "community" / "integrations" + 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 / "integration-directory.md").write_text(listing, encoding="utf-8") + return len(entries) + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--catalog", type=Path, default=ROOT / "integrations/catalog.community.json") + parser.add_argument("--docs", type=Path, default=ROOT / "docs") + parser.add_argument("--fetch-stars", action="store_true", help="Fetch GitHub repository stars 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"Integration documentation generation failed: {exc}\n") + print(f"Generated directory and detail pages for {count} community integrations.") + + +if __name__ == "__main__": + main() diff --git a/docs/integrations/contributing.md b/docs/integrations/contributing.md index d6c859c81c..de82ed81e6 100644 --- a/docs/integrations/contributing.md +++ b/docs/integrations/contributing.md @@ -112,6 +112,13 @@ an archive SHA-256 digest is recommended. - Link to your integration repository - Confirmation that `integration.yml` is valid +The community directory and detail pages are generated from the catalog during +the normal documentation build. Do not edit `docs/community/integrations.md` or +add a separate Markdown listing for a catalog entry. Catalog-only changes trigger +deployment after merge; the shared Monday 04:17 UTC rebuild refreshes repository +stars without writing them back to the catalog. See the +[local build instructions](../README.md#building-locally) to preview your entry. + ### Version Updates To update your integration version in the catalog: diff --git a/tests/test_integration_documentation.py b/tests/test_integration_documentation.py new file mode 100644 index 0000000000..40a25ac2bc --- /dev/null +++ b/tests/test_integration_documentation.py @@ -0,0 +1,390 @@ +"""Community integration generation, progressive controls, safety and deployment.""" + +import copy +import io +import json +import os +import shutil +import subprocess +import sys +from html.parser import HTMLParser +from pathlib import Path + +import pytest +import yaml + +from docs import generate_integrations as generator + +ROOT = Path(__file__).resolve().parent.parent + + +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") == "workflow-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 = { + "name": "Sample Adapter", "description": "Connect a coding agent", + "version": "1.2.3", "author": "Contributor", "license": "MIT", + "repository": "https://github.com/example/adapter", + "download_url": "https://example.com/v1.2.3/adapter.zip", + "requires": {"speckit_version": ">=1.1.2.dev0", + "tools": [{"name": "sample-cli", "version": ">=2"}]}, + "tags": ["cli", "review"], "stars": 987654, + } + data = {"schema_version": "1.0", "integrations": {"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_empty_state_has_no_misleading_controls_or_mutation(tmp_path, monkeypatch): + path = ROOT / "integrations/catalog.community.json" + original = path.read_bytes() + assert json.loads(original)["integrations"] == {} + monkeypatch.setattr(generator.shared, "urlopen", lambda *a, **k: pytest.fail("empty catalog fetch")) + assert generator.generate(path, tmp_path, fetch_stars=True) == 0 + listing = (tmp_path / "_generated/integration-directory.md").read_text(encoding="utf-8") + assert "No community integrations yet" in listing + assert "built-in integrations" in listing + assert "catalog submission guide" in listing + assert all(value not in listing for value in ("--force", "root", "integration.yml", + "__init__.py", "IntegrationBase", "No SHA-256 digest", + "
    sample-cli >=2
    "): + assert text in detail + assert "--from" not in detail and "--dev" not in detail + assert path.read_bytes() == original + data["integrations"] = {} + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + assert not (docs / "community/integrations/sample.md").exists() + assert "No community integrations yet" in (docs / "_generated/integration-directory.md").read_text() + path.write_bytes(original) + generator.generate(path, docs) + assert (docs / "community/integrations/sample.md").exists() + + +def test_missing_metadata_and_integrity_guidance(catalog): + data, path, docs = catalog + entry = data["integrations"]["sample"] + entry["sha256"] = "a" * 64 + entry["requires"]["tools"].append({"name": "helper", "required": False}) + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + detail = (docs / "community/integrations/sample.md").read_text(encoding="utf-8") + assert "helper (optional)" in detail + assert "installer checks this digest" in detail + assert "a" * 64 in detail + for field in ("author", "repository", "license", "requires", "tags", "download_url", "sha256"): + del entry[field] + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + detail = (docs / "community/integrations/sample.md").read_text(encoding="utf-8") + assert "
    Author
    Not provided
    " in detail + assert "
    Requires Spec Kit
    Not specified
    " in detail + assert "
    Tool requirements
    None listed
    " in detail + assert "Source repository: Not provided" in detail + assert "No package archive URL is listed" in detail + + +@pytest.mark.parametrize("requirements", [ + {"tools": None}, {"tools": []}, {"tools": [{"name": "agent", "version": ""}]}, +]) +def test_descriptor_optional_tool_requirements(catalog, requirements): + data, path, docs = catalog + data["integrations"]["sample"]["requires"] = requirements + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + detail = (docs / "community/integrations/sample.md").read_text(encoding="utf-8") + expected = "agent" if requirements.get("tools") else "None listed" + assert f"
    Tool requirements
    {expected}
    " in detail + + +@pytest.mark.parametrize("url", [ + "https://example.com/v1/adapter.zip", "http://localhost:8000/adapter.zip", + "http://127.0.0.2/adapter.tgz", "http://[::1]:8000/adapter.tar.gz", +]) +def test_supported_archive_url_schemes(catalog, url): + data, path, docs = catalog + data["integrations"]["sample"]["download_url"] = url + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + assert f'href="{url}"' in (docs / "community/integrations/sample.md").read_text(encoding="utf-8") + + +@pytest.mark.parametrize(("field", "value"), [ + ("id", "../escape"), ("name", None), ("author", ""), ("version", 1), + ("download_url", "javascript:alert(1)"), ("repository", "https://u:p@example.com/repo"), + ("download_url", "http://example.com/adapter.zip"), + ("download_url", "http://localhost.example.com/adapter.zip"), + ("download_url", "http://user:password@localhost/adapter.zip"), + ("repository", "https://example.com/\nreadme"), ("tags", "cli"), ("tags", [None]), + ("requires", []), ("requires", {"speckit_version": None}), + ("requires", {"tools": "git"}), ("requires", {"tools": [None]}), + ("requires", {"tools": [{"name": "git", "required": "yes"}]}), + ("requires", {"tools": [{"name": "git", "version": None}]}), + ("sha256", "{line_break}{line_break}[injected](javascript:alert%281%29) & |' + entry = data["integrations"]["sample"] + entry.update(name=payload, description=payload, author=payload, license=payload, tags=[payload]) + entry["requires"] = {"tools": [{"name": payload}]} + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + parsed = DirectoryParser() + parsed.feed((docs / "_generated/integration-directory.md").read_text(encoding="utf-8")) + assert json.loads(parsed.entries[0]["data-integration-tags"]) == [payload] + for generated in (docs / "_generated/integration-directory.md", docs / "community/integrations/sample.md"): + source = generated.read_text(encoding="utf-8") + assert payload not in source + assert generator.escape(payload) in source + if shutil.which("docfx") is None: + pytest.skip("DocFX is required for rendered Markdown verification") + (docs / "community/integrations.md").write_text( + "# Community Integrations\n\n[!INCLUDE [Directory](../_generated/integration-directory.md)]\n", + encoding="utf-8", + ) + (docs / "docfx.json").write_text(json.dumps({"build": { + "content": [{"files": ["community/**.md"]}], "dest": "_site", "template": ["default", "modern"], + }}), encoding="utf-8") + result = subprocess.run( + [shutil.which("docfx"), "docfx.json", "--logLevel", "Error"], + cwd=docs, capture_output=True, text=True, timeout=120, check=False, + ) + assert result.returncode == 0, result.stdout + result.stderr + for page in ("community/integrations.html", "community/integrations/sample.html"): + rendered = (docs / "_site" / page).read_text(encoding="utf-8") + parsed = DirectoryParser() + parsed.feed(rendered) + assert not any(link.startswith("javascript:") for link in parsed.links) + assert "[injected](javascript:alert%281%29)" in rendered + assert '' not in rendered + + +@pytest.mark.skipif(shutil.which("node") is None, reason="Node.js is required for controls") +def test_search_tag_sort_url_reset_and_empty_page_guard(catalog): + data, path, docs = catalog + data["integrations"]["other"] = { + **data["integrations"]["sample"], "name": "Another Adapter", "tags": ["ide"], + } + path.write_text(json.dumps(data), encoding="utf-8") + generator.generate(path, docs) + parsed = DirectoryParser() + parsed.feed((docs / "_generated/integration-directory.md").read_text(encoding="utf-8")) + result = subprocess.run( + [shutil.which("node"), "-e", r""" +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const vm = require("node:vm"); +const input = JSON.parse(fs.readFileSync(0, "utf8")); +vm.runInNewContext(input.script, {document: {querySelector: () => null}}); +const entries = input.entries.map((attrs) => ({ + hidden: false, dataset: { + integrationSearch: attrs["data-integration-search"], + integrationTags: attrs["data-integration-tags"], + }, +})); +const fields = Object.fromEntries(["q", "tag", "sort"].map((key) => [key, {value: ""}])); +const handlers = {}; +const form = { + hidden: true, elements: {namedItem: (name) => fields[name]}, + addEventListener: (event, handler) => { handlers[event] = handler; }, +}; +const list = { + children: [...entries], + append: (entry) => { + list.children.splice(list.children.indexOf(entry), 1); + list.children.push(entry); + }, +}; +const status = {}; +const empty = {}; +const elements = { + "[data-integration-controls]": form, ".workflow-results": list, + "[data-integration-status]": status, "[data-integration-empty]": empty, +}; +let current = new URL("https://example.com/spec-kit/community/integrations.html?q=CONNECT&tag=cli&sort=za&keep=1"); +vm.runInNewContext(input.script, { + document: {querySelector: () => ({querySelector: (key) => elements[key]})}, + window: { + location: current, history: {replaceState: (_state, _title, url) => { current = url; }}, + }, + URL, URLSearchParams, +}); +const visible = () => list.children.filter((entry) => !entry.hidden); +assert.equal(form.hidden, false); +assert.equal(visible().length, 1); +assert.equal(status.textContent, "1 of 2 integrations"); +fields.q.value = "missing"; +handlers.input(); +assert.equal(visible().length, 0); +assert.equal(empty.hidden, false); +handlers.reset(); +assert.equal(visible().length, 2); +assert.equal(empty.hidden, true); +assert.equal(current.pathname, "/spec-kit/community/integrations.html"); +assert.equal(current.search, "?keep=1"); +fields.sort.value = "za"; +handlers.change(); +assert.equal(list.children[0].dataset.integrationTags, '["cli", "review"]'); +fields.tag.value = "ide"; +handlers.change(); +assert.equal(visible().length, 1); +handlers.reset(); +fields.q.value = "Contributor sample-cli"; +let prevented = false; +handlers.submit({preventDefault: () => { prevented = true; }}); +assert.equal(prevented, true); +assert.equal(visible().length, 2); +"""], + input=json.dumps({"entries": parsed.entries, + "script": (ROOT / "docs/assets/integration-catalog.js").read_text(encoding="utf-8")}), + capture_output=True, text=True, timeout=30, check=False, + ) + assert result.returncode == 0, result.stdout + result.stderr + + +def test_build_submission_and_generated_output_contracts(): + workflow = yaml.safe_load((ROOT / ".github/workflows/docs.yml").read_text(encoding="utf-8")) + assert "integrations/catalog.community.json" in workflow[True]["push"]["paths"] + assert workflow[True]["schedule"] == [{"cron": "17 4 * * 1"}] + steps = workflow["jobs"]["build"]["steps"] + generation = next(i for i, step in enumerate(steps) + if step.get("run") == "python3 docs/generate_integrations.py --fetch-stars") + assert steps[generation]["env"] == {"GH_TOKEN": "${{ github.token }}"} + assert generation < next(i for i, step in enumerate(steps) if "docfx docfx.json" in step.get("run", "")) + config = json.loads((ROOT / "docs/docfx.json").read_text(encoding="utf-8")) + assert "community/integrations/*.md" in config["build"]["content"][0]["files"] + page = (ROOT / "docs/community/integrations.md").read_text(encoding="utf-8") + assert "[!INCLUDE [Community integration directory](../_generated/integration-directory.md)]" in page + assert "submit a catalog PR" in page + assert "no direct-URL or local installation route" in page + guide = (ROOT / "docs/integrations/contributing.md").read_text(encoding="utf-8") + assert "Do not edit `docs/community/integrations.md`" in guide + assert "04:17 UTC" in guide + assert "Open a pull request" in guide From 9a3f2c8655a4e7e727e0391f3bd9d6aec9905139 Mon Sep 17 00:00:00 2001 From: Manfred Riem <15701806+mnriem@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:31:05 -0600 Subject: [PATCH 2/2] test(docs): decouple integration empty state from catalog contents Exercise the empty state using a temporary catalog and derive production smoke-test expectations from current entries. Cover populated fixture input without changing the genuine catalog. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- tests/test_integration_documentation.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/test_integration_documentation.py b/tests/test_integration_documentation.py index 40a25ac2bc..b91a41c76e 100644 --- a/tests/test_integration_documentation.py +++ b/tests/test_integration_documentation.py @@ -52,10 +52,10 @@ def catalog(tmp_path): return data, path, tmp_path / "docs" -def test_real_catalog_empty_state_has_no_misleading_controls_or_mutation(tmp_path, monkeypatch): - path = ROOT / "integrations/catalog.community.json" +def test_empty_state_has_no_misleading_controls_or_mutation(tmp_path, monkeypatch): + path = tmp_path / "catalog.json" + path.write_text(json.dumps({"schema_version": "1.0", "integrations": {}}), encoding="utf-8") original = path.read_bytes() - assert json.loads(original)["integrations"] == {} monkeypatch.setattr(generator.shared, "urlopen", lambda *a, **k: pytest.fail("empty catalog fetch")) assert generator.generate(path, tmp_path, fetch_stars=True) == 0 listing = (tmp_path / "_generated/integration-directory.md").read_text(encoding="utf-8") @@ -67,6 +67,22 @@ def test_real_catalog_empty_state_has_no_misleading_controls_or_mutation(tmp_pat assert path.read_bytes() == original +@pytest.mark.parametrize("source", ["production", "populated-fixture"]) +def test_catalog_smoke_derives_expected_output_from_entries(catalog, source): + _, fixture_path, docs = catalog + path = ROOT / "integrations/catalog.community.json" if source == "production" else fixture_path + original = path.read_bytes() + entries = json.loads(original)["integrations"] + assert generator.generate(path, docs) == len(entries) + parsed = DirectoryParser() + parsed.feed((docs / "_generated/integration-directory.md").read_text(encoding="utf-8")) + assert len(parsed.entries) == len(entries) + assert {page.stem for page in (docs / "community/integrations").glob("*.md")} == set(entries) + for key in entries: + assert f"integrations/{key}.md" in parsed.links + assert path.read_bytes() == original + + def test_populated_static_listing_optional_id_details_and_transition(catalog): data, path, docs = catalog original = path.read_bytes()