From 95ee13b9ff3f1c66f71e488da7adcdc7a68bed17 Mon Sep 17 00:00:00 2001 From: Luke Belton <58511679+luke-belton@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:53:52 +0100 Subject: [PATCH] Add ingestion-warnings command Wires the context-mill `ingestion-warnings` skill into the wizard as a first-class native command (`wizard ingestion-warnings`), mirroring the `revenue-analytics` pattern: a `createSkillProgram` config registered in the program registry, a `nativeCommandFactory` command file, and a bin.ts entry. Adds an abort case for the skill's `[ABORT] Could not read ingestion warnings and no PostHog instrumentation found to scan` so the user gets a structured outro instead of a generic failure. Generated-By: PostHog Code Task-Id: 9e7dceff-bc33-4dcd-bf3d-aa14f0abee65 --- bin.ts | 2 + src/commands/ingestion-warnings.ts | 15 ++++++++ src/lib/programs/ingestion-warnings/index.ts | 39 ++++++++++++++++++++ src/lib/programs/program-registry.ts | 3 ++ 4 files changed, 59 insertions(+) create mode 100644 src/commands/ingestion-warnings.ts create mode 100644 src/lib/programs/ingestion-warnings/index.ts diff --git a/bin.ts b/bin.ts index 34b709ef..d7c930f1 100644 --- a/bin.ts +++ b/bin.ts @@ -35,6 +35,7 @@ import { mcpCommand } from './src/commands/mcp'; import { mcpAnalyticsCommand } from './src/commands/mcp-analytics'; import { auditCommand } from './src/commands/audit'; import { doctorCommand } from './src/commands/doctor'; +import { ingestionWarningsCommand } from './src/commands/ingestion-warnings'; import { migrateCommand } from './src/commands/migrate'; import { revenueCommand } from './src/commands/revenue'; import { warehouseCommand } from './src/commands/warehouse'; @@ -66,6 +67,7 @@ Wizard.use(basicIntegrationCommand) .use(cliCommand) .use(auditCommand) .use(doctorCommand) + .use(ingestionWarningsCommand) .use(migrateCommand) .use(revenueCommand) .use(warehouseCommand) diff --git a/src/commands/ingestion-warnings.ts b/src/commands/ingestion-warnings.ts new file mode 100644 index 00000000..d0727106 --- /dev/null +++ b/src/commands/ingestion-warnings.ts @@ -0,0 +1,15 @@ +import { ingestionWarningsConfig } from '@lib/programs/ingestion-warnings/index'; + +import type { Command } from './command'; +import { nativeCommandFactory } from './factories/native-command-factory'; + +/** + * `wizard ingestion-warnings` — flat skill command. + * + * Diagnoses the ingestion warnings firing on the user's PostHog project and + * fixes the instrumentation producing them. Stays flat: there's a single + * thing to do here, not a family of choices. + */ +export const ingestionWarningsCommand: Command = nativeCommandFactory( + ingestionWarningsConfig, +); diff --git a/src/lib/programs/ingestion-warnings/index.ts b/src/lib/programs/ingestion-warnings/index.ts new file mode 100644 index 00000000..d4cfce12 --- /dev/null +++ b/src/lib/programs/ingestion-warnings/index.ts @@ -0,0 +1,39 @@ +import type { AbortCase } from '@lib/agent/agent-runner'; +import { createSkillProgram } from '@lib/programs/agent-skill/index'; + +/** + * `[ABORT] ` cases the ingestion-warnings skill can emit. + * Kept in sync with the abort reason declared in the context-mill skill's + * `description.md` / `references/1-triage.md`. + */ +export const INGESTION_WARNINGS_ABORT_CASES: AbortCase[] = [ + { + // Skill emits: [ABORT] Could not read ingestion warnings and no PostHog instrumentation found to scan + match: + /^could not read ingestion warnings and no posthog instrumentation found to scan$/i, + message: 'No ingestion warnings to work from', + body: + "The wizard couldn't read this project's ingestion warnings and found " + + 'no PostHog SDK usage in this directory to scan for the patterns that ' + + 'cause them. Run this command from the root of the project that sends ' + + 'events to PostHog, signed in to the right project.', + docsUrl: 'https://posthog.com/docs/data/ingestion-warnings', + }, +]; + +export const ingestionWarningsConfig = createSkillProgram({ + skillId: 'ingestion-warnings', + command: 'ingestion-warnings', + id: 'ingestion-warnings', + description: + "Diagnose and fix the instrumentation behind your project's ingestion warnings", + integrationLabel: 'ingestion-warnings', + successMessage: + 'Ingestion warnings triaged! See ./posthog-ingestion-warnings-report.md', + reportFile: 'posthog-ingestion-warnings-report.md', + docsUrl: 'https://posthog.com/docs/data/ingestion-warnings', + spinnerMessage: 'Diagnosing ingestion warnings...', + estimatedDurationMinutes: 5, + abortCases: INGESTION_WARNINGS_ABORT_CASES, + requires: ['posthog-integration'], +}); diff --git a/src/lib/programs/program-registry.ts b/src/lib/programs/program-registry.ts index 6a87e451..5e38f3ca 100644 --- a/src/lib/programs/program-registry.ts +++ b/src/lib/programs/program-registry.ts @@ -18,6 +18,7 @@ import { warehouseSourceConfig } from './warehouse-source/index.js'; import { auditConfig } from './audit/index.js'; import { eventsAuditConfig } from './events-audit/index.js'; import { posthogDoctorConfig } from './posthog-doctor/index.js'; +import { ingestionWarningsConfig } from './ingestion-warnings/index.js'; import { webAnalyticsDoctorConfig } from './web-analytics-doctor/index.js'; import { migrationConfig } from './migration/index.js'; import { errorTrackingUploadSourceMapsConfig } from './error-tracking-upload-source-maps/index.js'; @@ -70,6 +71,7 @@ export const PROGRAM_REGISTRY = [ auditConfig, eventsAuditConfig, posthogDoctorConfig, + ingestionWarningsConfig, webAnalyticsDoctorConfig, migrationConfig, selfDrivingConfig, @@ -95,6 +97,7 @@ export const Program = { Audit: auditConfig.id, EventsAudit: eventsAuditConfig.id, PosthogDoctor: posthogDoctorConfig.id, + IngestionWarnings: ingestionWarningsConfig.id, WebAnalyticsDoctor: webAnalyticsDoctorConfig.id, SelfDriving: selfDrivingConfig.id, AgentSkill: agentSkillConfig.id,