@funnelsgrove/cli 0.1.53 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/cli.d.ts +1 -1
  2. package/dist/cli.js +24 -2
  3. package/dist/experimentCreate.d.ts +3 -8
  4. package/dist/experimentCreate.js +19 -18
  5. package/funnel-contract-compatibility.json +35 -35
  6. package/package.json +4 -4
  7. package/template_docs/.funnelsgrove-docs.json +4 -4
  8. package/template_docs/docs/funnelsgrove/migrations/step-contract-v3.md +1 -1
  9. package/template_docs/docs/funnelsgrove/recipes/add-experiment.md +11 -10
  10. package/template_docs/funnel-docs.config.json +1 -1
  11. package/template_scaffold/.funnelsgrove-contract-tools.json +1 -1
  12. package/template_scaffold/.funnelsgrove-docs.json +4 -4
  13. package/template_scaffold/.funnelsgrove-scaffold.json +19 -34
  14. package/template_scaffold/docs/funnelsgrove/migrations/step-contract-v3.md +1 -1
  15. package/template_scaffold/docs/funnelsgrove/recipes/add-experiment.md +11 -10
  16. package/template_scaffold/funnel-docs.config.json +1 -1
  17. package/template_scaffold/package-lock.json +14 -14
  18. package/template_scaffold/package.json +3 -3
  19. package/template_scaffold/src/components/FunnelFlow.tsx +26 -0
  20. package/template_scaffold/src/config/funnel.manifest.ts +2 -2
  21. package/template_scaffold/src/contract/funnel-project.validation.ts +1 -2
  22. package/template_scaffold/src/runtime/funnel-runtime.ts +2 -10
  23. package/template_scaffold/src/runtime/use-funnel-flow-controller.ts +15 -1
  24. package/template_scaffold/src/steps/step-32-paywall.tsx +47 -15
  25. package/template_scaffold/tests/funnel-agent-docs.test.ts +5 -4
  26. package/template_scaffold/tests/src/components/FunnelFlow.test.tsx +4 -0
  27. package/template_scaffold/tests/src/contract/funnel-project.validation.test.ts +1 -2
  28. package/template_scaffold/tests/src/steps/step-32-paywall.test.ts +6 -3
  29. package/template_validation/.funnelsgrove-contract-tools.json +1 -1
  30. package/template_validation/src/contract/funnel-project.validation.ts +1 -2
  31. package/template_scaffold/src/config/experiments.generated.ts +0 -4
  32. package/template_scaffold/src/config/experiments.ts +0 -9
  33. package/template_scaffold/tests/src/config/experiments.test.ts +0 -12
package/dist/cli.d.ts CHANGED
@@ -267,7 +267,7 @@ export declare const formatOfferSetSyncSuccess: (input: {
267
267
  offerSetLabel: string;
268
268
  generatedFileCount: number;
269
269
  }) => string[];
