Skip to content

Add support for externally-hosted DocC websites#29

Merged
mattt merged 10 commits intomainfrom
mattt/external
Feb 18, 2026
Merged

Add support for externally-hosted DocC websites#29
mattt merged 10 commits intomainfrom
mattt/external

Conversation

@mattt
Copy link
Copy Markdown
Member

@mattt mattt commented Feb 17, 2026

Resolves #28
Resolves #12

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for externally-hosted Swift-DocC documentation sites, resolving issues #28 and #12. It enables users to proxy non-Apple DocC sites (e.g., third-party Swift package documentation) through sosumi.ai using a new /external/ route pattern.

Changes:

  • Adds external DocC support with URL pattern /external/https://<host>/documentation/<path>
  • Implements comprehensive access controls including robots.txt checking, host allowlist/blocklist, and SSRF protection
  • Adds link rewriting in rendered markdown to properly handle external origins
  • Includes new MCP tool fetchExternalDocumentation for AI clients

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/lib/external/policy.ts New module implementing access control policies, robots.txt parsing, and SSRF protection for external hosts
src/lib/external/fetch.ts Handles fetching external DocC JSON data and building proper JSON URLs from documentation paths
src/lib/external/index.ts Exports external module functionality
src/lib/reference/render.ts Adds externalOrigin option and rewrites documentation links to use /external/ prefix
src/lib/mcp.ts Adds fetchExternalDocumentation tool to MCP server
src/index.ts Implements /external/* HTTP route and error handling for ExternalAccessError
tests/external.test.ts Comprehensive tests for external DocC support including policy enforcement and rendering
tests/integration.test.ts Integration test for external DocC fetching
tests/url.test.ts Tests for external URL to JSON URL conversion
public/index.html Adds bot policy section and external documentation examples
README.md Documents external DocC support and access controls

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/external/policy.ts
Comment thread src/lib/mcp.ts Outdated
Comment thread src/lib/external/policy.ts Outdated
Comment thread src/index.ts Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/external/policy.ts Outdated
Comment thread src/lib/external/policy.ts
Comment thread src/index.ts Outdated
Comment thread src/lib/external/fetch.ts
Comment thread src/index.ts
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/external/policy.ts
Comment thread src/lib/external/policy.ts Outdated
Comment thread src/lib/external/fetch.ts Outdated
Comment on lines +35 to +39
export async function fetchExternalDocCJSON(sourceUrl: URL): Promise<AppleDocJSON> {
const jsonUrl = buildExternalDocCJsonUrl(sourceUrl)
const response = await fetch(jsonUrl.toString(), {
headers: {
"User-Agent": EXTERNAL_DOC_USER_AGENT,
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchExternalDocCJSON is exported but does not enforce validateExternalDocumentationUrl/assertExternalDocumentationAccess itself. This makes it easy for future call sites to fetch arbitrary external URLs without applying the host/robots/X-Robots-Tag policies. Consider either (a) making this function internal (not exported) or (b) moving the policy enforcement into this function so it’s safe-by-default.

Copilot uses AI. Check for mistakes.
Comment thread src/index.ts Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mattt mattt merged commit 4939659 into main Feb 18, 2026
2 checks passed
@mattt mattt deleted the mattt/external branch February 18, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Support non-Apple doc pages that use Swift DocC Support for all DocC generated Document.

2 participants