Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions docs/AGENT_ASSEMBLY_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

## Status

**Stage:** Phase 0 complete (schema + gap inventory + recipe backlog). No
compiled `catalog.json`, hosted skill, MCP surface, or recipe fixture package
exists yet. This document is the working plan for closing the gap between what
AI coding agents tend to do (regenerate common backend functions as bespoke
code) and what the Pegma stack already packages (typed, tested, pin-able
components).
**Stage:** Phase 1 complete (compiled `catalog.json` at site build). No hosted
skill, MCP surface, or recipe fixture package exists yet. This document is the
working plan for closing the gap between what AI coding agents tend to do
(regenerate common backend functions as bespoke code) and what the Pegma stack
already packages (typed, tested, pin-able components).

**Phase 0 artifacts:**
**Phase 0–1 artifacts:**

| Artifact | Path |
| --- | --- |
| TypeScript schema | `src/data/catalog-schema.ts` |
| Schema documentation | `docs/catalog/SCHEMA.md` |
| Registry gap inventory | `docs/catalog/GAP_INVENTORY.md` |
| Prioritized recipe backlog | `docs/catalog/RECIPE_BACKLOG.md` |
| Example catalog (illustrative) | `docs/catalog/example-catalog.json` |
| Example catalog (fictional shape sample) | `docs/catalog/example-catalog.json` |
| Catalog compiler | `src/data/compile-catalog.ts` |
| Published catalog | `https://pegma.dev/catalog.json` (build emit) |

**Goal:** An agent given a short product description chooses the right
`@pegma/*` packages, respects their refusals, and wires them at an explicit
Expand Down Expand Up @@ -242,7 +243,7 @@ architecture disclosure in any recipe intent.
backlog prioritizes P1 `cf-passkey-accounts` and P2 `storage-audit-mail-outbox`
(synthetic intents only); deferred recipes gated on unpublished packages.

### Phase 1 — Compiled catalog artifact
### Phase 1 — Compiled catalog artifact ✓ complete

Emit `catalog.json` (and optionally generated markdown) at site build or
from a small compile step fed by the component registry, plan aggregation,
Expand All @@ -255,6 +256,12 @@ entire catalog into the index file.
**Exit:** an agent can HTTP-fetch a complete, dated composition catalog;
unpublished packages are explicitly flagged.

**Done:** `src/pages/catalog.json.ts` prerenders `/catalog.json` via
`compileCompositionCatalog` (registry + plan stage + npm latest pins +
enrichment + recipe backlog). `public/llms.txt` links the catalog without
inlining it. Unpublished packages get `published: false` / `publishUsability:
unpublished|partial`.

### Phase 2 — Synthetic recipe fixtures

Create public, CI-tested fixtures for the highest-value published
Expand Down
10 changes: 10 additions & 0 deletions public/llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ reference environment.
Each repository's docs/PROJECT_PLAN.md is the source of truth for its
status, design decisions, and non-goals.

## Composition catalog (agents)

