Skip to content

Add GitHub intake mode and whitelist helpers for setup #1606

Closed

Description

@propr-dev

Context

Setup must guide users through GitHub event ingestion choices and user whitelisting. The request specifically asks for the default ProPR App mode, polling, or direct webhooks, with brief explanations and links to documentation. It also asks to configure a GitHub user whitelist.

Requirements

  • Add a dedicated helper for intake mode .env updates.
  • Default to the ProPR App/shared relay path where available.
  • Support polling by disabling webhooks.
  • Support direct webhooks by requiring a secret.
  • Add whitelist configuration through the settings API when the backend is running.
  • Keep docs links in user-facing detail text.

Implementation Specification

Create packages/cli/src/commands/setup/github.ts and replace inline intake/whitelist logic in the engine with these helpers.

Acceptance Criteria

  • Selecting polling writes ENABLE_GITHUB_WEBHOOKS=false.
  • Selecting webhooks writes ENABLE_GITHUB_WEBHOOKS=true and GH_WEBHOOK_SECRET.
  • Empty webhook secret is rejected.
  • Whitelist is saved through settings without overwriting unrelated settings.

Created by ProPR AI Planner

Activity

  1. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    Suggested Implementation:

    Implementation Approach

    GitHub setup is factored out because it mixes local .env writes with backend settings updates. Keeping these operations in one helper makes the security-sensitive defaults easy to inspect. Polling remains the safest default for hardened deployments; direct webhooks are explicit and require a secret so setup cannot create an unsigned public endpoint.

    File: packages/cli/src/commands/setup/github.ts (new file)

    Why this file: This file owns setup choices around GitHub event intake and authorized users. It connects local env configuration to backend settings while keeping security rationale close to the code.

    import { spawnSync } from 'node:child_process';
    import type { ApiClient } from '../../api/client.js';
    import { updateSettings } from '../../api/settings.js';
    import { writeSetupEnv } from './state.js';
    import type { SetupPrompts } from './engine.js';
    
    export type IntakeMode = 'app' | 'polling' | 'webhooks';
    
    export async function configureGithubIntake(rootDir: string, prompts: SetupPrompts): Promise<IntakeMode> {
      const mode = await prompts.choose<IntakeMode>('Choose GitHub event ingestion mode.', [
        {
          value: 'app',
          label: 'ProPR App',
          detail: 'Recommended default. Uses the ProPR App/relay flow where available. Docs: https://docs.propr.dev/operations/github-auth',
        },
        {
          value: 'polling',
          label: 'Polling',
          detail: 'No public webhook endpoint required. ProPR checks GitHub periodically. Docs: https://docs.propr.dev/architecture/daemon-runtime',
        },
        {
          value: 'webhooks',
          label: 'Direct webhooks',
          detail: 'Lowest latency, but requires public HTTPS routing and a webhook secret. Docs: https://docs.propr.dev/tutorials/setup-server#configure-github-webhooks-optional',
        },
      ], 'app');
    
      if (mode === 'polling') {
        // Disable webhooks explicitly so re-running setup after a webhook experiment
        // returns the instance to the safer no-public-endpoint intake mode.
        writeSetupEnv(rootDir, { ENABLE_GITHUB_WEBHOOKS: 'false' });
      }
    
      if (mode === 'webhooks') {
        const secret = await prompts.input('GitHub webhook secret', '');
        if (!secret.trim()) {
          // The API refuses unsigned webhook mode at startup; fail here so the user
          // fixes the security prerequisite before continuing.
          throw new Error('Direct webhook mode requires GH_WEBHOOK_SECRET. Generate one with `openssl rand -hex 32`.');
        }
        writeSetupEnv(rootDir, { ENABLE_GITHUB_WEBHOOKS: 'true', GH_WEBHOOK_SECRET: secret.trim() });
      }
    
      return mode;
    }
    
    export async function configureGithubWhitelist(client: ApiClient, prompts: SetupPrompts): Promise<string[]> {
      const detectedUser = spawnSync('gh', ['api', 'user', '--jq', '.login'], { encoding: 'utf8' }).stdout.trim();
      const answer = await prompts.input('Comma-separated GitHub usernames allowed to trigger ProPR work', detectedUser);
      const users = answer.split(',').map((name) => name.trim()).filter(Boolean);
      if (users.length === 0) return [];
    
      // Use partial settings update because the settings endpoint merges values and
      // this avoids clobbering unrelated model/concurrency settings during setup.
      await updateSettings({ github_user_whitelist: users }, client);
      return users;
    }

    File: packages/cli/src/commands/setup/engine.ts

    Why this file: The engine should delegate GitHub-specific decisions to the helper so the main setup flow stays readable.

    --- a/packages/cli/src/commands/setup/engine.ts
    +++ b/packages/cli/src/commands/setup/engine.ts
    @@
    -import { updateSettings } from '../../api/settings.js';
    @@
     import { ensureSelectedAgents } from './agents.js';
    +import { configureGithubIntake, configureGithubWhitelist } from './github.js';
    @@
    -  const intake = await prompts.choose('Choose GitHub event ingestion mode.', [
    -    { value: 'app', label: 'ProPR App', detail: 'Recommended shared-app/relay path; simplest setup and supports managed event handling.' },
    -    { value: 'polling', label: 'Polling', detail: 'Private deployment default; no public webhook endpoint required, checks GitHub periodically.' },
    -    { value: 'webhooks', label: 'Direct webhooks', detail: 'Lowest latency, but requires public HTTPS endpoint and webhook secret.' },
    -  ], 'app');
    -  if (intake === 'polling') writeSetupEnv(rootDir, { ENABLE_GITHUB_WEBHOOKS: 'false' });
    -  if (intake === 'webhooks') {
    -    const secret = await prompts.input('Webhook secret', '');
    -    writeSetupEnv(rootDir, { ENABLE_GITHUB_WEBHOOKS: 'true', GH_WEBHOOK_SECRET: secret });
    -  }
    +  const intake = await configureGithubIntake(rootDir, prompts);
    @@
    -  const currentUser = spawnSync('gh', ['api', 'user', '--jq', '.login'], { encoding: 'utf8' }).stdout.trim();
    -  const whitelist = await prompts.input('Comma-separated GitHub usernames allowed to trigger work', currentUser);
    -  if (whitelist.trim()) await updateSettings({ github_user_whitelist: whitelist.split(',').map((name) => name.trim()).filter(Boolean) }, client);
    -  emit(updateStep(nextState, 'whitelist', { status: whitelist.trim() ? 'complete' : 'warning', detail: whitelist.trim() ? 'Whitelist saved.' : 'Whitelist skipped; configure it before production use.' }));
    +  const whitelist = await configureGithubWhitelist(client, prompts);
    +  emit(updateStep(nextState, 'whitelist', { status: whitelist.length > 0 ? 'complete' : 'warning', detail: whitelist.length > 0 ? 'Whitelist saved.' : 'Whitelist skipped; configure it before production use.' }));
  2. propr-dev commented on Jun 22, 2026

    @propr-dev
    ContributorAuthor

    🤖 AI processing has started for this issue using claude agent with claude-opus-4-8 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-4-8
    • Branch: 1606/claude-opus-4-8-add-github-intake-mode-an-20260622-1100-cnj
    • Base Branch: 1599-epic-build-comprehensive-b5c
    • Worktree: issue-1606-20260622-1100-claude-opus-4-8-cnj

    🔍 Track Task Execution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions