feat(core): per-provider scope catalog (supportedScopes)#136
Conversation
Mirrors the trigger catalog pipeline for connection **scope** keys — the
user-facing filter params a persona sets under integrations.<provider>.scope
(e.g. github owner/repo), distinct from infra config and trigger events.
- Adapters declare keys via supportedScopes() (with a mapping.yaml `scopes:`
fallback), parallel to supportedEvents().
- New scopes/catalog-generator.ts scans adapters into KNOWN_SCOPE_CATALOG +
KnownScopeKey<P>, emitted to scopes/catalog.generated.{ts,json} and an
adapters-without-known-scopes report.
- Exported at @relayfile/adapter-core/scopes; `adapter-core scopes generate|check`
CLI; in-sync test.
- Seeds github -> [owner, repo]; other providers declare their scope contract
later (generator records "no known scopes" gracefully, like triggers).
Consumed by @agentworkforce/persona-kit to type integrations.<provider>.scope
per provider. Did not touch the triggers catalog (its committed drift is
pre-existing and unrelated).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 25 minutes and 44 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
📝 WalkthroughWalkthroughThis pull request introduces a scope catalog system that automatically discovers OAuth scope definitions declared by adapters. The system scans adapter packages for either explicit ChangesScope Catalog System
Sequence DiagramsequenceDiagram
participant User
participant CLI
participant Generator
participant Adapters
participant YAML as mapping.yaml
participant FileSystem
User->>CLI: scopes generate
CLI->>Generator: writeScopeCatalog()
Generator->>Generator: listAdapterPackages()
loop For each adapter
Generator->>Adapters: dynamically import
Adapters-->>Generator: export list
Generator->>Adapters: instantiate with stubs
Adapters-->>Generator: call supportedScopes()
Generator->>YAML: read mapping.yaml
YAML-->>Generator: scope keys
end
Generator->>Generator: sortCatalog()
Generator->>Generator: renderScopeCatalogModule()
Generator->>FileSystem: write catalog.generated.json
Generator->>FileSystem: write catalog.generated.ts
Generator->>FileSystem: write adapters-without-known-scopes.generated.json
Generator-->>CLI: ScopeCatalogGeneration
CLI-->>User: catalog generation summary
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/core/src/scopes/catalog-generator.ts`:
- Around line 69-94: The code is merging mappingScopes into entries even when
supportedScopes provides keys; change behavior so mappingScopes is treated as a
fallback: if readSupportedScopes(adapterPackage).keys.length > 0, do NOT push
mappingScopes into entries/sources (or alternatively throw/fail-fast if you want
to detect divergence) — update the logic around mappingScopes, supportedScopes,
entries, sources and hasKnownScopes so mappingScopes is only used when
supportedScopes.keys is empty (use adapterPackage.provider as before), and
consider emitting an error/log if both exist but differ to surface stale YAML
instead of merging into KNOWN_SCOPE_CATALOG.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0e044afb-2d4d-42eb-97a4-7e6133272f15
📒 Files selected for processing (11)
packages/core/package.jsonpackages/core/src/cli.tspackages/core/src/index.tspackages/core/src/scopes/adapters-without-known-scopes.generated.jsonpackages/core/src/scopes/catalog-generator.tspackages/core/src/scopes/catalog.generated.jsonpackages/core/src/scopes/catalog.generated.tspackages/core/tests/scopes/catalog-generator.test.tspackages/core/tsconfig.jsonpackages/github/src/index.tspackages/github/src/types.ts
There was a problem hiding this comment.
1 issue found across 11 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/scopes/catalog-generator.ts">
<violation number="1" location="packages/core/src/scopes/catalog-generator.ts:84">
P2: Treat `mapping.scopes` as a fallback only when `supportedScopes()` has no keys. Merging both sources can keep stale YAML scope keys in `KNOWN_SCOPE_CATALOG` after an adapter removes or renames a supported scope.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| hasKnownScopes = true; | ||
| } | ||
|
|
||
| if (mappingScopes.length > 0) { |
There was a problem hiding this comment.
P2: Treat mapping.scopes as a fallback only when supportedScopes() has no keys. Merging both sources can keep stale YAML scope keys in KNOWN_SCOPE_CATALOG after an adapter removes or renames a supported scope.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/src/scopes/catalog-generator.ts, line 84:
<comment>Treat `mapping.scopes` as a fallback only when `supportedScopes()` has no keys. Merging both sources can keep stale YAML scope keys in `KNOWN_SCOPE_CATALOG` after an adapter removes or renames a supported scope.</comment>
<file context>
@@ -0,0 +1,435 @@
+ hasKnownScopes = true;
+ }
+
+ if (mappingScopes.length > 0) {
+ const provider = supportedScopes.keys.length > 0 ? supportedScopes.provider : adapterPackage.provider;
+ entries.push({ provider, keys: mappingScopes });
</file context>
|
Reviewed and fixed PR #136. Changes made:
Verification:
|
|
✅ pr-reviewer applied fixes — committed and pushed Reviewed and fixed PR #136. Changes made:
Verification:
|
There was a problem hiding this comment.
✅ pr-reviewer applied fixes — committed and pushed e1c2eca to this PR. The notes below describe what changed.
Reviewed and fixed PR #136.
Changes made:
- Made scope catalog discovery stable for common adapter builds by checking
dist/index.jsand avoiding raw TS execution failures in the compiled CLI: catalog-generator.ts. - Added a source literal fallback for simple
supportedScopes()declarations so GitHub scopes remain discoverable without package dists: catalog-generator.ts. - Aligned the existing trigger catalog generator with the repo’s normal
dist/index.jsbuild output: catalog-generator.ts. - Regenerated the trigger catalog so Granola’s mapping-declared
recording.createdtrigger is no longer incorrectly listed as missing: catalog.generated.json.
Verification:
npm run build -w packages/corenpm test -w packages/corenode --import tsx packages/core/src/cli.ts scopes check --repo-root /home/daytona/workspacenode --import tsx packages/core/src/cli.ts triggers check --repo-root /home/daytona/workspacenpx turbo build typecheck test --concurrency=2passed: 125/125 tasks successful.
|
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed. pr-reviewer could not complete review for #136 in AgentWorkforce/relayfile-adapters. |
There was a problem hiding this comment.
ℹ️ pr-reviewer: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.
pr-reviewer could not complete review for #136 in AgentWorkforce/relayfile-adapters.
The review harness exited with code 1.
No review was posted; this needs operator attention.
There was a problem hiding this comment.
1 issue found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/scopes/catalog-generator.ts">
<violation number="1" location="packages/core/src/scopes/catalog-generator.ts:254">
P2: Import error gets swallowed. Catalog can silently lose provider scopes and report wrong reason. Preserve and propagate import failure details.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| let moduleExports: Record<string, unknown>; | ||
| try { | ||
| moduleExports = (await import(pathToFileURL(entryPoint).href)) as Record<string, unknown>; | ||
| } catch { |
There was a problem hiding this comment.
P2: Import error gets swallowed. Catalog can silently lose provider scopes and report wrong reason. Preserve and propagate import failure details.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/core/src/scopes/catalog-generator.ts, line 254:
<comment>Import error gets swallowed. Catalog can silently lose provider scopes and report wrong reason. Preserve and propagate import failure details.</comment>
<file context>
@@ -215,27 +215,44 @@ async function listAdapterPackages(repoRoot: string): Promise<AdapterPackage[]>
- provider: adapterPackage.provider,
- error: `Could not import built adapter entrypoint: ${errorMessage(error)}`,
- };
+ } catch {
+ return { keys: [], provider: adapterPackage.provider };
}
</file context>
…ract Disambiguates from OAuth "scopes" (docs/integration-scopes.yaml / required_scopes): the connection-filter catalog is now scope-**keys** throughout. - supportedScopes() -> supportedScopeKeys(); KNOWN_SCOPE_CATALOG -> KNOWN_SCOPE_KEY_CATALOG; KnownScopeKey -> ScopeKey; KnownScopeProviderName -> ScopeKeyProvider; dir scopes/ -> scope-keys/; export /scopes -> /scope-keys; CLI `scopes` -> `scope-keys`; mapping fallback block `scopes:` -> `scopeKeys:`. - AGENTS.md: new "Declared catalogs: triggers and scope keys" section — the supportedEvents/supportedScopeKeys contract, the regen commands, the CI in-sync gate, and the cross-repo bump caveat. README points to it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 14 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/core/src/scopes/catalog-generator.ts">
<violation number="1" location="packages/core/src/scopes/catalog-generator.ts:84">
P2: Treat `mapping.scopes` as a fallback only when `supportedScopes()` has no keys. Merging both sources can keep stale YAML scope keys in `KNOWN_SCOPE_CATALOG` after an adapter removes or renames a supported scope.</violation>
<violation number="2" location="packages/core/src/scopes/catalog-generator.ts:254">
P2: Import error gets swallowed. Catalog can silently lose provider scopes and report wrong reason. Preserve and propagate import failure details.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
…pagation, CLI summary) Resolves CodeRabbit + cubic findings on #136: - mapping `scopeKeys:` is now a FALLBACK only (else-if), never merged with supportedScopeKeys() — a stale YAML key can no longer outlive an adapter that renamed/removed a scope. (scope keys have one source of truth, unlike triggers where mapping webhooks are a legitimate second delivery contract.) - propagate the adapter import failure into the "no scope keys" reason instead of swallowing it and reporting the generic "no implementation" message; re-add the errorMessage() helper the refactor dropped. - restore the dropped subcommand in the CLI summary (`scope-keys ${command}`), so `generate` and `check` outputs are distinct again. Catalog unchanged (github -> owner/repo); scope-keys check passes in-sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressed the review findings in
Catalog is unchanged ( Note: CodeRabbit and gemini both bailed on the full review (rate-limit / daily-quota), so their green checks don't reflect a completed pass — the actionable items above came from CodeRabbit's one inline comment + cubic. |
What
Adds a per-provider scope catalog to
@relayfile/adapter-core, mirroring the existing trigger catalog. Scope keys are the user-facing connection filters a persona sets underintegrations.<provider>.scope(e.g.github→owner/repo) — distinct from infra config (connectionId, tokens) and from trigger event names.Why
@agentworkforce/persona-kittypes persona triggers per provider (TriggerNameFor<P>) by importingKNOWN_TRIGGER_CATALOGfrom@relayfile/adapter-core/triggers. There was no equivalent forscope, sointegrations.<provider>.scopewas an untypedRecord<string, string>. This adds the source-of-truth catalog so persona authoring can autocomplete/lint scope keys per provider (consumed in a follow-up persona-kit PR).Scope keys aren't derivable from adapter config (it mixes infra + filters with no marker), so each adapter explicitly declares them — exactly what
supportedScopes()is for.Changes
supportedScopes(): string[]on adapters (parallel tosupportedEvents()), with amapping.yamlscopes:fallback. Seeds github →[owner, repo].scopes/catalog-generator.ts— faithful mirror of the triggers generator; reusesfindRepoRoot. Emitsscopes/catalog.generated.{ts,json}(KNOWN_SCOPE_CATALOG,KnownScopeProviderName,KnownScopeKey<P>) + anadapters-without-known-scopesreport.@relayfile/adapter-core/scopessubpath export +indexre-export.adapter-core scopes generate|checkCLI (thecheckform is a CI gate).github → owner/repoassertion.Other providers report "no known scopes" gracefully (just like
adapters-without-known-triggers) until their owners declare a scope contract.Notes
publish.ymlrelease flow).main(pre-existing drift, unrelated to this PR).Test
adapter-core scopes generateis deterministic across partial/full builds; the new test (KNOWN_SCOPE_CATALOG.github === ['owner','repo']+ full in-sync regeneration) passes afterturbo build.🤖 Generated with Claude Code