Plan — BJ-10: ClaudeInvocationService platform-switched env#
Summary#
Teach ClaudeInvocationService to select an auth provider and inject the correct env block based on task.platform (github | bitbucket | jira), always setting PLATFORM and fetching the token per-invocation.
Files#
| File | Action | Why |
|---|---|---|
src/invoke/claude-invocation.service.ts | modify | Replace single-provider DI with a registry; branch env block on platform |
src/invoke/invoke.module.ts | modify | Register PLATFORM_AUTH_PROVIDERS array via factory (GitHub required, Atlassian optional) |
src/phase-router/phase-router.service.ts | modify | Set env.PLATFORM = task.platform ?? 'github' in buildEnv() |
src/invoke/claude-invocation.service.spec.ts | modify | Cover github (regression), bitbucket, jira, unknown-platform, PLATFORM passthrough |
Steps#
- Add
PLATFORM_AUTH_PROVIDERStoken (array) alongsidePLATFORM_AUTH_PROVIDERinsrc/platform/platform-auth-provider.interface.ts. - In
InvokeModule, wire a factory that returns[github, bitbucket?, jira?].filter(Boolean); inject Atlassian tokens asoptional: trueso unmerged deps do not break boot. - Change
ClaudeInvocationServiceconstructor to injectPlatformAuthProvider[]via the new token; drop the singlePLATFORM_AUTH_PROVIDERinjection. - In
invoke(), resolveplatform = env['PLATFORM'] ?? 'github'; find the matching provider — throwErrorwith the platform name if none match. - Call
provider.getToken()andprovider.getBotUsername()at invocation time; write into the platform-specific env keys listed below. Preserve the existing behaviour that caller-supplied values are not overwritten. - Platform env blocks (only set when not already in
env):github—GITHUB_TOKEN,AGENT_USERNAME, plus existing passthrough (GITHUB_OWNER,GITHUB_REPO)bitbucket—BITBUCKET_TOKEN,BITBUCKET_BOT_USERNAME,BITBUCKET_WORKSPACE,BITBUCKET_REPOjira—JIRA_TOKEN,JIRA_BOT_USERNAME,JIRA_SITE_URL,JIRA_CLOUD_ID,JIRA_PROJECT_KEY
- Always write
env['PLATFORM'] = platforminto the outgoing env. - In
phase-router.service.tsbuildEnv(), addenv['PLATFORM'] = task.platform ?? 'github'so platform flows end-to-end (safe before BJ-0 lands — falls back to'github'). - Extend the spec: GitHub path unchanged (regression), bitbucket env injected, jira env injected, unknown platform throws,
PLATFORMalways present,getToken()called once perinvoke().
Verification#
npm run test— new spec cases pass; existing payload shape for GitHub invocations unchanged.npm run lint— zero warnings.npm run build— compiles without type errors.
Risks#
- Hard dep on BJ-0 (#540 —
task.platformcolumn), BJ-2 (#542 — Bitbucket provider), BJ-3 (#543 — Jira provider). All stillOPENonrc/atlassian-integration; implementer must rebase on those once merged. Optional DI tokens keep the module bootable in the interim.
Assumptions#
- Unknown
task.platformfails fast with a descriptiveErrorat invocation time. - Atlassian provider tokens are exported from their respective modules (
BITBUCKET_AUTH_PROVIDER,JIRA_AUTH_PROVIDER) — matches the factory pattern already used insrc/github/github.module.ts:14. - Tenant-specific values (
BITBUCKET_WORKSPACE,JIRA_CLOUD_ID, etc.) are sourced fromConfigServicelike the existing GitHub passthrough; BJ-11 handles per-tenant routing separately.