@skyramp/mcp 0.2.5 → 0.2.7
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.
- package/build/commands/commandLibrary.d.ts +12 -0
- package/build/commands/recommendTestsAndExecuteCommand.d.ts +2 -0
- package/build/commands/testThisEndpointCommand.d.ts +2 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +1 -2
- package/build/playwright/PlaywrightTraceService.d.ts +32 -0
- package/build/playwright/index.d.ts +3 -0
- package/build/playwright/registerPlaywrightTools.d.ts +8 -0
- package/build/playwright/registerPlaywrightTools.js +12 -11
- package/build/playwright/traceRecordingPrompt.d.ts +13 -0
- package/build/playwright/traceRecordingPrompt.js +3 -11
- package/build/prompts/code-reuse.d.ts +1 -0
- package/build/prompts/enhance-assertions/contractProviderAssertionsPrompt.d.ts +2 -0
- package/build/prompts/enhance-assertions/integrationAssertionsPrompt.d.ts +2 -0
- package/build/prompts/enhance-assertions/sharedAssertionRules.d.ts +15 -0
- package/build/prompts/enhance-assertions/uiAssertionsPrompt.d.ts +2 -0
- package/build/prompts/enhance-assertions/uiAssertionsPrompt.js +14 -3
- package/build/prompts/fix-error-prompt.d.ts +1 -0
- package/build/prompts/initialize-workspace/initializeWorkspacePrompt.d.ts +1 -0
- package/build/prompts/modularization/integration-test-modularization.d.ts +1 -0
- package/build/prompts/modularization/ui-test-modularization.d.ts +1 -0
- package/build/prompts/personas.d.ts +21 -0
- package/build/prompts/pom-aware-code-reuse.d.ts +1 -0
- package/build/prompts/startTraceCollectionPrompts.d.ts +2 -0
- package/build/prompts/test-maintenance/actionsInstructions.d.ts +35 -0
- package/build/prompts/test-maintenance/drift-analysis-prompt.d.ts +4 -0
- package/build/prompts/test-maintenance/driftAnalysisSections.d.ts +13 -0
- package/build/prompts/test-recommendation/analysisOutputPrompt.d.ts +84 -0
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.d.ts +1 -0
- package/build/prompts/test-recommendation/analysisOutputPrompt.test.js +1 -0
- package/build/prompts/test-recommendation/diffExecutionPlan.d.ts +17 -0
- package/build/prompts/test-recommendation/diffExecutionPlan.js +7 -16
- package/build/prompts/test-recommendation/fullRepoCatalog.d.ts +7 -0
- package/build/prompts/test-recommendation/mergeEnrichedScenarios.test.d.ts +1 -0
- package/build/prompts/test-recommendation/mergeEnrichedScenarios.test.js +1 -0
- package/build/prompts/test-recommendation/promptPlan.d.ts +203 -0
- package/build/prompts/test-recommendation/promptPlan.test.d.ts +1 -0
- package/build/prompts/test-recommendation/recommendationSections.d.ts +35 -0
- package/build/prompts/test-recommendation/recommendationShared.d.ts +31 -0
- package/build/prompts/test-recommendation/registerRecommendTestsPrompt.d.ts +7 -0
- package/build/prompts/test-recommendation/scopeAssessment.d.ts +55 -0
- package/build/prompts/test-recommendation/scopeAssessment.js +2 -2
- package/build/prompts/test-recommendation/scopeAssessment.test.d.ts +1 -0
- package/build/prompts/test-recommendation/scopeAssessment.test.js +1 -0
- package/build/prompts/test-recommendation/test-recommendation-prompt.d.ts +6 -0
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +4 -4
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.d.ts +1 -0
- package/build/prompts/test-recommendation/test-recommendation-prompt.test.js +6 -99
- package/build/prompts/testbot/testbot-prompts.d.ts +11 -0
- package/build/prompts/testbot/testbot-prompts.js +198 -34
- package/build/prompts/testbot/testbot-prompts.test.d.ts +1 -0
- package/build/prompts/testbot/testbot-prompts.test.js +15 -73
- package/build/resources/analysisResources.d.ts +17 -0
- package/build/resources/progressResource.d.ts +2 -0
- package/build/resources/testbotResource.d.ts +2 -0
- package/build/services/AnalyticsService.d.ts +13 -0
- package/build/services/AnalyticsService.test.d.ts +1 -0
- package/build/services/AnalyticsService.test.js +86 -0
- package/build/services/ModularizationService.d.ts +11 -0
- package/build/services/ScenarioGenerationService.d.ts +37 -0
- package/build/services/ScenarioGenerationService.integration.test.d.ts +1 -0
- package/build/services/ScenarioGenerationService.integration.test.js +4 -0
- package/build/services/ScenarioGenerationService.test.d.ts +1 -0
- package/build/services/TestDiscoveryService.d.ts +128 -0
- package/build/services/TestDiscoveryService.test.d.ts +1 -0
- package/build/services/TestDiscoveryService.test.js +4 -3
- package/build/services/TestExecutionService.d.ts +46 -0
- package/build/services/TestExecutionService.test.d.ts +1 -0
- package/build/services/TestExecutionService.test.js +33 -25
- package/build/services/TestGenerationService.d.ts +56 -0
- package/build/services/TestGenerationService.test.d.ts +1 -0
- package/build/services/TestGenerationService.test.js +10 -8
- package/build/services/containerEnv.d.ts +14 -0
- package/build/tool-phase-coverage.test.d.ts +1 -0
- package/build/tool-phase-coverage.test.js +2 -0
- package/build/tool-phases.d.ts +38 -0
- package/build/tools/auth/loginTool.d.ts +2 -0
- package/build/tools/auth/logoutTool.d.ts +2 -0
- package/build/tools/code-refactor/codeReuseTool.d.ts +2 -0
- package/build/tools/code-refactor/enhanceAssertionsTool.d.ts +2 -0
- package/build/tools/code-refactor/modularizationTool.d.ts +2 -0
- package/build/tools/executeSkyrampTestTool.d.ts +2 -0
- package/build/tools/fixErrorTool.d.ts +2 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.d.ts +45 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.test.d.ts +1 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.test.js +11 -9
- package/build/tools/generate-tests/generateContractRestTool.d.ts +31 -0
- package/build/tools/generate-tests/generateE2ERestTool.d.ts +13 -0
- package/build/tools/generate-tests/generateFuzzRestTool.d.ts +10 -0
- package/build/tools/generate-tests/generateIntegrationRestTool.d.ts +16 -0
- package/build/tools/generate-tests/generateLoadRestTool.d.ts +18 -0
- package/build/tools/generate-tests/generateLoadRestTool.test.d.ts +1 -0
- package/build/tools/generate-tests/generateMockRestTool.d.ts +64 -0
- package/build/tools/generate-tests/generateSmokeRestTool.d.ts +8 -0
- package/build/tools/generate-tests/generateUIRestTool.d.ts +14 -0
- package/build/tools/generate-tests/generateUIRestTool.js +1 -1
- package/build/tools/generate-tests/loadTestSchema.d.ts +39 -0
- package/build/tools/one-click/oneClickTool.d.ts +11 -0
- package/build/tools/submitReportTool.d.ts +384 -0
- package/build/tools/submitReportTool.js +144 -2
- package/build/tools/submitReportTool.test.d.ts +1 -0
- package/build/tools/submitReportTool.test.js +215 -5
- package/build/tools/test-management/actionsTool.d.ts +10 -0
- package/build/tools/test-management/analyzeChangesTool.d.ts +27 -0
- package/build/tools/test-management/analyzeChangesTool.js +44 -7
- package/build/tools/test-management/analyzeChangesTool.test.d.ts +1 -0
- package/build/tools/test-management/analyzeChangesTool.test.js +76 -39
- package/build/tools/test-management/analyzeTestHealthTool.d.ts +2 -0
- package/build/tools/test-management/index.d.ts +3 -0
- package/build/tools/test-management/index.js +0 -1
- package/build/tools/trace/resolveSaveStoragePath.d.ts +7 -0
- package/build/tools/trace/resolveSaveStoragePath.test.d.ts +1 -0
- package/build/tools/trace/resolveSessionPaths.d.ts +40 -0
- package/build/tools/trace/resolveSessionPaths.test.d.ts +1 -0
- package/build/tools/trace/sessionState.d.ts +2 -0
- package/build/tools/trace/sessionState.test.d.ts +1 -0
- package/build/tools/trace/startTraceCollectionTool.d.ts +2 -0
- package/build/tools/trace/stopTraceCollectionTool.d.ts +2 -0
- package/build/tools/workspace/initScanWorkspaceTool.d.ts +4 -0
- package/build/tools/workspace/initializeWorkspaceTool.d.ts +2 -0
- package/build/tools/workspace/initializeWorkspaceTool.test.d.ts +1 -0
- package/build/tools/workspace/initializeWorkspaceTool.test.js +134 -0
- package/build/types/OneClickCommands.d.ts +68 -0
- package/build/types/RepositoryAnalysis.d.ts +3004 -0
- package/build/types/TestAnalysis.d.ts +96 -0
- package/build/types/TestExecution.d.ts +53 -0
- package/build/types/TestRecommendation.d.ts +12 -0
- package/build/types/TestTypes.d.ts +234 -0
- package/build/utils/AnalysisStateManager.d.ts +182 -0
- package/build/utils/AnalysisStateManager.test.d.ts +1 -0
- package/build/utils/analyze-openapi.d.ts +1 -0
- package/build/utils/branchDiff.d.ts +18 -0
- package/build/utils/dartRouteExtractor.d.ts +45 -0
- package/build/utils/dartRouteExtractor.test.d.ts +1 -0
- package/build/utils/docker.d.ts +19 -0
- package/build/utils/docker.test.d.ts +1 -0
- package/build/utils/docker.test.js +10 -9
- package/build/utils/featureFlags.d.ts +37 -0
- package/build/utils/featureFlags.test.d.ts +1 -0
- package/build/utils/gitStaging.d.ts +24 -0
- package/build/utils/gitStaging.test.d.ts +1 -0
- package/build/utils/gitStaging.test.js +13 -7
- package/build/utils/httpDefaults.d.ts +10 -0
- package/build/utils/httpDefaults.test.d.ts +1 -0
- package/build/utils/initAgent.d.ts +36 -0
- package/build/utils/language-helper.d.ts +6 -0
- package/build/utils/logger.d.ts +11 -0
- package/build/utils/normalizeParams.d.ts +14 -0
- package/build/utils/normalizeSkyrampImports.d.ts +13 -0
- package/build/utils/pr-comment-parser.d.ts +31 -0
- package/build/utils/pr-comment-parser.test.d.ts +1 -0
- package/build/utils/pr-comment-parser.test.js +6 -5
- package/build/utils/projectMetadata.d.ts +15 -0
- package/build/utils/projectMetadata.test.d.ts +1 -0
- package/build/utils/proxy-terminal.d.ts +2 -0
- package/build/utils/repoScanner.d.ts +27 -0
- package/build/utils/repoScanner.test.d.ts +1 -0
- package/build/utils/routeParsers.d.ts +63 -0
- package/build/utils/routeParsers.test.d.ts +1 -0
- package/build/utils/scenarioDrafting.d.ts +71 -0
- package/build/utils/scenarioDrafting.test.d.ts +1 -0
- package/build/utils/skyrampMdContent.d.ts +5 -0
- package/build/utils/sourceRouteExtractor.d.ts +48 -0
- package/build/utils/sourceRouteExtractor.test.d.ts +1 -0
- package/build/utils/telemetry.d.ts +32 -0
- package/build/utils/telemetry.test.d.ts +1 -0
- package/build/utils/trace-parser.d.ts +32 -0
- package/build/utils/trace-parser.test.d.ts +6 -0
- package/build/utils/uiPageEnumerator.d.ts +146 -0
- package/build/utils/uiPageEnumerator.js +58 -14
- package/build/utils/uiPageEnumerator.test.d.ts +1 -0
- package/build/utils/uiPageEnumerator.test.js +223 -43
- package/build/utils/utils.d.ts +39 -0
- package/build/utils/utils.test.d.ts +1 -0
- package/build/utils/versions.d.ts +3 -0
- package/build/utils/versions.js +1 -1
- package/build/utils/workspaceAuth.d.ts +127 -0
- package/build/utils/workspaceAuth.test.d.ts +1 -0
- package/build/utils/workspaceAuth.test.js +25 -25
- package/build/workspace/index.d.ts +1 -0
- package/build/workspace/workspace.d.ts +390 -0
- package/build/workspace/workspace.test.d.ts +1 -0
- package/node_modules/playwright/lib/mcp/skyramp/traceRecordingBackend.js +14 -2
- package/package.json +8 -3
- package/build/tools/test-management/uiAnalyzeChangesTool.js +0 -155
- package/build/tools/test-management/uiAnalyzeChangesTool.test.js +0 -147
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic UI page enumeration — translates "which frontend files changed"
|
|
3
|
+
* into "which URLs should the agent capture blueprints for."
|
|
4
|
+
*
|
|
5
|
+
* Replaces the prose-driven Task 0 strategy ladder in the testbot prompt with
|
|
6
|
+
* deterministic code so the candidate page list lives in the stateFile and is
|
|
7
|
+
* reusable across analyze_changes consumers (testbot, analyze_test_health,
|
|
8
|
+
* future blueprint-grounded recommenders).
|
|
9
|
+
*
|
|
10
|
+
* Strategies, tried in order:
|
|
11
|
+
*
|
|
12
|
+
* Strategy 1 — Framework route grep
|
|
13
|
+
* Translate file-system-routed component paths directly to URLs. Covers
|
|
14
|
+
* Next.js (app/ and pages/), Nuxt / Vue Router file-based, and SvelteKit.
|
|
15
|
+
* Gated on detection of a framework config file in the repo.
|
|
16
|
+
*
|
|
17
|
+
* Strategy 2 — Source-grounded routes
|
|
18
|
+
* Walks router/App files with the TS Compiler API for code-defined
|
|
19
|
+
* route declarations like `<Route path="/cart" element={<Cart/>}>`.
|
|
20
|
+
* Matches each route's component file OR declaration file against the
|
|
21
|
+
* changed-file list (so router rewrites surface their routes even when
|
|
22
|
+
* the component itself is unchanged). Handles React Router string-literal
|
|
23
|
+
* paths, cross-file constant resolution, Vue Router object literals,
|
|
24
|
+
* and Directus `defineModule` aggregation. See `sourceRouteExtractor.ts`.
|
|
25
|
+
*
|
|
26
|
+
* Strategy 3 — Root fallback
|
|
27
|
+
* Read the workspace's frontend baseUrl and treat it as the single
|
|
28
|
+
* candidate page. Always available when a frontend service is configured.
|
|
29
|
+
*/
|
|
30
|
+
export type CandidateUiPageStrategy = "framework-route-grep" | "source-grounded-routes" | "dart-go-router" | "root-fallback";
|
|
31
|
+
export interface CandidateUiPage {
|
|
32
|
+
/** Fully qualified URL (workspace baseUrl + framework-derived path). */
|
|
33
|
+
url: string;
|
|
34
|
+
/** Source files that suggested this page (for traceability). */
|
|
35
|
+
sourcedFrom: string[];
|
|
36
|
+
/** Which strategy enumerated it. */
|
|
37
|
+
strategy: CandidateUiPageStrategy;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* File-system → URL mapping for filesystem-routed frameworks.
|
|
41
|
+
*
|
|
42
|
+
* Returns the URL path (no host) when the file is a route entrypoint, or
|
|
43
|
+
* null when the file isn't a route in any recognized convention.
|
|
44
|
+
*
|
|
45
|
+
* The `null` cases include component files used by routes (e.g. shared
|
|
46
|
+
* widgets in `components/`), API handlers (e.g. Next.js `pages/api/*`),
|
|
47
|
+
* and arbitrary `.ts`/`.js` modules under frontend directories. These
|
|
48
|
+
* are picked up by strategy 2 (import-graph walk, future) or by strategy
|
|
49
|
+
* 3 (root fallback).
|
|
50
|
+
*/
|
|
51
|
+
export declare function frameworkFileToUrlPath(filePath: string): string | null;
|
|
52
|
+
/**
|
|
53
|
+
* Detect whether the repository is configured for filesystem-based routing.
|
|
54
|
+
*
|
|
55
|
+
* Strategy 1 maps file paths to URLs based on conventions (Next.js Pages
|
|
56
|
+
* Router, Nuxt, SvelteKit). Without a positive signal that the framework
|
|
57
|
+
* is actually configured, a repo that just *happens* to have a `pages/`
|
|
58
|
+
* directory (e.g. React with conventional layout, Vue with route-config
|
|
59
|
+
* code) produces false-positive URLs. This guard suppresses strategy 1
|
|
60
|
+
* for those repos so they fall through to root-fallback.
|
|
61
|
+
*
|
|
62
|
+
* Looks for framework config files in the repo root, common subdirectories,
|
|
63
|
+
* and the `frontendFiles[]`-derived candidate frontend roots.
|
|
64
|
+
*/
|
|
65
|
+
export declare function detectsFilesystemRouting(repositoryPath: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Strategy 1 implementation. Filters frontend files through the framework
|
|
68
|
+
* route mapper; collects the URL paths that mapped successfully.
|
|
69
|
+
*
|
|
70
|
+
* Suppressed when the repo doesn't have a recognized filesystem-routing
|
|
71
|
+
* framework config — see `detectsFilesystemRouting`. Without that guard,
|
|
72
|
+
* repos with conventional `pages/` directories but code-defined routes
|
|
73
|
+
* (e.g. React with React Router) produce false-positive URLs.
|
|
74
|
+
*/
|
|
75
|
+
export declare function findCandidatePagesByFrameworkRoute(frontendFiles: string[], baseUrl: string, repositoryPath?: string): CandidateUiPage[];
|
|
76
|
+
/**
|
|
77
|
+
* Strategy 2 implementation. Walks router/App files with the TS Compiler API
|
|
78
|
+
* to find route declarations (`<Route path="/cart" element={<Cart/>}>`),
|
|
79
|
+
* matches each declaration's component file against the changed-file list,
|
|
80
|
+
* and emits one CandidateUiPage per matching route.
|
|
81
|
+
*
|
|
82
|
+
* Slice 3a covers string-literal `path` attributes only — `path={CONST}` and
|
|
83
|
+
* Vue Router object literals are deferred to slice 3b.
|
|
84
|
+
*
|
|
85
|
+
* Returns empty when no route declarations match the changed files (which is
|
|
86
|
+
* also the right answer for SPAs without client-side routing — they fall
|
|
87
|
+
* through to root-fallback).
|
|
88
|
+
*/
|
|
89
|
+
export declare function findCandidatePagesBySourceRoute(frontendFiles: string[], baseUrl: string, repositoryPath: string): CandidateUiPage[];
|
|
90
|
+
/**
|
|
91
|
+
* Strategy 2.5: walk the repo's Dart files for GoRoute(path: '...') calls.
|
|
92
|
+
* Gated on `hasFlutterSdkDep(repoPath)` so non-Flutter Dart projects (e.g.
|
|
93
|
+
* shelf_router servers) don't accidentally emit URLs.
|
|
94
|
+
*
|
|
95
|
+
* Diff-matching: each GoRoute references its screen widget via
|
|
96
|
+
* `builder:`/`pageBuilder:` (e.g. `AuthorsScreen`). The extractor resolves
|
|
97
|
+
* those identifiers through the route file's imports to absolute screen
|
|
98
|
+
* file paths. We surface only routes whose screen file appears in the
|
|
99
|
+
* changed-file list. Falls back to all-routes when no route's screen
|
|
100
|
+
* file matches — preserves coverage for "router untouched, screen edited"
|
|
101
|
+
* cases when the import-resolution heuristic doesn't find a match.
|
|
102
|
+
*
|
|
103
|
+
* Filters applied:
|
|
104
|
+
* 1. Drop redirect-only routes (`redirect:` with no `builder:`/`pageBuilder:`).
|
|
105
|
+
* These have no UI to render — navigating there is wasted work.
|
|
106
|
+
* 2. Drop nested relative children (paths that don't start with `/`).
|
|
107
|
+
* Without parent-path composition the URL is meaningless.
|
|
108
|
+
*
|
|
109
|
+
* Returns empty when the repo isn't Flutter or no GoRoute calls are
|
|
110
|
+
* found — caller falls through to root-fallback.
|
|
111
|
+
*/
|
|
112
|
+
export declare function findCandidatePagesByDartRoute(repositoryPath: string, baseUrl: string, frontendFiles: string[]): CandidateUiPage[];
|
|
113
|
+
/**
|
|
114
|
+
* Strategy 3: when strategies 1+2 yield nothing, fall back to the workspace's
|
|
115
|
+
* frontend baseUrl as the single candidate page. The agent's downstream
|
|
116
|
+
* explore-and-discover step can then surface gated UI from the root.
|
|
117
|
+
*
|
|
118
|
+
* Returns null when the workspace has no recognizable frontend service.
|
|
119
|
+
*/
|
|
120
|
+
export declare function findRootFallbackPage(repositoryPath: string): Promise<CandidateUiPage | null>;
|
|
121
|
+
/**
|
|
122
|
+
* Resolves the frontend service's baseUrl from the workspace config.
|
|
123
|
+
*
|
|
124
|
+
* Returns the baseUrl string with environment variable override precedence:
|
|
125
|
+
* 1. Per-service override: `SKYRAMP_TEST_SERVICE_URL_<NAME>` (where <NAME>
|
|
126
|
+
* is the picked frontend service's serviceName, sanitized via
|
|
127
|
+
* `sanitizeServiceName`)
|
|
128
|
+
* 2. Global override: `SKYRAMP_TEST_BASE_URL` (single service or all
|
|
129
|
+
* services share one URL)
|
|
130
|
+
* 3. Static workspace.yml value: `api.baseUrl` from the picked frontend
|
|
131
|
+
* service
|
|
132
|
+
*
|
|
133
|
+
* Returns null when no service has a usable URL.
|
|
134
|
+
*
|
|
135
|
+
* Exported (vs private) so analyze_changes and future tools can reuse the
|
|
136
|
+
* same selection without re-implementing it.
|
|
137
|
+
*/
|
|
138
|
+
export declare function pickFrontendBaseUrl(repositoryPath: string): Promise<string | null>;
|
|
139
|
+
/**
|
|
140
|
+
* Run the strategy ladder in order: framework route grep (1) → source-grounded
|
|
141
|
+
* routes (2) → root fallback (3). Each strategy is consulted only if the
|
|
142
|
+
* previous one produced no candidates. Returns whatever the ladder produces
|
|
143
|
+
* (possibly empty if the workspace has no frontend baseUrl AND none of the
|
|
144
|
+
* earlier strategies matched).
|
|
145
|
+
*/
|
|
146
|
+
export declare function enumerateCandidateUiPages(repositoryPath: string, frontendFiles: string[]): Promise<CandidateUiPage[]>;
|
|
@@ -311,31 +311,38 @@ export async function findRootFallbackPage(repositoryPath) {
|
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
/**
|
|
314
|
-
*
|
|
314
|
+
* Mirror of testbot.git src/services.ts exportServiceBaseUrlEnvVars sanitize().
|
|
315
|
+
* Keep in sync with that function (separate repo, cannot share code).
|
|
316
|
+
*
|
|
317
|
+
* Transforms a service name into the corresponding env var suffix:
|
|
318
|
+
* `supabase-nextjs` → `SUPABASE_NEXTJS`
|
|
319
|
+
* `my.app` → `MY_APP`
|
|
320
|
+
* `proto://app` → `PROTO___APP`
|
|
321
|
+
*/
|
|
322
|
+
function sanitizeServiceName(name) {
|
|
323
|
+
return name.toUpperCase().replace(/[-.:\/]/g, "_");
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Extracted from pickFrontendBaseUrl: returns the chosen frontend service
|
|
327
|
+
* object (not the URL). Implements the original heuristics unchanged.
|
|
315
328
|
*
|
|
316
329
|
* Heuristics, in order:
|
|
317
|
-
* 1. Service whose `serviceName`
|
|
330
|
+
* 1. Service whose `serviceName` contains a frontend token (`frontend`,
|
|
331
|
+
* `ui`, `app`, or `web`) as a `-`/`_`-delimited word
|
|
318
332
|
* 2. Service whose `language` is `typescript` / `javascript` AND whose
|
|
319
333
|
* `framework` is one of the common UI frameworks (react, vue, svelte,
|
|
320
334
|
* next, nuxt, etc.)
|
|
321
335
|
* 3. First service with a defined `api.baseUrl`
|
|
322
336
|
*
|
|
323
|
-
* Returns the
|
|
324
|
-
*
|
|
325
|
-
* Exported (vs private) so analyze_changes and future tools can reuse the
|
|
326
|
-
* same selection without re-implementing it.
|
|
337
|
+
* Returns the service object or null when no service has a usable URL.
|
|
327
338
|
*/
|
|
328
|
-
|
|
329
|
-
const config = await readWorkspaceConfigRaw(repositoryPath);
|
|
330
|
-
if (!config?.services || !Array.isArray(config.services))
|
|
331
|
-
return null;
|
|
332
|
-
const services = config.services;
|
|
339
|
+
function pickFrontendService(services) {
|
|
333
340
|
// Heuristic 1: serviceName signals frontend.
|
|
334
341
|
const byName = services.find((s) => typeof s?.serviceName === "string" &&
|
|
335
342
|
/(?:^|[-_])frontend(?:[-_]|$)|(?:^|[-_])ui(?:[-_]|$)|(?:^|[-_])app(?:[-_]|$)|(?:^|[-_])web(?:[-_]|$)/.test(s.serviceName.toLowerCase()) &&
|
|
336
343
|
s?.api?.baseUrl);
|
|
337
344
|
if (byName)
|
|
338
|
-
return byName
|
|
345
|
+
return byName;
|
|
339
346
|
// Heuristic 2: language + framework signal frontend.
|
|
340
347
|
const FRONTEND_FRAMEWORKS = new Set([
|
|
341
348
|
"react", "vue", "svelte", "next", "nextjs", "nuxt", "sveltekit",
|
|
@@ -349,10 +356,47 @@ export async function pickFrontendBaseUrl(repositoryPath) {
|
|
|
349
356
|
s?.api?.baseUrl);
|
|
350
357
|
});
|
|
351
358
|
if (byFramework)
|
|
352
|
-
return byFramework
|
|
359
|
+
return byFramework;
|
|
353
360
|
// Heuristic 3: first service with a baseUrl.
|
|
354
361
|
const anyBase = services.find((s) => s?.api?.baseUrl);
|
|
355
|
-
return anyBase
|
|
362
|
+
return anyBase ?? null;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Resolves the frontend service's baseUrl from the workspace config.
|
|
366
|
+
*
|
|
367
|
+
* Returns the baseUrl string with environment variable override precedence:
|
|
368
|
+
* 1. Per-service override: `SKYRAMP_TEST_SERVICE_URL_<NAME>` (where <NAME>
|
|
369
|
+
* is the picked frontend service's serviceName, sanitized via
|
|
370
|
+
* `sanitizeServiceName`)
|
|
371
|
+
* 2. Global override: `SKYRAMP_TEST_BASE_URL` (single service or all
|
|
372
|
+
* services share one URL)
|
|
373
|
+
* 3. Static workspace.yml value: `api.baseUrl` from the picked frontend
|
|
374
|
+
* service
|
|
375
|
+
*
|
|
376
|
+
* Returns null when no service has a usable URL.
|
|
377
|
+
*
|
|
378
|
+
* Exported (vs private) so analyze_changes and future tools can reuse the
|
|
379
|
+
* same selection without re-implementing it.
|
|
380
|
+
*/
|
|
381
|
+
export async function pickFrontendBaseUrl(repositoryPath) {
|
|
382
|
+
const config = await readWorkspaceConfigRaw(repositoryPath);
|
|
383
|
+
if (!config?.services || !Array.isArray(config.services))
|
|
384
|
+
return null;
|
|
385
|
+
const picked = pickFrontendService(config.services);
|
|
386
|
+
// 1. Per-service override (multi-service, distinct URLs).
|
|
387
|
+
// readWorkspaceConfigRaw may fall back to unvalidated YAML, so serviceName
|
|
388
|
+
// is not guaranteed to be a string — guard before sanitizing.
|
|
389
|
+
if (typeof picked?.serviceName === "string") {
|
|
390
|
+
const perSvc = process.env[`SKYRAMP_TEST_SERVICE_URL_${sanitizeServiceName(picked.serviceName)}`]?.trim();
|
|
391
|
+
if (perSvc)
|
|
392
|
+
return perSvc;
|
|
393
|
+
}
|
|
394
|
+
// 2. Global override (single service / all services share a URL).
|
|
395
|
+
const global = process.env.SKYRAMP_TEST_BASE_URL?.trim();
|
|
396
|
+
if (global)
|
|
397
|
+
return global;
|
|
398
|
+
// 3. Static workspace.yml value.
|
|
399
|
+
return picked?.api?.baseUrl ?? null;
|
|
356
400
|
}
|
|
357
401
|
// ── Composer ────────────────────────────────────────────────────────────────
|
|
358
402
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|