CASCADE uses a unified integration layer so infrastructure code (router, worker, webhook handlers) looks up integrations through registries instead of branching on provider type. PM providers use the newer PMProviderManifest registry; SCM (GitHub) and alerting (Sentry) still use the legacy IntegrationModule path and mirror into the same cross-category IntegrationRegistry.
src/integrations/types.ts
The base contract for SCM and alerting integrations, and the compatibility surface that PM manifests mirror into:
interface IntegrationModule {
readonly type: string; // 'trello', 'jira', 'linear', 'github', 'sentry'
readonly category: IntegrationCategory; // 'pm' | 'scm' | 'alerting'
withCredentials<T>(projectId: string, fn: () => Promise<T>): Promise<T>;
hasIntegration(projectId: string): Promise<boolean>;
// Optional webhook methods
parseWebhookPayload?(raw: unknown): IntegrationWebhookEvent | null;
isSelfAuthored?(event: unknown, projectId: string): Promise<boolean>;
lookupProject?(identifier: string): Promise<{ project; config } | null>;
extractWorkItemId?(text: string): string | null;
}withCredentials() uses AsyncLocalStorage to set provider-specific credentials for the duration of a callback. This provides per-request credential isolation without global state mutation.
hasIntegration() checks that all required credential roles for the provider are configured for the given project. Role definitions come from src/config/integrationRoles.ts.
src/integrations/registry.ts
class IntegrationRegistry {
register(integration: IntegrationModule): void;
get(type: string): IntegrationModule; // throws if missing
getOrNull(type: string): IntegrationModule | null;
getByCategory(category: IntegrationCategory): IntegrationModule[];
all(): IntegrationModule[];
}
const integrationRegistry: IntegrationRegistry; // singletonsrc/integrations/pm/manifest.ts — the manifest is the single PM-provider contract. Trello, JIRA, and Linear each declare identity, credential roles, webhook route/signature verification, router adapter, trigger handlers, platform ack client, config schema, discovery capabilities, wizard spec, and lifecycle fixture in one provider-owned object.
The PM barrel (src/integrations/pm/index.ts) imports each provider once, then mirrors each manifest's pmIntegration into integrationRegistry. New PM providers add one provider folder plus one import in that barrel; shared router, worker, dashboard, CLI, and config files are guarded against provider-specific edits by conformance tests.
The dashboard has a matching frontend PM-provider boundary under web/src/components/projects/pm-providers/<provider>/. A provider owns its wizard definition, auth metadata, credential persistence metadata, save config serialization, edit-mode hydration, discovery/mutation hooks, webhook UX composition, and provider-specific state slice in that folder. The shared wizard files (pm-wizard.tsx, pm-wizard-hooks.ts, and pm-wizard-common-steps.tsx) only render registered provider definitions and run metadata-driven verification/save helpers, so adding a provider does not require editing them. New providers add one frontend barrel import in web/src/components/projects/pm-providers/index.ts; pm-wizard-state.ts is the remaining explicit shared-dashboard exception while it composes provider state slices into the aggregate WizardState and reducer.
src/pm/integration.ts — extends IntegrationModule with PM-specific methods:
createProvider(project)— create aPMProviderinstance for CRUD operationsresolveLifecycleConfig(project)— extract labels, statuses, list IDs from project configpostAckComment(projectId, workItemId, message)— post acknowledgment commentdeleteAckComment(projectId, workItemId, commentId)— remove ack commentsendReaction(projectId, event)— add emoji reaction to source eventlookupProject(identifier)— find project by board ID or project keyextractWorkItemId(text)— parse work item ID from text (e.g., Trello URL, JIRA key)
src/integrations/scm.ts — extends IntegrationModule with SCM-specific methods for webhook payload parsing and project lookup by repository name.
src/integrations/alerting.ts — extends IntegrationModule with alerting-specific methods.
src/integrations/entrypoint.ts
Single registration entrypoint for all runtime surfaces. Router, worker, CLI bootstrap, dashboard, and tests import it for side effects.
PM barrel → pmProviderRegistry + integrationRegistry
GitHub register.ts → integrationRegistry + trigger handlers
Sentry register.ts → integrationRegistry + trigger handlers
src/config/integrationRoles.ts
Each provider declares its credential roles — the mapping from logical role names to environment variable keys:
| Provider | Category | Required Roles | Optional Roles |
|---|---|---|---|
| Trello | pm | api_key → TRELLO_API_KEY, token → TRELLO_TOKEN |
api_secret |
| JIRA | pm | email → JIRA_EMAIL, api_token → JIRA_API_TOKEN |
webhook_secret |
| Linear | pm | api_key → LINEAR_API_KEY |
webhook_secret → LINEAR_WEBHOOK_SECRET |
| GitHub | scm | implementer_token → GITHUB_TOKEN_IMPLEMENTER, reviewer_token → GITHUB_TOKEN_REVIEWER |
webhook_secret |
| Sentry | alerting | api_token → SENTRY_API_TOKEN |
webhook_secret |
trelloManifestdeclares the PM provider contract and registers withpmProviderRegistryTrelloIntegrationimplements the mirroredPMIntegrationTrelloPMProviderimplementsPMProvider(card CRUD, comments, labels, checklists)trelloClient— Octokit-style client with AsyncLocalStorage credential scoping- Media extraction from markdown in card descriptions/comments
- Status = list ID (cards grouped by lists)
jiraManifestdeclares the PM provider contract and registers withpmProviderRegistryJiraIntegrationimplements the mirroredPMIntegrationJiraPMProviderimplementsPMProvider(issue CRUD, transitions, comments)jiraClient— wrapsjira.jsVersion3Client with AsyncLocalStorage scoping- ADF (Atlassian Document Format) ↔ markdown conversion (
src/pm/jira/adf.ts) - Status transitions via JIRA transition ID lookup
- Issue key extraction via regex:
[A-Z][A-Z0-9]+-\d+ - Auth mode — the optional
authTypeconfig field ('basic' | 'scoped') is a non-secret connection setting (mirrorsbaseUrl, not a credential role) that selects the REST v3 host. Both modes use HTTP Basic (email:api_token); absent ⇒'basic'. - Host resolution — every REST v3 call site routes through the shared
resolveJiraApiBaseUrl(creds)resolver (src/jira/api-host.ts):basickeeps the tenant site URL;scopedroutes through the Atlassian gatewayhttps://api.atlassian.com/ex/jira/{cloudId}(cloudId resolved from/_edge/tenant_info). Scoped tokens have known limits — see08-config-credentials.md.
linearManifestdeclares the PM provider contract and registers withpmProviderRegistryLinearIntegrationimplements the mirroredPMIntegrationLinearPMProviderimplementsPMProvider(issue CRUD, comments, labels, state transitions)linearClient— GraphQL/REST client with AsyncLocalStorage credential scoping- Status transitions via Linear state ID lookup
- Issue identifier extraction via regex:
[A-Z][A-Z0-9]*-\d+(e.g.TEAM-123) - Work item URL format:
https://linear.app/<org>/issue/<identifier>
GitHubSCMIntegrationimplementsSCMIntegrationgithubClient— Octokit wrapper withwithGitHubToken()AsyncLocalStorage scoping- Dual-persona model (
src/github/personas.ts):- Implementer — writes code, creates PRs (used by most agents)
- Reviewer — reviews PRs, can approve or request changes (used by
reviewagent) isCascadeBot(login)— checks if a GitHub login belongs to either personaresolvePersonaIdentities()— resolves both tokens to usernames (cached 60s per project)
- Loop prevention:
respond-to-reviewonly fires on reviewer'schanges_requested; comment triggers skip @mentions from any known persona
SentryAlertingIntegrationimplementsAlertingIntegrationsentryClient— REST API client with Bearer token auth- Supports Sentry webhook resources
event_alert,metric_alert, andissuelifecycle - Config:
organizationSlugandprojectSlugstored inproject_integrations.configJSONB
src/pm/
Lower-level data operations consumed by gadgets and lifecycle hooks:
interface PMProvider {
getWorkItem(id: string): Promise<WorkItem>;
listWorkItems(filter?): Promise<WorkItem[]>;
createWorkItem(config): Promise<WorkItem>;
updateWorkItem(id, updates): Promise<WorkItem>;
moveToStatus(id, status): Promise<void>;
addComment(id, text): Promise<WorkItemComment>;
getChecklists(id): Promise<Checklist[]>;
addLabel(id, label): Promise<void>;
removeLabel(id, label): Promise<void>;
linkPR(id, prUrl): Promise<void>;
// ... more operations
}src/pm/registry.ts — backward-compatible PM-specific registry. Maps PM type to integration instance. Used by trigger handlers and gadgets that need PM operations.
src/pm/lifecycle.ts — orchestrates card/issue state during agent execution:
prepareForAgent()— add processing label, move to "In Progress"handleSuccess()— add processed label, move to "In Review", link PRhandleFailure()— add error label, post error commentcleanupProcessing()— remove processing label
For the complete step-by-step guide to adding a new integration, see src/integrations/README.md.