@@ -12,7 +12,7 @@ import {
1212 statSync ,
1313 writeFileSync ,
1414} from 'node:fs' ;
15- import { dirname , isAbsolute , join , relative , resolve } from 'node:path' ;
15+ import { dirname , join , relative } from 'node:path' ;
1616import { fileURLToPath , pathToFileURL } from 'node:url' ;
1717import { jsonSchema , tool , type ToolSet } from 'ai' ;
1818import { parseEvalMarkdown } from '@supabase-evals/core/eval-markdown' ;
@@ -32,6 +32,7 @@ import {
3232} from '../lib/cli-args.js' ;
3333import { bootPlatformBackend } from './platform-backend.js' ;
3434import { viteBuild , vitestRun } from './project-runner.js' ;
35+ import { resolveMcpServerPath , validateContentApi } from './mcp-launch.js' ;
3536import {
3637 buildDocsResult ,
3738 buildSkillResult ,
@@ -73,6 +74,7 @@ const SMOKE = args.has('--smoke');
7374const DRY = args . has ( '--dry' ) ;
7475const STRICT = args . has ( '--strict' ) ;
7576const MCP_PATH = readFlag ( rawArgs , 'mcp' ) ;
77+ const CONTENT_API_URL = readFlag ( rawArgs , 'content-api' ) ;
7678const EXPERIMENT_FILTERS = readRepeatedFlag ( rawArgs , 'experiment' ) . map (
7779 normalizeExperimentName
7880) ;
@@ -641,6 +643,7 @@ type Provenance = {
641643 generatedAt : string ;
642644 host : { sha ?: string ; branch ?: string ; dirtyFiles : number } ;
643645 mcpOverride ?: { path : string ; sha ?: string ; dirtyFiles ?: number } ;
646+ contentApiUrl ?: string ;
644647 platform : string ;
645648} ;
646649
@@ -654,7 +657,10 @@ function tryGit(args: string[], cwd: string): string | undefined {
654657 }
655658}
656659
657- function collectProvenance ( mcpPath ?: string ) : Provenance {
660+ function collectProvenance (
661+ mcpPath ?: string ,
662+ contentApiUrl ?: string
663+ ) : Provenance {
658664 const dirty = ( cwd : string ) =>
659665 ( tryGit ( [ 'status' , '--porcelain' ] , cwd ) ?? '' ) . split ( '\n' ) . filter ( Boolean )
660666 . length ;
@@ -675,34 +681,10 @@ function collectProvenance(mcpPath?: string): Provenance {
675681 dirtyFiles : repository ? dirty ( repository ) : undefined ,
676682 } ;
677683 }
684+ if ( contentApiUrl ) provenance . contentApiUrl = contentApiUrl ;
678685 return provenance ;
679686}
680687
681- function resolveMcpServerPath ( raw : string ) : string {
682- let path = isAbsolute ( raw ) ? raw : resolve ( process . cwd ( ) , raw ) ;
683- if ( ! existsSync ( path ) ) throw new Error ( `--mcp path does not exist: ${ path } ` ) ;
684- const packageDir = join ( path , 'packages' , 'mcp-server-supabase' ) ;
685- if ( existsSync ( packageDir ) ) path = packageDir ;
686- if ( ! existsSync ( join ( path , 'dist' , 'transports' , 'stdio.js' ) ) ) {
687- throw new Error (
688- `no built server at ${ path } (dist/transports/stdio.js missing) — build it first:\n pnpm install && pnpm build`
689- ) ;
690- }
691- try {
692- const localVersion = JSON . parse (
693- readFileSync ( join ( path , 'package.json' ) , 'utf8' )
694- ) . version ;
695- if ( localVersion && localVersion !== MCP_SERVER_VERSION ) {
696- console . error (
697- `note: local mcp build is v${ localVersion } ; the harness fixture (platform-lite) tracks the v${ MCP_SERVER_VERSION } pin — endpoint drift is possible`
698- ) ;
699- }
700- } catch {
701- // An unversioned checkout is valid when it has the expected built entry.
702- }
703- return realpathSync ( path ) ;
704- }
705-
706688function validateJudgeKeys ( evals : readonly EvalManifest [ ] ) {
707689 if ( process . env . OPENAI_API_KEY || DRY ) return ;
708690 const judged = evals
@@ -781,6 +763,10 @@ async function main() {
781763
782764 const mcpPath = MCP_PATH ? resolveMcpServerPath ( MCP_PATH ) : undefined ;
783765 if ( mcpPath ) process . env . SUPABASE_MCP_SERVER_PATH = mcpPath ;
766+ if ( CONTENT_API_URL ) {
767+ validateContentApi ( CONTENT_API_URL , mcpPath ) ;
768+ process . env . SUPABASE_CONTENT_API_URL = CONTENT_API_URL ;
769+ }
784770
785771 const allExperiments = await loadExperiments ( ) ;
786772 if ( EXPERIMENT_FILTERS . length > 0 ) {
@@ -916,7 +902,7 @@ async function main() {
916902
917903 validateJudgeKeys ( [ ...new Set ( allWork . map ( ( { ev } ) => ev ) ) ] ) ;
918904 if ( ! DEBUG ) console . error = ( ) => undefined ;
919- const provenance = collectProvenance ( mcpPath ) ;
905+ const provenance = collectProvenance ( mcpPath , CONTENT_API_URL ) ;
920906
921907 let localStackTurn = Promise . resolve ( ) ;
922908 const errored : Error [ ] = [ ] ;
0 commit comments