Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/lib/onboarding-prompt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export function buildOnboardingPrompt({

...migrations.map((m) => migrateFlags(m, steps.next())),

generateReport({ step: steps.next(), isEmptyProject, goal, hasPlugins }),
generateReport({
step: steps.next(),
isEmptyProject,
goal,
hasPlugins,
hasMigrations: migrations.length > 0,
}),
summary(steps.next()),
rules(),
];
Expand Down
24 changes: 24 additions & 0 deletions src/lib/onboarding-prompt/report-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ const ALL_TEMPLATE_START = `\
- \`<feature flags SDK package name>\`
- \`<session recording SDK package name>\``;

export const MIGRATION_REPORT_SECTION = `\

## Flag migration

**Migrated flags:**

| Flag | Source | Status | Notes |
|------|--------|--------|-------|
<!-- One row per flag. Status: ✅ Migrated, ⚠️ Partial rollout, ❌ Failed, ⏭️ Skipped (blocked) -->

<!-- If any flags used a partial rollout, include this section: -->
### ⚠️ Partial-rollout warnings

<!-- For each partial-rollout flag: -->
- \`<flag-name>\` — migrated at <X>% rollout. Confidence uses a different bucketing hash than <PROVIDER>, so the exact user cohort will change: users currently in the rollout may drop out, and new users may enter. Verify rollout behavior after shipping.

<!-- If any flags failed to migrate, include this section: -->
### ❌ Failed migrations

<!-- For each failed flag: -->
- \`<flag-name>\` — <error reason>. Retry manually with \`/<SKILL_NAME> execute\`.

<!-- Omit the subsections above entirely if there are no partial-rollout or failed flags -->`;

const COMMON_TEMPLATE_END = `\
## How to use it

Expand Down
5 changes: 4 additions & 1 deletion src/lib/onboarding-prompt/report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { OnboardingGoal } from '../session.js';
import { CONFIDENCE_DOCS_URL } from '../constants.js';
import { buildReportTemplate } from './report-templates.js';
import { buildReportTemplate, MIGRATION_REPORT_SECTION } from './report-templates.js';
import { loadStep } from './steps/load.js';

const HOW_TO_RUN = `
Expand All @@ -17,18 +17,21 @@ export function generateReport({
isEmptyProject,
goal = 'feature-flags',
hasPlugins = false,
hasMigrations = false,
}: {
step: number;
isEmptyProject: boolean;
goal?: OnboardingGoal;
hasPlugins?: boolean;
hasMigrations?: boolean;
}): string {
const template = buildReportTemplate(goal);

return loadStep('generate-report.md', {
STEP: step,
REPORT_START: template.start,
HOW_TO_RUN: isEmptyProject ? HOW_TO_RUN : '',
MIGRATION_REPORT: hasMigrations ? MIGRATION_REPORT_SECTION : '',
REPORT_END: template.end,
SKILLS_NOTE: hasPlugins ? SKILLS_NOTE : '',
DOCS_URL: CONFIDENCE_DOCS_URL,
Expand Down
1 change: 1 addition & 0 deletions src/lib/onboarding-prompt/steps/generate-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Write a CONFIDENCE_QUICKSTART.md file in the project root with this structure:

{{REPORT_START}}
{{HOW_TO_RUN}}
{{MIGRATION_REPORT}}
{{SKILLS_NOTE}}{{REPORT_END}}

Fill in all actual values from the preceding steps. For the SDK reference link, use the docs MCP if available, otherwise search the web for the relevant SDK page at {{DOCS_URL}}. If no URL is found, omit that line rather than guessing.
29 changes: 24 additions & 5 deletions src/lib/onboarding-prompt/steps/migrate-flags.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
## {{STEP}}. Migrate {{PROVIDER_NAME}} flags to Confidence

Use the `/{{SKILL_NAME}}` skill to migrate existing {{PROVIDER_NAME}} feature flag evaluations to Confidence.
Read the `/{{SKILL_NAME}}` skill as a **methodology reference** — use it for how to identify flags, build the migration plan, map types and rules to Confidence equivalents, and call the MCP tools. Ignore its output formatting, step trackers, EDUCATE blocks, AskUserQuestion calls, and ALL interactive prompts. Never pause for user input.

Follow the skill's three-phase workflow:
**Guardrails — apply regardless of what the skill says:**

1. Run `/{{SKILL_NAME}} plan flag` to generate the flag migration plan
2. Run `/{{SKILL_NAME}} plan code` to generate the code migration plan
3. Run `/{{SKILL_NAME}} execute <plan-file>` to apply the migration
- **Scan the codebase, not the provider API.** You do not have {{PROVIDER_NAME}} API credentials. Discover flags by scanning the project source code for {{PROVIDER_NAME}} SDK usage patterns (flag evaluations, feature checks, experiment references). Do NOT ask for API tokens, project IDs, or exported JSON files.
- **Consent is pre-approved.** The user already chose to migrate {{PROVIDER_NAME}} flags through the wizard UI — that is their consent. Mark every eligible flag as `[x] Migrate`. This satisfies the skill's consent gate — do NOT stop to ask the user to tick checkboxes.
- **Auto-select all decisions.** Do not stop at any `⏸ awaiting user` gate. Use these defaults:
- environment → `production`;
- archived flags → exclude;
- execution mode → `migrate-all-eligible`;
- Confidence client → use first existing client, or create one if none exist;
- entity/bucketing field → `targeting_key`.
- If the skill asks the user to confirm scope, choose a mode, pick a client, or map a field — apply the default and move on.
- **No per-flag confirmations.** Skip `review-each` gates, per-flag `[Yes / Skip / Pause]` prompts, and checkpoint pauses. Process every eligible flag without stopping.
- **Partial-rollout flags → migrate at the original percentage.** Do not stop to explain risk or ask for confirmation. Use the same rollout percentage from the {{PROVIDER_NAME}} configuration. Record each partial-rollout flag in the report with a warning: Confidence uses a different bucketing hash, so the exact user cohort will change after migration — users currently in the rollout may move out, and new users may move in. The user should verify rollout behavior after shipping.
- **All changes on the current branch.** Do NOT create separate branches or pull requests per flag. Apply all migration changes (flag creation + code rewrites) directly on the current branch in a single pass. Ignore the skill's "each flag = one PR" instruction.
- **SDK install and code transforms → just do it.** Do not ask `Install SDK now?`, `Create wrapper?`, or `Transform this flag's files?` — run every install, wrapper creation, and code transform automatically.
- **Always start fresh.** If an existing plan file is found, overwrite it. Do not ask the user whether to resume or start fresh.
- **Errors → log and continue.** If a single flag fails after retry, log it and move to the next flag. Do not stop to ask `[Retry / Skip / Pause]`. Include every failed flag in the report with the error reason so the user can retry manually.

Execute the skill's workflow automatically:

1. **Scan** the project for {{PROVIDER_NAME}} feature flag usage in source code and build the flag migration plan.
2. **Pre-approve** all eligible flags per the guardrails above.
3. **Plan code** transformations for all approved flags.
4. **Execute** — create Confidence flags via MCP tools and rewrite code. Apply all changes on the current branch without branching or opening PRs.

For each flag migrated, print:
STATUS: Migrated flag: <flag-name>
Expand Down