" for label, value in metadata.items()
+ )
+ links = " ".join(
+ f'{label}'
+ for field, label in (
+ ("repository", "View source and README"),
+ ("documentation", "Author documentation"),
+ ("changelog", "Changelog"),
+ )
+ if field in entry
+ ) or "No source repository or documentation links listed; inspect the release before installation."
+ checksum = (
+ "
Before installation, compute the downloaded artifact's SHA-256 and "
+ "compare it with the catalog SHA-256 below. If they do not match, "
+ "stop and do not install the artifact.
"
+ f'
Catalog SHA-256: {escape(entry["sha256"])}
'
+ if entry.get("sha256") else
+ "
No SHA-256 digest is listed in this catalog entry. Obtain and verify "
+ "an integrity digest from a source you trust before installation.
Requirements are author-declared expectations, not enforced permissions or
+a sandbox. Missing integration metadata does not imply support for every integration.
+Repository stars reflect the last documentation build, not a safety assessment.
+
Review before installing or running
+
This workflow is independently maintained. Maintainers check catalog metadata only;
+they do not review, audit, endorse, or support workflow code, scripts, or dependencies.
+You must vet the exact release, required integrations, custom steps, shell commands
+and environment values, side effects, credentials, and review gates before installation and use.
+
The community catalog is discovery-only. A listing does not make
+specify workflow add {escape(entry["id"])} installable through that source.
+Inspect active workflow and step catalogs; project configuration may select sources
+you did not choose. Use only separately vetted, install-allowed catalogs or an explicit
+release source after review.
A digest checks artifact integrity; it is not evidence of code review or safety.
+Direct-URL installation selects the source explicitly and does not use catalog digest
+verification. Verify the downloaded bytes before installing a local definition or package;
+see the workflow installation options.
+
Installing a workflow does not run it. Running a workflow executes its steps;
+it is not a dry run. Test unfamiliar workflows in a disposable project and review
+applicable gate, rejection, failure, and resume behavior.
+"""
+
+
+def generate(catalog_path: Path, docs_path: Path, *, fetch_stars: bool = False) -> int:
+ workflows = load_workflows(catalog_path)
+ stars = repository_stars(workflows) if fetch_stars else {}
+ pages = {f"{entry['id']}.md": detail(entry, stars.get(entry.get("repository"))) for entry in workflows}
+ listing = directory(workflows, stars)
+ details_path = docs_path / "community" / "workflows"
+ 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 / "workflow-directory.md").write_text(listing, encoding="utf-8")
+ return len(workflows)
+
+
+def main() -> None:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--catalog", type=Path, default=ROOT / "workflows/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"Workflow documentation generation failed: {exc}\n")
+ print(f"Generated directory and detail pages for {count} community workflows.")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docs/workflows/publishing.md b/docs/workflows/publishing.md
index 050988f2cf..6229f1e57a 100644
--- a/docs/workflows/publishing.md
+++ b/docs/workflows/publishing.md
@@ -115,6 +115,12 @@ the release's real values. Keep `requires` consistent with the definition.
The current release stays at the top level; use `releases` for historical
versions as described in the catalog reference.
+The [community workflow directory](../community/workflows.md) and its detail
+pages are generated from this catalog during documentation builds. Do not
+maintain a separate Markdown listing or edit generated pages. To preview a
+catalog change locally, run `python3 docs/generate_workflows.py` before DocFX;
+add `--fetch-stars` to refresh build-time repository stars.
+
Submit a focused catalog PR with:
- Workflow ID, name, version, repository, and license.
diff --git a/tests/test_workflow_documentation.py b/tests/test_workflow_documentation.py
new file mode 100644
index 0000000000..12c0d29916
--- /dev/null
+++ b/tests/test_workflow_documentation.py
@@ -0,0 +1,449 @@
+"""Catalog-derived workflow documentation, controls, failures, and build wiring."""
+
+import copy
+import importlib.util
+import io
+import json
+import os
+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_workflows.py"
+spec = importlib.util.spec_from_file_location("generate_workflows", 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") == "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 = {
+ "id": "sample",
+ "name": "Sample Workflow",
+ "description": "Review a specification",
+ "author": "Contributor",
+ "version": "1.2.3",
+ "license": "MIT",
+ "repository": "https://github.com/example/workflows",
+ "documentation": "https://github.com/example/workflows/blob/v1.2.3/README.md",
+ "changelog": "https://github.com/example/workflows/blob/v1.2.3/CHANGELOG.md",
+ "url": "https://example.com/v1.2.3/workflow.yml",
+ "requires": {"speckit_version": ">=1.0.0", "integrations": {"any": ["copilot", "claude"]}},
+ "tags": ["review", "planning"],
+ }
+ data = {"schema_version": "1.0", "workflows": {"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_complete_static_directory_and_detail_per_entry(tmp_path):
+ path = ROOT / "workflows/catalog.community.json"
+ original = path.read_bytes()
+ entries = json.loads(original)["workflows"]
+ assert generator.generate(path, tmp_path) == len(entries)
+ parsed = DirectoryParser()
+ parsed.feed((tmp_path / "_generated/workflow-directory.md").read_text(encoding="utf-8"))
+ assert len(parsed.entries) == len(entries)
+ assert set(parsed.links) == {f"workflows/{workflow_id}.md" for workflow_id in entries}
+ assert all("hidden" not in entry for entry in parsed.entries)
+ assert {page.stem for page in (tmp_path / "community/workflows").glob("*.md")} == set(entries)
+ for workflow_id, entry in entries.items():
+ detail = (tmp_path / f"community/workflows/{workflow_id}.md").read_text(encoding="utf-8")
+ assert generator.escape_metadata(entry["name"]) in detail
+ assert generator.escape_metadata(entry["url"]) in detail
+ assert "discovery-only" in detail
+ assert "do not review, audit, endorse, or support" in detail
+ assert "shell commands" in detail and "environment values" in detail
+ assert "not a dry run" in detail
+ assert "--install-allowed" not in detail
+ assert path.read_bytes() == original
+
+
+def test_generation_is_deterministic_and_removes_deleted_pages(catalog):
+ data, path, docs = catalog
+ other = copy.deepcopy(data["workflows"]["sample"])
+ other.update(id="other", name="Another Workflow")
+ data["workflows"]["other"] = other
+ path.write_text(json.dumps(data), encoding="utf-8")
+ generator.generate(path, docs)
+ first = (docs / "_generated/workflow-directory.md").read_bytes()
+ assert first.index(b"Another Workflow") < first.index(b"Sample Workflow")
+ generator.generate(path, docs)
+ assert (docs / "_generated/workflow-directory.md").read_bytes() == first
+ del data["workflows"]["other"]
+ path.write_text(json.dumps(data), encoding="utf-8")
+ generator.generate(path, docs)
+ assert not (docs / "community/workflows/other.md").exists()
+ assert (docs / "community/workflows/sample.md").is_file()
+
+
+def test_casefold_tied_filters_and_names_have_deterministic_tie_breakers(catalog):
+ data, path, docs = catalog
+ data["workflows"]["sample"].update(name="Same", tags=["Review"])
+ data["workflows"]["sample"]["requires"]["integrations"]["any"] = ["Copilot"]
+ other = copy.deepcopy(data["workflows"]["sample"])
+ other.update(id="other", name="same", tags=["review"])
+ other["requires"]["integrations"]["any"] = ["copilot"]
+ data["workflows"]["other"] = other
+ path.write_text(json.dumps(data), encoding="utf-8")
+ listings = []
+ for seed in ("1", "2", "3", "4"):
+ output = docs / seed
+ result = subprocess.run(
+ [sys.executable, str(GENERATOR), "--catalog", str(path), "--docs", str(output)],
+ env={**os.environ, "PYTHONHASHSEED": seed},
+ capture_output=True, text=True, timeout=30, check=False,
+ )
+ assert result.returncode == 0, result.stdout + result.stderr
+ listings.append((output / "_generated/workflow-directory.md").read_bytes())
+ assert len(set(listings)) == 1
+ assert listings[0].index(b"workflows/other.md") < listings[0].index(b"workflows/sample.md")
+
+
+def test_optional_fields_are_not_invented_and_empty_catalog_is_readable(catalog, monkeypatch):
+ data, path, docs = catalog
+ entry = data["workflows"]["sample"]
+ for field in ("repository", "documentation", "changelog", "requires", "tags", "license"):
+ del entry[field]
+ path.write_text(json.dumps(data), encoding="utf-8")
+ monkeypatch.setattr(generator, "urlopen", lambda *args, **kwargs: pytest.fail("No repository to fetch"))
+ generator.generate(path, docs, fetch_stars=True)
+ detail = (docs / "community/workflows/sample.md").read_text(encoding="utf-8")
+ assert "
Declared integrations
Not specified
" in detail
+ assert "
Requires Spec Kit
Not specified
" in detail
+ assert "No source repository or documentation links listed" in detail
+ assert "No SHA-256 digest is listed" in detail
+ assert "Obtain and verify an integrity digest" in detail
+ assert "Unavailable" in detail
+ data["workflows"] = {}
+ path.write_text(json.dumps(data), encoding="utf-8")
+ assert generator.generate(path, docs) == 0
+ assert "0 workflows" in (docs / "_generated/workflow-directory.md").read_text(encoding="utf-8")
+ assert not (docs / "community/workflows/sample.md").exists()
+
+
+@pytest.mark.parametrize("has_digest", [True, False])
+def test_workflow_artifact_vetting_and_digest_guidance(catalog, has_digest):
+ data, path, docs = catalog
+ if has_digest:
+ data["workflows"]["sample"]["sha256"] = "a" * 64
+ path.write_text(json.dumps(data), encoding="utf-8")
+ generator.generate(path, docs)
+ detail = (docs / "community/workflows/sample.md").read_text(encoding="utf-8")
+ assert ("compute the downloaded artifact's SHA-256" in detail) is has_digest
+ assert ("No SHA-256 digest is listed" in detail) is not has_digest
+ if has_digest:
+ assert "compare it with the catalog SHA-256 below" in detail
+ assert "stop and do not install the artifact" in detail
+ assert f"{'a' * 64}" in detail
+ assert "does not use catalog digest\nverification" in detail
+ assert "raw YAML does not include adjacent scripts or resources" in detail
+ assert "