Shoalrun documentation frameworkMenu
For agents
Start with https://www.shoalrun.com/llms.txt for the documentation index, then read the Markdown pages it links. Skip to article. Documentation index. Read this page as Markdown.
How to

Example: serve two audience builds

Follow a fictional billing example with two selected builds and an in-app export.

Updated Since 1.3.0
Read as Markdown

This fictional billing example uses customer and internal as configured audience choices. They aren't built-in Shoalrun roles, and the labels don't grant permissions. Your project can declare other choices or select a different facet.

The example keeps shared instructions and additional sections in one source page, produces two website builds, and selects an in-app export separately. It illustrates one possible configuration rather than a required deployment model.

Before you begin

Start in a project containing Shoalrun. Copy the packaged example into a working directory:

cp -R node_modules/@shoalrun/cli/examples/dual-audience-serving ./audience-demo
cd audience-demo

The example contains synthetic billing instructions. Don't replace them with real privileged information until your deployment's authentication and publishing checks are ready.

  1. Review the audience boundaries

    In this example, base.yaml declares the customer and internal audience choices. The shared page has audiences: [customer, internal]. Shared paragraphs remain outside guards, while internal additions use a visible callout:

    Customer-facing instructions.
    
    <ForFacet audience="internal">
    
    <Callout type="warning">
    
    **Company Internal Content**
    
    Privileged operational instructions.
    
    </Callout>
    
    </ForFacet>
    

    This is an authored composition of existing components. ForFacet doesn't add a label, glow, or box automatically. Unguarded text on a selected page is included. A custom project audit can enforce your team's marking conventions; the serving adapter doesn't classify paragraphs.

  2. Build both websites and MCP bundles

    The customer config selects audience: [customer]; the internal config selects audience: [internal]. Run:

    npx --no-install shoalrun build customer.config.yaml dist/customer-site
    npx --no-install shoalrun build internal.config.yaml dist/internal-site
    npx --no-install shoalrun mcp export dist/customer-site --out dist/customer-mcp
    npx --no-install shoalrun mcp export dist/internal-site --out dist/internal-mcp
    

    Both builds use production/current/en. Their audience selections and bundle revisions differ; audience isn't an extra publication coordinate. Don't combine them in a server registry keyed only by publication.

  3. Export customer in-app content

    The example's app-help export target explicitly selects customer content. Website site.contentFilter doesn't select application exports:

    exports:
      app-help:
        formats: [html, markdown]
        contentFilter: { audience: [customer] }
        publicBase: /help/releases/demo/
        resources:
          - { kind: page, documentId: guide.billing }
          - { kind: section, documentId: guide.billing, sectionId: refunds }
    

    Build that target separately:

    npx --no-install shoalrun export customer.config.yaml --target app-help --out dist/app-help
    

    The page declares the refund section suitable for standalone use. Host the complete export at its publicBase, including assets, or use the Content REST adapter. Your app can fetch guide.billing or its refunds section using the content client.

  4. Serve and compare the two editions

    Run each command in a separate terminal:

    npx --no-install shoalrun serve dist/customer-site --port 8771
    
    npx --no-install shoalrun serve dist/internal-site --port 8772
    

    Open http://127.0.0.1:8771/ and http://127.0.0.1:8772/. Only the internal page shows the Company Internal Content boxes. Their MCP endpoints are /mcp on the respective ports. For a host without Node, pass each discovery bundle to a separate Python adapter, and optionally supply dist/app-help to the customer instance.

Check the result

Confirm INTERNAL_RETRY_QUEUE and INTERNAL_BILLING_REPLAY appear in the internal build and are absent from every customer website, discovery, and application-export file. Test MCP search for those markers and try reading known internal-only IDs. Check both inclusion and exclusion so a missing fixture can't produce a false pass.

If you adapt this example for restricted content, protect the relevant website, MCP, Markdown, content routes, and assets with your own authentication. The current mcp.access: public configuration supplies no authentication itself. Keep audience directories and handler instances separate, and include the bundle revision in cache identity. The Node Content REST adapter's public immutable cache policy must be overridden for privileged responses.

HTML, Markdown, and agents

The internal HTML page displays its authored callouts alongside shared instructions. Its Markdown and MCP reads retain the internal labels and text. The customer build omits each unmatched block before rendering, indexing, and dependency expansion. The customer in-app export applies its own filter and contains passive selected HTML or Markdown.

Next steps

Reference while working