- [catalog.json](https://pegma.dev/catalog.json): machine-readable composition
catalog — components, exact npm pins when known, owns/refuses, dependencies,
adapters, and synthetic recipe intents. Compiled at site build. Unpublished
packages are flagged (`published: false`, `publishUsability: unpublished`).
Do not invent package versions; fetch this document.
- Schema and recipe backlog (source docs):
https://github.com/pegma-dev/pegma.dev/tree/main/docs/catalog

## Site

- [The stack](https://pegma.dev/stack): every component — owns, refuses,
Expand Down
235 changes: 235 additions & 0 deletions src/data/catalog-enrichment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
/**
* Hand enrichment for composition-catalog fields the registry does not yet
* carry (deps, adapters, hostMustProvide, capability tags).
*
* Status and package versions are compiled (plan stage + npm). These edges are
* curated agent-facing facts; keep them short and refuse-aligned.
*/

import type {
CapabilityTag,
CatalogAdapter,
CatalogDependency,
} from './catalog-schema';

export interface ComponentEnrichment {
readonly dependencies: readonly CatalogDependency[];
readonly adapters: readonly CatalogAdapter[];
readonly hostMustProvide: readonly string[];
readonly capabilityTags: readonly CapabilityTag[];
}

/** Keyed by component id (= registry `repo`). */
export const COMPONENT_ENRICHMENT: Readonly<Record<string, ComponentEnrichment>> = {
spine: {
dependencies: [],
adapters: [],
hostMustProvide: [
'Composition-root wiring for Clock, Logger, and any in-process bus subscribers',
],
capabilityTags: ['logging', 'events_in_process'],
},
'storage-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires', note: 'Shared contracts and Logger' },
],
adapters: [
{
id: 'memory',
packageName: '@pegma/storage-core',
host: 'memory',
when: 'Tests and local sketches; not a production durability claim',
},
{
id: 'azure-tables',
packageName: '@pegma/storage-azure-tables',
host: 'azure',
when: 'Azure-hosted apps using the Tables adapter',
},
{
id: 'cloudflare-d1',
packageName: '@pegma/storage-cloudflare-d1',
host: 'cloudflare',
when: 'Cloudflare Workers/Pages with D1',
},
],
hostMustProvide: [
'Chosen adapter binding (D1 database, Azure connection, or memory for tests)',
'Collection declarations and codecs',
],
capabilityTags: ['storage', 'cloudflare', 'azure'],
},
'authorization-core': {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'optional',
note: 'When using storage-backed authorization adapters',
},
],
adapters: [],
hostMustProvide: [
'Trusted identity/billing facts at the composition root',
'Policy versioning and permission checks at the HTTP boundary',
],
capabilityTags: ['authorization'],
},
audit: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'requires',
note: 'Audit rows commit inside the caller’s storage transaction',
},
],
adapters: [],
hostMustProvide: [
'Caller-owned storage transaction that includes the audit TransactionAction',
],
capabilityTags: ['audit', 'storage'],
},
'support-desk': {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{ componentId: 'storage-core', kind: 'requires' },
{ componentId: 'mail', kind: 'requires' },
{ componentId: 'authorization-core', kind: 'requires' },
],
adapters: [],
hostMustProvide: [
'Host runtime and data ownership (not a hosted SaaS)',
'Mail provider and permission model',
],
capabilityTags: ['support_queue', 'mail_transactional'],
},
webhooks: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{ componentId: 'storage-core', kind: 'requires' },
],
adapters: [],
hostMustProvide: [
'HTTP endpoint and provider signature verification',
'Storage binding for the receipt ledger',
],
capabilityTags: ['webhooks_inbound'],
},
sessions: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{ componentId: 'storage-core', kind: 'requires' },
],
adapters: [],
hostMustProvide: [
'Authentication (login) at the host',
'Cookie/session HTTP boundary and CSRF strategy',
],
capabilityTags: ['sessions'],
},
mail: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'requires',
note: 'Outbox jobs live in the caller’s store',
},
],
adapters: [],
hostMustProvide: [
'Outbox collection in host storage',
'Provider adapter and delivery worker schedule',
'DNS for SPF/DKIM/DMARC',
],
capabilityTags: ['mail_transactional'],
},
identity: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{ componentId: 'storage-core', kind: 'requires' },
{ componentId: 'sessions', kind: 'requires' },
{ componentId: 'mail', kind: 'composes_with', note: 'Email codes' },
{
componentId: 'rate-limit',
kind: 'composes_with',
note: 'Durable limits on expensive auth paths',
},
{
componentId: 'authorization-core',
kind: 'composes_with',
note: 'Identity claims adapter',
},
],
adapters: [],
hostMustProvide: [
'HTTP routes and cookie boundary',
'WebAuthn relying-party configuration',
'Email provider and secrets',
'Any account UI',
],
capabilityTags: [
'accounts',
'passkeys',
'email_codes',
'sessions',
'authorization',
'mail_transactional',
],
},
'rate-limit': {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'optional',
note: 'Required for the durable fixed-window tier',
},
],
adapters: [],
hostMustProvide: [
'Explicit tier choice (memory vs durable) per path',
'Storage binding when using the durable tier',
],
capabilityTags: ['rate_limit_durable', 'rate_limit_memory'],
},
'logger-adapters': {
dependencies: [
{ componentId: 'spine', kind: 'requires', note: 'Implements Spine Logger' },
],
adapters: [],
hostMustProvide: [
'Composition-root Logger wiring (e.g. tee + sink factories)',
'Vendor credentials/config for chosen sinks',
],
capabilityTags: ['logging'],
},
health: {
dependencies: [
{ componentId: 'spine', kind: 'requires' },
{
componentId: 'storage-core',
kind: 'optional',
note: 'When registering a store ping check',
},
],
adapters: [],
hostMustProvide: [
'Explicit check registration at the composition root',
'HTTP route that returns health responses',
],
capabilityTags: ['health'],
},
};

export function enrichmentFor(componentId: string): ComponentEnrichment {
return (
COMPONENT_ENRICHMENT[componentId] ?? {
dependencies: [],
adapters: [],
hostMustProvide: [],
capabilityTags: [],
}
);
}
Loading