270
- type ExperimentLifecycleAction = 'start' | 'stop' | 'restart';
270
+ type ExperimentLifecycleAction = 'start' | 'stop' | 'restart' | 'end';
271
271
  type ExperimentLifecycleResult = {
272
272
  id: string;
273
273
  funnel_id: string;
package/dist/cli.js CHANGED
@@ -1048,7 +1048,7 @@ const GENERATED_CONFIG_PATH_BY_KIND = {
1048
1048
  offerSets: 'src/config/offer-sets.generated.ts',
1049
1049
  experiments: 'src/config/experiments.generated.ts',
1050
1050
  };
1051
- export const SYNC_DOWN_GENERATED_CONFIG_KINDS = ['offerSets', 'experiments'];
1051
+ export const SYNC_DOWN_GENERATED_CONFIG_KINDS = ['offerSets'];
1052
1052
  export const EXPERIMENT_TRANSACTION_RECOVERY_COMMANDS = [
1053
1053
  'sync down',
1054
1054
  'sync up',
@@ -1508,7 +1508,13 @@ export const formatExperimentLifecycleSuccess = (action, result, json) => {
1508
1508
  if (json) {
1509
1509
  return `${JSON.stringify(payload)}\n`;
1510
1510
  }
1511
- const verb = action === 'stop' ? 'Stopped' : action === 'restart' ? 'Restarted' : 'Started';
1511
+ const verb = action === 'stop'
1512
+ ? 'Stopped'
1513
+ : action === 'restart'
1514
+ ? 'Restarted'
1515
+ : action === 'end'
1516
+ ? 'Ended'
1517
+ : 'Started';
1512
1518
  return `${verb} experiment ${result.name?.trim() || result.id} (${result.status})\n`;
1513
1519
  };
1514
1520
  /**
@@ -1809,6 +1815,22 @@ const registerExperimentLifecycleCommand = (action, description) => {
1809
1815
  registerExperimentLifecycleCommand('start', 'Start a draft or stopped experiment');
1810
1816
  registerExperimentLifecycleCommand('stop', 'Stop traffic without ending the experiment');
1811
1817
  registerExperimentLifecycleCommand('restart', 'Stop and start an experiment, preserving its variants');
1818
+ registerExperimentLifecycleCommand('end', 'Permanently end and archive an experiment');
1819
+ addExamples(experimentsCommand
1820
+ .command('delete <id>')
1821
+ .description('Delete a draft experiment')
1822
+ .option('--json', 'Emit one machine-readable success object'), ['fgrove experiments delete 22222222-2222-4222-8222-222222222222'])
1823
+ .action(async (id, options) => {
1824
+ await callApi({
1825
+ path: 'funnelExperiments.delete',
1826
+ type: 'mutation',
1827
+ token: await readAuthToken(),
1828
+ data: { id },
1829
+ });
1830
+ process.stdout.write(options.json === true
1831
+ ? `${JSON.stringify({ experimentId: id, deleted: true })}\n`
1832
+ : `Deleted experiment ${id}\n`);
1833
+ });
1812
1834
  addExamples(experimentsCommand
1813
1835
  .command('sync')
1814
1836
  .description('Write generated experiment config for a funnel')
@@ -11,7 +11,7 @@ export type AgentExperimentVariant = {
11
11
  isControl: boolean;
12
12
  };
13
13
  export type AgentPricingExperimentVariant = AgentExperimentVariant & {
14
- offerSetKey: string;
14
+ offerSetId: string;
15
15
  };
16
16
  type SharedAgentExperimentSpec = {
17
17
  id: string;
@@ -47,7 +47,7 @@ export type ExperimentCreateResponse = {
47
47
  is_control: boolean;
48
48
  }>;
49
49
  draftVersionId: string;
50
- generatedFiles: [GeneratedExperimentFile, GeneratedExperimentFile];
50
+ generatedFiles: [];
51
51
  githubConnected: boolean;
52
52
  };
53
53
  export declare class ExperimentCreateContractError extends Error {
@@ -81,19 +81,14 @@ export type ExperimentCreateSuccess = {
81
81
  experimentId: string;
82
82
  experimentKey: string;
83
83
  draftVersionId: string;
84
- writtenPaths: [...typeof EXPERIMENT_GENERATED_PATHS];
84
+ writtenPaths: [];
85
85
  githubConnected: boolean;
86
86
  };
87
87
  type ExecuteExperimentCreateDependencies = {
88
88
  recover: typeof recoverExperimentCreateTransaction;
89
89
  readManifest: typeof readSyncManifest;
90
90
  readSpec: typeof readAgentExperimentSpec;
91
- assertGeneratedFilesUnchanged: typeof assertGeneratedExperimentFilesUnchanged;
92
91
  parseResponse: typeof parseExperimentCreateResponse;
93
- install: (sourceDir: string, input: {
94
- generatedFiles: unknown;
95
- manifest: SyncManifest;
96
- }) => Promise<void>;
97
92
  };
98
93
  export declare function executeExperimentCreate(input: ExecuteExperimentCreateInput, dependencyOverrides?: Partial<ExecuteExperimentCreateDependencies>): Promise<ExperimentCreateSuccess>;
99
94
  export declare function formatExperimentCreateSuccess(result: ExperimentCreateSuccess, json: boolean): string;
@@ -11,6 +11,7 @@ export const EXPERIMENT_GENERATED_PATHS = [
11
11
  ];
12
12
  const EXPERIMENT_GENERATED_CONTENT_TYPE = 'text/typescript';
13
13
  const LOWERCASE_SHA256 = /^[a-f0-9]{64}$/;
14
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
14
15
  const EXPERIMENT_METRICS = [
15
16
  'step_completion',
16
17
  'next_step_reached',
@@ -54,6 +55,13 @@ const requireString = (value, fieldPath, maxLength) => {
54
55
  }
55
56
  return trimmed;
56
57
  };
58
+ const requireUuid = (value, fieldPath) => {
59
+ const parsed = requireString(value, fieldPath, 36);
60
+ if (!UUID_PATTERN.test(parsed)) {
61
+ fail(fieldPath, 'must be a UUID');
62
+ }
63
+ return parsed;
64
+ };
57
65
  const requireBoolean = (value, fieldPath) => {
58
66
  if (typeof value !== 'boolean') {
59
67
  fail(fieldPath, 'must be a boolean');
@@ -95,7 +103,7 @@ const parseVariant = (value, index, type) => {
95
103
  'routeToStepId',
96
104
  'trafficPercent',
97
105
  'isControl',
98
- ...(type === 'pricing' ? ['offerSetKey'] : []),
106
+ ...(type === 'pricing' ? ['offerSetId'] : []),
99
107
  ];
100
108
  assertExactKeys(record, keys, fieldPath);
101
109
  const shared = {
@@ -110,7 +118,7 @@ const parseVariant = (value, index, type) => {
110
118
  }
111
119
  return {
112
120
  ...shared,
113
- offerSetKey: requireString(record.offerSetKey, `${fieldPath}.offerSetKey`, 200),
121
+ offerSetId: requireUuid(record.offerSetId, `${fieldPath}.offerSetId`),
114
122
  };
115
123
  };
116
124
  export function parseAgentExperimentSpec(value) {
@@ -257,7 +265,7 @@ const expectedConversionConfig = (spec) => (spec.type === 'pricing'
257
265
  source: 'agent',
258
266
  type: 'pricing',
259
267
  paywallStepId: spec.stepId,
260
- offerSetKeys: spec.variants.map((variant) => variant.offerSetKey),
268
+ offerSetIds: spec.variants.map((variant) => variant.offerSetId),
261
269
  }
262
270
  : {
263
271
  source: 'agent',
@@ -343,13 +351,15 @@ export function parseExperimentCreateResponse(value, requestedSpec, expectedFunn
343
351
  fail('variants', 'must contain unique persisted variant ids');
344
352
  }
345
353
  const draftVersionId = requireString(response.draftVersionId, 'draftVersionId');
346
- const generatedFiles = parseGeneratedExperimentFiles(response.generatedFiles);
354
+ if (!Array.isArray(response.generatedFiles) || response.generatedFiles.length !== 0) {
355
+ fail('generatedFiles', 'must be empty because experiments are runtime artifacts');
356
+ }
347
357
  const githubConnected = requireBoolean(response.githubConnected, 'githubConnected');
348
358
  return {
349
359
  experiment: experiment,
350
360
  variants,
351
361
  draftVersionId,
352
- generatedFiles,
362
+ generatedFiles: [],
353
363
  githubConnected,
354
364
  };
355
365
  }
@@ -830,9 +840,7 @@ const executeExperimentCreateDependencies = {
830
840
  recover: recoverExperimentCreateTransaction,
831
841
  readManifest: readSyncManifest,
832
842
  readSpec: readAgentExperimentSpec,
833
- assertGeneratedFilesUnchanged: assertGeneratedExperimentFilesUnchanged,
834
843
  parseResponse: parseExperimentCreateResponse,
835
- install: installExperimentCreateTransaction,
836
844
  };
837
845
  export async function executeExperimentCreate(input, dependencyOverrides = {}) {
838
846
  const dependencies = { ...executeExperimentCreateDependencies, ...dependencyOverrides };
@@ -842,7 +850,6 @@ export async function executeExperimentCreate(input, dependencyOverrides = {}) {
842
850
  throw new Error(`No ${SYNC_MANIFEST_FILE} found. Run \`fgrove sync down --dir ${input.sourceDir}\` first.`);
843
851
  }
844
852
  const spec = await dependencies.readSpec(input.specPath);
845
- await dependencies.assertGeneratedFilesUnchanged(input.sourceDir, manifest);
846
853
  const rawResponse = await input.createFromSpec({
847
854
  workspaceId: manifest.workspaceId,
848
855
  funnelId: manifest.funnelId,
@@ -850,17 +857,11 @@ export async function executeExperimentCreate(input, dependencyOverrides = {}) {
850
857
  spec,
851
858
  });
852
859
  const response = dependencies.parseResponse(rawResponse, spec, manifest.funnelId);
853
- await dependencies.assertGeneratedFilesUnchanged(input.sourceDir, manifest);
854
- const nextManifest = buildExperimentCreateManifest(manifest, response.draftVersionId, response.generatedFiles);
855
- await dependencies.install(input.sourceDir, {
856
- generatedFiles: response.generatedFiles,
857
- manifest: nextManifest,
858
- });
859
860
  return {
860
861
  experimentId: response.experiment.id,
861
862
  experimentKey: response.experiment.posthog_flag_key,
862
863
  draftVersionId: response.draftVersionId,
863
- writtenPaths: [...EXPERIMENT_GENERATED_PATHS],
864
+ writtenPaths: [],
864
865
  githubConnected: response.githubConnected,
865
866
  };
866
867
  }
@@ -875,12 +876,12 @@ export function formatExperimentCreateSuccess(result, json) {
875
876
  return `${JSON.stringify(machineOutput, null, 2)}\n`;
876
877
  }
877
878
  const guidance = result.githubConnected
878
- ? 'For this GitHub-connected funnel, commit and push the generated source files with your other source changes, then run `fgrove github pull`.'
879
- : 'Run `fgrove sync up` to deliver the local funnel changes.';
879
+ ? 'The experiment is stored in FunnelsGrove. Commit and push any variant source changes, then run `fgrove github pull`; no generated experiment files were written.'
880
+ : 'The experiment is stored in FunnelsGrove. Run `fgrove sync up` only if the local funnel source also changed; no generated experiment files were written.';
880
881
  return [
881
882
  `Created experiment ${result.experimentId} (${result.experimentKey})`,
882
883
  `Draft version ${result.draftVersionId}`,
883
- `Wrote ${result.writtenPaths.join(', ')}`,
884
+ 'Wrote no generated experiment files',
884
885
  guidance,
885
886
  '',
886
887
  ].join('\n');
@@ -4,10 +4,10 @@
4
4
  "minimumCliVersion": "0.1.20",
5
5
  "entries": [
6
6
  {
7
- "repositoryCliVersion": "0.1.53",
7
+ "repositoryCliVersion": "0.1.62",
8
8
  "manifest": {
9
9
  "schemaVersion": 1,
10
- "bundleVersion": "2.0.41",
10
+ "bundleVersion": "2.0.51",
11
11
  "stepContractVersion": 3,
12
12
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
13
13
  "managedFiles": [
@@ -45,7 +45,7 @@
45
45
  },
46
46
  {
47
47
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
48
- "sha256": "7993d09cd90636290a43ee9ed0cdebf62a4fea99c77625b7880d2641b6175ba0"
48
+ "sha256": "10cd5853ffbe09a300fe222b18d1f7d7c1dd0f61a02693dd8e6d586b283f2121"
49
49
  },
50
50
  {
51
51
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  {
67
67
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
68
- "sha256": "7b2d28d84042c7b22f1cc26f0407389c4bfc6d38f82b473cb128a822f750b0d8"
68
+ "sha256": "c63a0f15884b2bf5d65f28d127345bd97641a7b38d047907d6d66f091e15a44a"
69
69
  },
70
70
  {
71
71
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -145,16 +145,16 @@
145
145
  },
146
146
  {
147
147
  "path": "funnel-docs.config.json",
148
- "sha256": "dd7eeb6a8028af400f7c28565b622a3ae824e67c9830b71f4c83fbb2487d2159"
148
+ "sha256": "06c7a3e1b2885129c83e8dd405a9d37ef6f87a14702d92c420772e5bf733f9cc"
149
149
  }
150
150
  ]
151
151
  }
152
152
  },
153
153
  {
154
- "repositoryCliVersion": "0.1.52",
154
+ "repositoryCliVersion": "0.1.61",
155
155
  "manifest": {
156
156
  "schemaVersion": 1,
157
- "bundleVersion": "2.0.40",
157
+ "bundleVersion": "2.0.50",
158
158
  "stepContractVersion": 3,
159
159
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
160
160
  "managedFiles": [
@@ -192,7 +192,7 @@
192
192
  },
193
193
  {
194
194
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
195
- "sha256": "bbde1c301b2d4ca0a7a3cbfd9b198263a9106d1c42a2dfd0ef802f581fd45988"
195
+ "sha256": "88942be6d27cf6f8526d01dfbf143948dd7f82f4b9a17469e18243900a736139"
196
196
  },
197
197
  {
198
198
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -212,7 +212,7 @@
212
212
  },
213
213
  {
214
214
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
215
- "sha256": "7b2d28d84042c7b22f1cc26f0407389c4bfc6d38f82b473cb128a822f750b0d8"
215
+ "sha256": "c63a0f15884b2bf5d65f28d127345bd97641a7b38d047907d6d66f091e15a44a"
216
216
  },
217
217
  {
218
218
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -292,16 +292,16 @@
292
292
  },
293
293
  {
294
294
  "path": "funnel-docs.config.json",
295
- "sha256": "9b68227426254a9b5563019abb36c552d598ccc2fed3266b432421e3908ddbc7"
295
+ "sha256": "a39599a33bdbed2eaa5660371d25912dae392a5cefda40798014bd8b933db50e"
296
296
  }
297
297
  ]
298
298
  }
299
299
  },
300
300
  {
301
- "repositoryCliVersion": "0.1.51",
301
+ "repositoryCliVersion": "0.1.60",
302
302
  "manifest": {
303
303
  "schemaVersion": 1,
304
- "bundleVersion": "2.0.39",
304
+ "bundleVersion": "2.0.49",
305
305
  "stepContractVersion": 3,
306
306
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
307
307
  "managedFiles": [
@@ -339,7 +339,7 @@
339
339
  },
340
340
  {
341
341
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
342
- "sha256": "26382941b09aa65edc147d2aa7336a745179047b6ec9a308c9572f88516c5e01"
342
+ "sha256": "f0294b0f21fc24ab69d2f41917869a885a5901d6138d25df11140174e4fb4e72"
343
343
  },
344
344
  {
345
345
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -359,7 +359,7 @@
359
359
  },
360
360
  {
361
361
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
362
- "sha256": "9918b577f47a9577c3c98d9a6a7a8762ddfeedb667efe13000900d1a1daee1f9"
362
+ "sha256": "dda3f6d812a18ec6be690f76ba82a520ba9e07b4a23f2278e14a0eecb801c729"
363
363
  },
364
364
  {
365
365
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -439,16 +439,16 @@
439
439
  },
440
440
  {
441
441
  "path": "funnel-docs.config.json",
442
- "sha256": "61864db071b802bc5570df67e5eecd8bf43dfbd3e0c5c08abe3a1745df662503"
442
+ "sha256": "70200599749b518b879b32539ea67ada93bd138237c1a5fab57d64203c06cda1"
443
443
  }
444
444
  ]
445
445
  }
446
446
  },
447
447
  {
448
- "repositoryCliVersion": "0.1.50",
448
+ "repositoryCliVersion": "0.1.59",
449
449
  "manifest": {
450
450
  "schemaVersion": 1,
451
- "bundleVersion": "2.0.38",
451
+ "bundleVersion": "2.0.48",
452
452
  "stepContractVersion": 3,
453
453
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
454
454
  "managedFiles": [
@@ -486,7 +486,7 @@
486
486
  },
487
487
  {
488
488
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
489
- "sha256": "056fccc3085ebde480cf0725fab45410bc369fc1434754cd25187e44d3615e28"
489
+ "sha256": "ad72376d6e98c3908bc57e6853387008dca3367f9dba2d7b43cdc4b90148ef4e"
490
490
  },
491
491
  {
492
492
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -506,7 +506,7 @@
506
506
  },
507
507
  {
508
508
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
509
- "sha256": "9918b577f47a9577c3c98d9a6a7a8762ddfeedb667efe13000900d1a1daee1f9"
509
+ "sha256": "ccc216612e0d532790a81d556111417876b0408944cae0eb8cd13e758a196bb8"
510
510
  },
511
511
  {
512
512
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -586,16 +586,16 @@
586
586
  },
587
587
  {
588
588
  "path": "funnel-docs.config.json",
589
- "sha256": "d3643ea1a8b9c63b28a18465e4afae1771aab6972559828ebf4802c7ad1df8cb"
589
+ "sha256": "9d1cb3d86bb1eaa518d04151829b71bb72c21a13c175fcec5ad798393b2f4340"
590
590
  }
591
591
  ]
592
592
  }
593
593
  },
594
594
  {
595
- "repositoryCliVersion": "0.1.49",
595
+ "repositoryCliVersion": "0.1.58",
596
596
  "manifest": {
597
597
  "schemaVersion": 1,
598
- "bundleVersion": "2.0.37",
598
+ "bundleVersion": "2.0.47",
599
599
  "stepContractVersion": 3,
600
600
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
601
601
  "managedFiles": [
@@ -633,7 +633,7 @@
633
633
  },
634
634
  {
635
635
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
636
- "sha256": "6268f1d754bc29586cc134032f199bcb7d449a096eafe90cf917e501b9768fe6"
636
+ "sha256": "4ea96f97ccad5bd9b01f0eeb30936557dec46f9b272599f12f96ffc6bcdc1883"
637
637
  },
638
638
  {
639
639
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -653,7 +653,7 @@
653
653
  },
654
654
  {
655
655
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
656
- "sha256": "9918b577f47a9577c3c98d9a6a7a8762ddfeedb667efe13000900d1a1daee1f9"
656
+ "sha256": "ccc216612e0d532790a81d556111417876b0408944cae0eb8cd13e758a196bb8"
657
657
  },
658
658
  {
659
659
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -733,16 +733,16 @@
733
733
  },
734
734
  {
735
735
  "path": "funnel-docs.config.json",
736
- "sha256": "99bc93eab4e586a84507821d8ad859f20e87d839a6d9eee2cdf83f72de4a51ae"
736
+ "sha256": "acd7e0c21d82218ed385a5606c1824af2d452368e0e9857cf2b2ddf341f1b855"
737
737
  }
738
738
  ]
739
739
  }
740
740
  },
741
741
  {
742
- "repositoryCliVersion": "0.1.48",
742
+ "repositoryCliVersion": "0.1.57",
743
743
  "manifest": {
744
744
  "schemaVersion": 1,
745
- "bundleVersion": "2.0.36",
745
+ "bundleVersion": "2.0.46",
746
746
  "stepContractVersion": 3,
747
747
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
748
748
  "managedFiles": [
@@ -780,7 +780,7 @@
780
780
  },
781
781
  {
782
782
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
783
- "sha256": "196f56b9138501b1cec0678422c1434d462a01ca5578ebfec607d323b1801234"
783
+ "sha256": "f7c68708397ff163bfbb29bf49d3e92a8d043100587efe9401478a2365f797c8"
784
784
  },
785
785
  {
786
786
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -800,7 +800,7 @@
800
800
  },
801
801
  {
802
802
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
803
- "sha256": "9918b577f47a9577c3c98d9a6a7a8762ddfeedb667efe13000900d1a1daee1f9"
803
+ "sha256": "ccc216612e0d532790a81d556111417876b0408944cae0eb8cd13e758a196bb8"
804
804
  },
805
805
  {
806
806
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -880,16 +880,16 @@
880
880
  },
881
881
  {
882
882
  "path": "funnel-docs.config.json",
883
- "sha256": "3f95a918c742c06e3130b20e2edc0820aee8ed213cd6bcdeb09cacb8c428143b"
883
+ "sha256": "00a3c1130a35be8d05380788e2d73444c78a65f661eb45963b929b5b7eda005a"
884
884
  }
885
885
  ]
886
886
  }
887
887
  },
888
888
  {
889
- "repositoryCliVersion": "0.1.47",
889
+ "repositoryCliVersion": "0.1.56",
890
890
  "manifest": {
891
891
  "schemaVersion": 1,
892
- "bundleVersion": "2.0.35",
892
+ "bundleVersion": "2.0.44",
893
893
  "stepContractVersion": 3,
894
894
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
895
895
  "managedFiles": [
@@ -927,7 +927,7 @@
927
927
  },
928
928
  {
929
929
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
930
- "sha256": "164ce4a6860a5d44cf6fad9a9df4c711cc246f1b3982501679645c9971173c70"
930
+ "sha256": "3bec55a8b14cb0c308d83597af78a59e3c5e8056605a0edc11411ee4e9441c93"
931
931
  },
932
932
  {
933
933
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -947,7 +947,7 @@
947
947
  },
948
948
  {
949
949
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
950
- "sha256": "9918b577f47a9577c3c98d9a6a7a8762ddfeedb667efe13000900d1a1daee1f9"
950
+ "sha256": "ccc216612e0d532790a81d556111417876b0408944cae0eb8cd13e758a196bb8"
951
951
  },
952
952
  {
953
953
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -1027,7 +1027,7 @@
1027
1027
  },
1028
1028
  {
1029
1029
  "path": "funnel-docs.config.json",
1030
- "sha256": "d4195ce4a134209e1dd5afb93744d5fbf3ff27f0e64f1c19ff210d09487368b1"
1030
+ "sha256": "bcfdb025c8123433ec0c8647fc7f4ce899b49479f91b10d06b354315854302cf"
1031
1031
  }
1032
1032
  ]
1033
1033
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/cli",
3
- "version": "0.1.53",
3
+ "version": "0.1.62",
4
4
  "description": "FunnelsGrove command-line tools for editing, syncing, and publishing funnels",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,13 +34,13 @@
34
34
  "test": "vitest run"
35
35
  },
36
36
  "dependencies": {
37
- "@funnelsgrove/runtime": "0.2.0",
37
+ "@funnelsgrove/runtime": "0.7.0",
38
38
  "commander": "^12.0.0",
39
39
  "typescript": "^5.8.3"
40
40
  },
41
41
  "devDependencies": {
42
- "@funnelsgrove/analytics": "0.1.44",
43
- "@funnelsgrove/payments": "0.2.0",
42
+ "@funnelsgrove/analytics": "0.1.49",
43
+ "@funnelsgrove/payments": "0.7.0",
44
44
  "vitest": "^3.0.0"
45
45
  }
46
46
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.41",
3
+ "bundleVersion": "2.0.51",
4
4
  "stepContractVersion": 3,
5
5
  "contractHash": "d761e91d5ac6ff9e72c6d49c5bcd014270912473a66f99c49d726c65998085cf",
6
6
  "managedFiles": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  {
40
40
  "path": "docs/funnelsgrove/migrations/step-contract-v3.md",
41
- "sha256": "7993d09cd90636290a43ee9ed0cdebf62a4fea99c77625b7880d2641b6175ba0"
41
+ "sha256": "10cd5853ffbe09a300fe222b18d1f7d7c1dd0f61a02693dd8e6d586b283f2121"
42
42
  },
43
43
  {
44
44
  "path": "docs/funnelsgrove/qa/analytics.md",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  {
60
60
  "path": "docs/funnelsgrove/recipes/add-experiment.md",
61
- "sha256": "7b2d28d84042c7b22f1cc26f0407389c4bfc6d38f82b473cb128a822f750b0d8"
61
+ "sha256": "c63a0f15884b2bf5d65f28d127345bd97641a7b38d047907d6d66f091e15a44a"
62
62
  },
63
63
  {
64
64
  "path": "docs/funnelsgrove/recipes/add-step.md",
@@ -138,7 +138,7 @@
138
138
  },
139
139
  {
140
140
  "path": "funnel-docs.config.json",
141
- "sha256": "dd7eeb6a8028af400f7c28565b622a3ae824e67c9830b71f4c83fbb2487d2159"
141
+ "sha256": "06c7a3e1b2885129c83e8dd405a9d37ef6f87a14702d92c420772e5bf733f9cc"
142
142
  }
143
143
  ]
144
144
  }
@@ -17,7 +17,7 @@ Supported read versions: `1`, `2`, `3`. Authoring and publish target version `3`
17
17
 
18
18
  ### Package release order
19
19
 
20
- Release `@funnelsgrove/runtime` `0.2.0` first, then `@funnelsgrove/analytics` `0.1.44`, then `@funnelsgrove/payments` `0.2.0`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.53`. Publishing packages and deploying production remain separately approved operational actions.
20
+ Release `@funnelsgrove/runtime` `0.7.0` first, then `@funnelsgrove/analytics` `0.1.49`, then `@funnelsgrove/payments` `0.7.0`. Deploy the API and funnel template, then confirm production `/health` reports the new docs identity. Only then publish `@funnelsgrove/cli` `0.1.62`. Publishing packages and deploying production remain separately approved operational actions.
21
21
  <!-- funnelsgrove:generated:end contract-v3/migration/step-contract-v3 -->
22
22
 
23
23
  ## Version-last policy
@@ -38,7 +38,7 @@ Use only the documented fields. Unknown top-level and variant fields are rejecte
38
38
 
39
39
  All experiment types require non-empty `id`, `name`, and `stepId`; one `primaryMetric`; at least one unique `trackedMetrics` entry containing the primary metric; and two to five variants. Each variant requires a unique non-empty `variantKey`, `label`, and `routeToStepId`, an integer `trafficPercent` from 0 through 100, and `isControl`. Exactly one variant is the control and traffic must total 100.
40
40
 
41
- Length limits are enforced after surrounding whitespace is trimmed: `variantKey` is at most 120 characters. `id`, `name`, `stepId`, `label`, `routeToStepId`, and `offerSetKey` are each at most 200 characters after trimming. `offerSetKey` applies only to pricing variants.
41
+ Length limits are enforced after surrounding whitespace is trimmed: `variantKey` is at most 120 characters. `id`, `name`, `stepId`, `label`, and `routeToStepId` are each at most 200 characters after trimming. Pricing variants additionally require `offerSetId` as a UUID.
42
42
 
43
43
  Metrics are exactly `step_completion`, `next_step_reached`, `checkout_opened`, `funnel_completed`, or `paying_customer`.
44
44
 
@@ -112,7 +112,7 @@ Like `step`, every variant has a route target. Use `type: "paywall"` when the ro
112
112
 
113
113
  ### Pricing experiment
114
114
 
115
- Each pricing variant also requires a non-empty `offerSetKey`, and every `routeToStepId` must exactly equal the top-level `stepId`.
115
+ Each pricing variant also requires the immutable UUID `offerSetId` of an active offer set in the same project. Every `routeToStepId` must exactly equal the top-level `stepId`.
116
116
 
117
117
  ```json
118
118
  {
@@ -132,7 +132,7 @@ Each pricing variant also requires a non-empty `offerSetKey`, and every `routeTo
132
132
  "routeToStepId": "paywall",
133
133
  "trafficPercent": 50,
134
134
  "isControl": true,
135
- "offerSetKey": "default-paywall"
135
+ "offerSetId": "11111111-1111-4111-8111-111111111111"
136
136
  },
137
137
  {
138
138
  "variantKey": "annual_focus",
@@ -140,7 +140,7 @@ Each pricing variant also requires a non-empty `offerSetKey`, and every `routeTo
140
140
  "routeToStepId": "paywall",
141
141
  "trafficPercent": 50,
142
142
  "isControl": false,
143
- "offerSetKey": "annual-focus"
143
+ "offerSetId": "22222222-2222-4222-8222-222222222222"
144
144
  }
145
145
  ]
146
146
  }
@@ -156,13 +156,15 @@ Creation always produces a draft. It does not create or activate a PostHog flag,
156
156
  fgrove experiments start <experiment-uuid>
157
157
  fgrove experiments stop <experiment-uuid>
158
158
  fgrove experiments restart <experiment-uuid>
159
+ fgrove experiments end <experiment-uuid>
160
+ fgrove experiments delete <experiment-uuid>
159
161
  ```
160
162
 
161
- `stop` is reversible: it pauses traffic and keeps the experiment, variants, and PostHog flag available for a later `start`. `restart` stops a running experiment when necessary and starts it again while preserving the existing definition. Each command updates PostHog and commits the final experiment status to the hosted generated funnel config. Use `--json` for agent-readable output. Run `fgrove experiments sync` afterward when the local generated config also needs to reflect the lifecycle change.
163
+ `stop` is reversible: it pauses traffic and keeps the experiment, variants, and PostHog flag available for a later `start`. `restart` stops a running experiment when necessary and starts it again while preserving the existing definition. `end` permanently archives the experiment; `delete` removes a draft. Each command updates PostHog when required and persists the final status in the control plane. Use `--json` for agent-readable output.
162
164
 
163
- The corresponding authenticated API mutations are `funnelExperiments.start`, `funnelExperiments.stop`, and `funnelExperiments.restart`; each accepts `{ "id": "<experiment-uuid>" }`.
165
+ The corresponding authenticated API mutations are agent-only. Normal browser sessions cannot call experiment lifecycle mutations.
164
166
 
165
- The API creates the experiment and variants atomically, commits the matching generated snapshot to the hosted draft, and only then returns. The draft is immediately visible in the FunnelsGrove UI and hosted previews use the same snapshot. The CLI installs the exact returned bytes at `src/config/experiments.generated.ts` and `src/config/experiments.ts`, then updates the sync manifest last. `.funnelsgrove-sync.json` stays local and ignored; never commit or push it.
167
+ The API creates the experiment and variants atomically through ordinary data services. Experiments are stored in the control plane and included in the version-bound runtime artifact when the funnel is published. `src/config/experiments.generated.ts` and `src/config/experiments.ts` are deprecated compatibility files: new funnels and experiment creation do not generate, install, or update them.
166
168
 
167
169
  ## Recovery and errors
168
170
 
@@ -170,8 +172,7 @@ The API creates the experiment and variants atomically, commits the matching gen
170
172
  - Invalid local JSON or `[FG-EXPERIMENT-SPEC]`: fix the reported field and retry with the same stable `id`.
171
173
  - `[FG-EXPERIMENT-STALE-DRAFT]`: do not overwrite remote work. Download the latest draft into a clean temporary directory, merge deliberately, rerun validation, and retry the same exact spec.
172
174
  - `[FG-EXPERIMENT-DRAFT-CONFLICT]`: the stable key already belongs to a different definition, owner, or lifecycle state. Reuse the original exact definition for a retry, or choose a new stable `id` only for a genuinely new experiment.
173
- - Locally changed generated experiment files are never overwritten. Resolve those edits before retrying.
174
- - If the API succeeded but the process stopped, retry safely with the same `id`. A ready local journal is automatically recovered before the next create or sync command; an interruption before the journal simply repeats the exact API request.
175
+ - If the API succeeded but the process stopped, retry safely with the same `id`; no source transaction is required.
175
176
 
176
177
  ## Validate and deliver
177
178
 
@@ -184,7 +185,7 @@ git status --short
184
185
 
185
186
  For a funnel without GitHub source sync, deliver all local source changes with `fgrove sync up`.
186
187
 
187
- For a GitHub-connected funnel, commit and push the generated source files with the rest of the source change, then run `fgrove github pull`. Never use `fgrove sync up` for the same GitHub-connected diff, and never add `.funnelsgrove-sync.json` to git.
188
+ For a GitHub-connected funnel, commit and push only the variant step or offer-set source changes, then run `fgrove github pull`. The experiment itself is stored in the control plane and does not create a source file. Never use `fgrove sync up` for the same GitHub-connected diff; `.funnelsgrove-sync.json` stays local and ignored.
188
189
 
189
190
  ## Pre-activation QA
190
191
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "bundleVersion": "2.0.41",
3
+ "bundleVersion": "2.0.51",
4
4
  "contractSource": "funnelsgrove-repository://apps/funnel-runtime/contracts/step-contract-v2.json",
5
5
  "fullyGenerated": [
6
6
  ".funnelsgrove-docs.json",
@@ -5,7 +5,7 @@
5
5
  "managedFiles": [
6
6
  {
7
7
  "path": "src/contract/funnel-project.validation.ts",
8
- "sha256": "b0ec02eac1bd56812eef773be71628ae4e94f80fcd88837bbc5c8bf04e73a62c"
8
+ "sha256": "99299cfb96414dd24272439cd1c57191a0863749c920a5eb03ff786f7972ab0e"
9
9
  },
10
10
  {
11
11
  "path": "src/contract/funnel-validator.vite.config.ts",