Skip to content

feat(wizard): add --detect-only headless detection mode - #1056

Draft
ablaszkiewicz wants to merge 2 commits into
mainfrom
ab/feat/sourcemaps-detect-only
Draft

feat(wizard): add --detect-only headless detection mode#1056
ablaszkiewicz wants to merge 2 commits into
mainfrom
ab/feat/sourcemaps-detect-only

Conversation

@ablaszkiewicz

@ablaszkiewicz ablaszkiewicz commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This is a part of a bigger change:

  1. feat(wizard): add --detect-only headless detection mode #1056 <-- this PR
  2. feat(backend): background repository detection cloud runs posthog#77157
  3. feat(frontend): cloud setup flow in source maps wizard modal posthog#80131
  4. feat(wizard): add headless mode with inline project selection #1069

Adds --detect-only command variant for uploading source maps. This runs only the detection and posts results back to posthog via scoped endpoint,

…to PostHog

Runs the agentic source-maps detection headlessly (doctor-style: auth, scan,
POST, exit — never enters the TUI or agent runner) and upserts the report to
/api/projects/{id}/wizard/repository_detections/. Built for the cloud wizard
run so a connected repository can be scanned in the background; also works
locally with --api-key. Failures (agent error, timeout) are recorded to the
same endpoint so the app can present them.

Hidden flag, unstable contract — same policy as the headless flag.
@ablaszkiewicz ablaszkiewicz self-assigned this Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue
  • /wizard-ci self-driving

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit

Results will be posted here when complete.

ablaszkiewicz added a commit to PostHog/posthog that referenced this pull request Aug 5, 2026
One kind identifier flows end to end: POST /api/wizard/detection
{project_id, repository, kind} creates a task and starts the dedicated
detect-repository Temporal workflow, which provisions a sandbox, clones
the repository, and runs the wizard detection program the kind selects
(WIZARD_DETECTION_PROGRAMS registry; error-tracking-source-maps runs
upload-source-maps --detect-only). The wizard posts its report to the
new POST-only repository_detections upsert endpoint under the same
kind, using its cloud-run OAuth token (the wizard_session scope its
grant already carries), so no scope or ceiling changes anywhere.

RepositoryDetection is a generic store: one row per (team, repository,
kind), one typed report serializer shared by all kinds, error variant
for failed runs. The workflow is a sibling of process-task reusing its
activities with none of the agent machinery: no agent server, no PR,
no CI loop, sandbox cleanup guaranteed in finally.

Verified end to end locally: cloud runs against posthog/hedgebox and
posthog/error-tracking-examples completed and stored reports; the
error path stores its failure under the same key.

Wizard side: PostHog/wizard#1056 (must release to npm first).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ablaszkiewicz added a commit to PostHog/posthog that referenced this pull request Aug 5, 2026
One kind identifier flows end to end: POST /api/wizard/detection
{project_id, repository, kind} creates a task and starts the dedicated
detect-repository Temporal workflow, which provisions a sandbox, clones
the repository, and runs the wizard detection program the kind selects
(WIZARD_DETECTION_PROGRAMS registry; error-tracking-source-maps runs
upload-source-maps --detect-only). The wizard posts its report to the
new POST-only repository_detections upsert endpoint under the same
kind, using its cloud-run OAuth token (the wizard_session scope its
grant already carries), so no scope or ceiling changes anywhere.

RepositoryDetection is a generic store: one row per (team, repository,
kind), one typed report serializer shared by all kinds, error variant
for failed runs. The workflow is a sibling of process-task reusing its
activities with none of the agent machinery: no agent server, no PR,
no CI loop, sandbox cleanup guaranteed in finally.

Verified end to end locally: cloud runs against posthog/hedgebox and
posthog/error-tracking-examples completed and stored reports; the
error path stores its failure under the same key.

Wizard side: PostHog/wizard#1056 (must release to npm first).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@posthog

posthog Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🦔 ReviewHog reviewed this pull request

Found 0 must fix, 2 should fix, 1 consider.

Published 3 findings (view the review).

@posthog

posthog Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

ReviewHog Alpha 🦔 If you find any issues helpful - please reply "valid", "invalid", etc., for evaluation purposes 🙏

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewHog Report

Changes

Issues: 3 issues

Files (3)
  • src/commands/upload-sourcemaps.ts
  • src/lib/programs/error-tracking-upload-source-maps/detect-only.ts
  • src/utils/setup-utils.ts

Comment thread src/lib/programs/error-tracking-upload-source-maps/detect-only.ts
Comment thread src/lib/programs/error-tracking-upload-source-maps/detect-only.ts
Comment thread src/commands/upload-sourcemaps.ts Outdated
- Dispatch runDetectOnly through runCommandHandler so pre-try/catch
  throws exit cleanly instead of becoming unhandled rejections
- Retry the detection POST (3 attempts, 30s per-attempt timeout,
  capped backoff) on network errors, 429, and 5xx; fail fast on
  other 4xx — the upsert is idempotent and guards a 5-minute scan
- Reconcile the entry-point docstring with the actual exit-code
  contract: 0 only on a saved successful detection

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ablaszkiewicz
ablaszkiewicz marked this pull request as ready for review August 7, 2026 12:33
Copilot AI review requested due to automatic review settings August 7, 2026 12:33
@ablaszkiewicz
ablaszkiewicz requested review from a team as code owners August 7, 2026 12:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@ablaszkiewicz ablaszkiewicz changed the title feat(sourcemaps): add --detect-only headless detection mode feat(wizard): add --detect-only headless detection mode Aug 9, 2026
@hpouillot

Copy link
Copy Markdown
Contributor

Any reason to not make it a command on its own? Is the detection data specific to sourcemap uploads ?

@ablaszkiewicz

Copy link
Copy Markdown
Contributor Author

@hpouillot yes. The detection data is specific to our program. We have a generic detect-agentic.ts which might be used by multiple programs but then our program has it's own further implementation of it

}

/** Best-effort: record the failure server-side so the app can show it. */
async function recordFailure(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not capture the exception inside this method instead ?

});
getUI().log.success(
`Detection saved: ${report.projects.length} project${
report.projects.length === 1 ? '' : 's'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have pluralize ?

@gewenyu99

gewenyu99 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

@ablaszkiewicz @hpouillot you read my mind. I had a detect command in mind that just did detection.

  • What projects can be instrumented
  • For each, what products can they make use of (frontend enable autocatpure, error tracking, session replay, etc), can they use AIO, do they have warehouse sources, etc.
  • report this in their wizard session table (idk what its actually called) for future context.

This way when we see there's a gap in analytics, we can even write scouts to fill gaps

An idea I had. I would make it its own command entirely ;) and make it that you can do posthog detect --source-map or smthing (maybe should be by product name)

Think about it. This is just me nudging you, please prioritize as you see fit

Copy link
Copy Markdown
Contributor Author

@gewenyu99 I agree that sounds good but I don't feel that I am the right person to come up with a new standard. I am lacking knowledge about wizard and cloud runs and how this plays together so I feel like I just wouldn't design this well. My wizard knowledge is very narrow and very focused just on our program.

I am happy to be a part of discussion tho and happy to migrate our ET detection to that once some standard is established.

@ablaszkiewicz
ablaszkiewicz marked this pull request as draft August 11, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants