AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-550
  5. plan
  6. plan.md
plan.md(3.4 KB)· Apr 23, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks
  • Assumptions

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#

FileActionWhy
src/invoke/claude-invocation.service.tsmodifyReplace single-provider DI with a registry; branch env block on platform
src/invoke/invoke.module.tsmodifyRegister PLATFORM_AUTH_PROVIDERS array via factory (GitHub required, Atlassian optional)
src/phase-router/phase-router.service.tsmodifySet env.PLATFORM = task.platform ?? 'github' in buildEnv()
src/invoke/claude-invocation.service.spec.tsmodifyCover github (regression), bitbucket, jira, unknown-platform, PLATFORM passthrough

Steps#

  1. Add PLATFORM_AUTH_PROVIDERS token (array) alongside PLATFORM_AUTH_PROVIDER in src/platform/platform-auth-provider.interface.ts.
  2. In InvokeModule, wire a factory that returns [github, bitbucket?, jira?].filter(Boolean); inject Atlassian tokens as optional: true so unmerged deps do not break boot.
  3. Change ClaudeInvocationService constructor to inject PlatformAuthProvider[] via the new token; drop the single PLATFORM_AUTH_PROVIDER injection.
  4. In invoke(), resolve platform = env['PLATFORM'] ?? 'github'; find the matching provider — throw Error with the platform name if none match.
  5. Call provider.getToken() and provider.getBotUsername() at invocation time; write into the platform-specific env keys listed below. Preserve the existing behaviour that caller-supplied values are not overwritten.
  6. 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_REPO
    • jira — JIRA_TOKEN, JIRA_BOT_USERNAME, JIRA_SITE_URL, JIRA_CLOUD_ID, JIRA_PROJECT_KEY
  7. Always write env['PLATFORM'] = platform into the outgoing env.
  8. In phase-router.service.ts buildEnv(), add env['PLATFORM'] = task.platform ?? 'github' so platform flows end-to-end (safe before BJ-0 lands — falls back to 'github').
  9. Extend the spec: GitHub path unchanged (regression), bitbucket env injected, jira env injected, unknown platform throws, PLATFORM always present, getToken() called once per invoke().

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.platform column), BJ-2 (#542 — Bitbucket provider), BJ-3 (#543 — Jira provider). All still OPEN on rc/atlassian-integration; implementer must rebase on those once merged. Optional DI tokens keep the module bootable in the interim.

Assumptions#

  • Unknown task.platform fails fast with a descriptive Error at invocation time.
  • Atlassian provider tokens are exported from their respective modules (BITBUCKET_AUTH_PROVIDER, JIRA_AUTH_PROVIDER) — matches the factory pattern already used in src/github/github.module.ts:14.
  • Tenant-specific values (BITBUCKET_WORKSPACE, JIRA_CLOUD_ID, etc.) are sourced from ConfigService like the existing GitHub passthrough; BJ-11 handles per-tenant routing separately.
ContextPrd