@skyramp/mcp 0.4.4-rc.2 → 0.5.0-rc.2

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 (36) hide show
  1. package/build/entitlements/entitlementGate.d.ts +8 -0
  2. package/build/entitlements/entitlementGate.js +57 -0
  3. package/build/entitlements/runCodes.d.ts +18 -0
  4. package/build/entitlements/runCodes.js +15 -0
  5. package/build/index.js +4 -4
  6. package/build/playwright/essentialTools.d.ts +1 -0
  7. package/build/playwright/essentialTools.js +43 -0
  8. package/build/playwright/registerPlaywrightTools.js +1 -43
  9. package/build/prompts/initialize-workspace/initializeWorkspacePrompt.d.ts +17 -0
  10. package/build/prompts/initialize-workspace/initializeWorkspacePrompt.js +46 -177
  11. package/build/prompts/test-maintenance/driftAnalysisShared.js +1 -1
  12. package/build/tool-phases.d.ts +14 -8
  13. package/build/tool-phases.js +83 -43
  14. package/build/tools/workspace/initScanWorkspaceTool.d.ts +11 -1
  15. package/build/tools/workspace/initScanWorkspaceTool.js +100 -9
  16. package/build/tools/workspace/initializeWorkspaceTool.js +40 -4
  17. package/build/utils/versions.d.ts +3 -3
  18. package/build/utils/versions.js +1 -1
  19. package/build/workspace/workspace.d.ts +51 -121
  20. package/build/workspace/workspace.js +34 -47
  21. package/build/workspace/workspaceVerifier.d.ts +22 -0
  22. package/build/workspace/workspaceVerifier.js +65 -0
  23. package/package.json +2 -2
  24. package/plugin/prompts/plan-tests.md +2 -2
  25. package/plugin/skills/setup-testbot-target-sut/SKILL.md +54 -0
  26. package/plugin/skills/setup-testbot-target-sut/reference/ci-workflow.md +26 -0
  27. package/plugin/skills/setup-testbot-target-sut/reference/existing-tests.md +14 -0
  28. package/plugin/skills/setup-testbot-target-sut/reference/troubleshooting.md +20 -0
  29. package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.d.ts +0 -2
  30. package/build/prompts/sut-setup/modes/adaptWorkflowPrompt.js +0 -178
  31. package/build/prompts/sut-setup/modes/dockerComposePrompt.d.ts +0 -2
  32. package/build/prompts/sut-setup/modes/dockerComposePrompt.js +0 -311
  33. package/build/prompts/sut-setup/shared.d.ts +0 -62
  34. package/build/prompts/sut-setup/shared.js +0 -196
  35. package/build/resources/sutSetupResource.d.ts +0 -2
  36. package/build/resources/sutSetupResource.js +0 -63
@@ -0,0 +1,8 @@
1
+ import type { McpServer } from "@modelcontextprotocol/server";
2
+ import { type RunCodes } from "./runCodes.js";
3
+ /**
4
+ * Makes every tool registered on `server` after this call check the run's
5
+ * entitlement codes before it runs. Without a run token it does nothing, so
6
+ * every tool behaves as before. Must be called before any tool is registered.
7
+ */
8
+ export declare function installEntitlementGate(server: McpServer, readCodes?: () => Promise<RunCodes>, token?: string | undefined): void;
@@ -0,0 +1,57 @@
1
+ import { readRunCodes } from "./runCodes.js";
2
+ import { NOT_GATED, TOOLS } from "../tool-phases.js";
3
+ const FEATURE_NAMES = {
4
+ analyze: "change analysis",
5
+ recommend: "test recommendations",
6
+ generate: "test generation",
7
+ execute: "test execution",
8
+ };
9
+ function refusal(text) {
10
+ return { content: [{ type: "text", text }], isError: true };
11
+ }
12
+ /** Returns why `tool` may not run with these codes, or undefined if it may. */
13
+ function refusalReason(tool, code, run) {
14
+ if ("refused" in run) {
15
+ return `Tool ${tool} is not available: Skyramp could not confirm what this run is allowed to do. ${run.refused}`;
16
+ }
17
+ if (run.codes.has(code))
18
+ return undefined;
19
+ return `Tool ${tool} is not available: your Skyramp plan does not include ${FEATURE_NAMES[code]}.`;
20
+ }
21
+ /**
22
+ * Makes every tool registered on `server` after this call check the run's
23
+ * entitlement codes before it runs. Without a run token it does nothing, so
24
+ * every tool behaves as before. Must be called before any tool is registered.
25
+ */
26
+ export function installEntitlementGate(server, readCodes = readRunCodes, token = process.env.SKYRAMP_RUN_TOKEN) {
27
+ if (!token?.trim())
28
+ return;
29
+ let codes;
30
+ const runCodes = () => (codes ??= readCodes()
31
+ .catch((err) => ({
32
+ refused: err instanceof Error ? err.message : String(err),
33
+ }))
34
+ .then((run) => {
35
+ // A refusal can be temporary, so the next tool call reads again.
36
+ if ("refused" in run)
37
+ codes = undefined;
38
+ return run;
39
+ }));
40
+ // Typed loosely: the gate forwards every argument as it came, whatever
41
+ // overload the tool used.
42
+ const target = server;
43
+ const register = target.registerTool.bind(target);
44
+ target.registerTool = (name, config, cb) => {
45
+ const code = TOOLS[name]?.entitlement;
46
+ if (code === NOT_GATED)
47
+ return register(name, config, cb);
48
+ const handler = cb;
49
+ return register(name, config, async (...args) => {
50
+ if (code === undefined) {
51
+ return refusal(`Tool ${name} is not available in this run.`);
52
+ }
53
+ const reason = refusalReason(name, code, await runCodes());
54
+ return reason ? refusal(reason) : handler(...args);
55
+ });
56
+ };
57
+ }
@@ -0,0 +1,18 @@
1
+ export type RunCodes = {
2
+ codes: ReadonlySet<string>;
3
+ }
4
+ /** Core refused the run token; `refused` is its reason. */
5
+ | {
6
+ refused: string;
7
+ };
8
+ type Entitlements = {
9
+ codes: string[];
10
+ } | {
11
+ error: string;
12
+ };
13
+ /** The part of SkyrampClient this file uses. Core releases before getEntitlements lack it. */
14
+ export interface Core {
15
+ getEntitlements?: (repository: string) => Promise<Entitlements>;
16
+ }
17
+ export declare function readRunCodes(core?: Core, env?: NodeJS.ProcessEnv): Promise<RunCodes>;
18
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The only file that may ask Skyramp core for the run's entitlement codes.
3
+ * Everything else in MCP reads them through `readRunCodes`, so a change on the
4
+ * core side changes this file and nothing else.
5
+ */
6
+ import { SkyrampClient } from "@skyramp/skyramp";
7
+ export async function readRunCodes(core = new SkyrampClient(), env = process.env) {
8
+ if (!core.getEntitlements) {
9
+ return { refused: "This Skyramp version does not support it yet." };
10
+ }
11
+ const answer = await core.getEntitlements(env.GITHUB_REPOSITORY ?? "");
12
+ return "error" in answer
13
+ ? { refused: answer.error }
14
+ : { codes: new Set(answer.codes) };
15
+ }
package/build/index.js CHANGED
@@ -10,6 +10,7 @@ import { registerExecuteFleetTool } from "./tools/executeFleetTool.js";
10
10
  import { AUTH_PLACEHOLDER_TOKEN } from "./types/TestTypes.js";
11
11
  import { AUTH_CONFLICT_ERROR_MSG } from "./prompts/test-recommendation/recommendationSections.js";
12
12
  import { logger } from "./utils/logger.js";
13
+ import { installEntitlementGate } from "./entitlements/entitlementGate.js";
13
14
  import { registerUITestTool } from "./tools/generate-tests/generateUIRestTool.js";
14
15
  import { registerUILoadTestTool } from "./tools/generate-tests/generateUILoadRestTool.js";
15
16
  import { registerSmokeTestTool } from "./tools/generate-tests/generateSmokeRestTool.js";
@@ -33,7 +34,6 @@ import { registerMockTool } from "./tools/generate-tests/generateMockRestTool.js
33
34
  import { registerBatchMockTool } from "./tools/generate-tests/batchMockGenerationTool.js";
34
35
  import { registerAnalyzeChangesTool, registerAnalyzeTestHealthTool, registerActionsTool, registerRegisterTestPlanTool, registerResolveScreenTool, } from "./tools/test-management/index.js";
35
36
  import { registerTestbotPrompt } from "./prompts/testbot/testbot-prompts.js";
36
- import { registerSutSetupResource } from "./resources/sutSetupResource.js";
37
37
  import { registerTestbotResource } from "./resources/testbotResource.js";
38
38
  import { registerLocalDevPrompt } from "./prompts/local-dev/local-dev-prompts.js";
39
39
  import { registerSubmitReportTool } from "./tools/submitReportTool.js";
@@ -74,7 +74,7 @@ else if (localDevEnabled) {
74
74
  oneClickInstructions = localDevInstructions;
75
75
  }
76
76
  // Global workspace-init nudge for bare MCP usage. Suppressed in testbot mode,
77
- // which runs its own INIT_WORKSPACE step (buildWorkspaceInitSection()) instead.
77
+ // which initializes the workspace in its own steps instead.
78
78
  const workspaceInitInstructions = isTestbotEnabled() || oneClickEnabled || localDevEnabled
79
79
  ? ""
80
80
  : `
@@ -156,6 +156,8 @@ async function createServer({ era }) {
156
156
  8. The user can always override workspace defaults by explicitly specifying values in their request.
157
157
  `,
158
158
  });
159
+ // Before any tool registers, so every tool goes through the check.
160
+ installEntitlementGate(server);
159
161
  // Register prompts
160
162
  logger.info("Starting prompt registration process");
161
163
  const prompts = [
@@ -167,8 +169,6 @@ async function createServer({ era }) {
167
169
  prompts.push(registerTestbotPrompt);
168
170
  registerTestbotResource(server);
169
171
  logger.info("Testbot prompt enabled via SKYRAMP_FEATURE_TESTBOT");
170
- registerSutSetupResource(server);
171
- logger.info("Testbot SUT setup resource enabled via SKYRAMP_FEATURE_TESTBOT");
172
172
  }
173
173
  if (isLocalDevEnabled()) {
174
174
  prompts.push(registerLocalDevPrompt);
@@ -0,0 +1 @@
1
+ export declare const ESSENTIAL_TOOLS: ReadonlySet<string>;
@@ -0,0 +1,43 @@
1
+ // Only expose essential browser tools to reduce LLM confusion.
2
+ // The full set (23 tools) overwhelms the LLM and causes it to use
3
+ // browser_evaluate/browser_run_code instead of the simpler tools.
4
+ //
5
+ // browser_blueprint is the only DOM Analyzer tool registered — it handles
6
+ // both full captures and same-URL deltas via the URL-cache (isFullCapture).
7
+ // browser_blueprint_diff, browser_sitemap_build, browser_sitemap_query fire
8
+ // 0 times in production evals and have no active call path in the testbot prompt.
9
+ //
10
+ // browser_widget_contract_lookup / browser_widget_contract_cache are
11
+ // intentionally excluded: the curated fingerprint library only covers
12
+ // test fixtures (not production widgets), and the LLM can handle custom
13
+ // widgets via snapshot-driven trial-and-error without the tool.
14
+ // The widgetType field on blueprint elements still signals "custom" to
15
+ // the agent — no guidance is lost.
16
+ export const ESSENTIAL_TOOLS = new Set([
17
+ "browser_navigate",
18
+ "browser_snapshot",
19
+ "browser_click",
20
+ "browser_type",
21
+ "browser_press_key",
22
+ "browser_select_option",
23
+ "browser_hover",
24
+ "browser_drag",
25
+ "browser_file_upload",
26
+ "browser_evaluate",
27
+ "browser_tabs",
28
+ "browser_navigate_back",
29
+ "browser_wait_for",
30
+ "browser_take_screenshot",
31
+ "browser_assert",
32
+ "browser_assert_hidden",
33
+ "browser_assert_api_request",
34
+ "browser_assert_table_cell",
35
+ "browser_mouse_action",
36
+ "browser_visual_snapshot",
37
+ "browser_gojs_add_node",
38
+ "browser_gojs_link",
39
+ "skyramp_export_zip",
40
+ "skyramp_load_trace",
41
+ // DOM Analyzer: blueprint capture (capture-act-capture pattern)
42
+ "browser_blueprint",
43
+ ]);
@@ -8,6 +8,7 @@ import { PlaywrightTraceService, } from "./PlaywrightTraceService.js";
8
8
  import { blueprintJsonSpan } from "./blueprintDigest.js";
9
9
  import { recordBlueprintCapture, recordBrowserNavigation, } from "./blueprintDigestStore.js";
10
10
  import { recordTraceExport } from "./traceExportStore.js";
11
+ import { ESSENTIAL_TOOLS } from "./essentialTools.js";
11
12
  let _service = null;
12
13
  export function getPlaywrightTraceService() {
13
14
  return _service;
@@ -169,49 +170,6 @@ export async function registerPlaywrightTools(server, options) {
169
170
  }
170
171
  const tools = _service.getTools();
171
172
  logger.info(`Registering ${tools.length} Playwright browser tools`);
172
- // Only expose essential browser tools to reduce LLM confusion.
173
- // The full set (23 tools) overwhelms the LLM and causes it to use
174
- // browser_evaluate/browser_run_code instead of the simpler tools.
175
- //
176
- // browser_blueprint is the only DOM Analyzer tool registered — it handles
177
- // both full captures and same-URL deltas via the URL-cache (isFullCapture).
178
- // browser_blueprint_diff, browser_sitemap_build, browser_sitemap_query fire
179
- // 0 times in production evals and have no active call path in the testbot prompt.
180
- //
181
- // browser_widget_contract_lookup / browser_widget_contract_cache are
182
- // intentionally excluded: the curated fingerprint library only covers
183
- // test fixtures (not production widgets), and the LLM can handle custom
184
- // widgets via snapshot-driven trial-and-error without the tool.
185
- // The widgetType field on blueprint elements still signals "custom" to
186
- // the agent — no guidance is lost.
187
- const ESSENTIAL_TOOLS = new Set([
188
- "browser_navigate",
189
- "browser_snapshot",
190
- "browser_click",
191
- "browser_type",
192
- "browser_press_key",
193
- "browser_select_option",
194
- "browser_hover",
195
- "browser_drag",
196
- "browser_file_upload",
197
- "browser_evaluate",
198
- "browser_tabs",
199
- "browser_navigate_back",
200
- "browser_wait_for",
201
- "browser_take_screenshot",
202
- "browser_assert",
203
- "browser_assert_hidden",
204
- "browser_assert_api_request",
205
- "browser_assert_table_cell",
206
- "browser_mouse_action",
207
- "browser_visual_snapshot",
208
- "browser_gojs_add_node",
209
- "browser_gojs_link",
210
- "skyramp_export_zip",
211
- "skyramp_load_trace",
212
- // DOM Analyzer: blueprint capture (capture-act-capture pattern)
213
- "browser_blueprint",
214
- ]);
215
173
  const filteredTools = tools.filter((t) => ESSENTIAL_TOOLS.has(t.name));
216
174
  logger.info(`Filtering to ${filteredTools.length} essential tools (from ${tools.length} total)`);
217
175
  for (const tool of filteredTools) {
@@ -1 +1,18 @@
1
1
  export declare const INIT_WORKSPACE_INSTRUCTIONS: string;
2
+ /** A repository of the Target other than the workspace's own, scanned into the same workspace.yml. */
3
+ export interface ScanRelatedRepository {
4
+ /** owner/repo, set verbatim as each of its services' `repository`. */
5
+ repository: string;
6
+ repositoryPath: string;
7
+ }
8
+ /**
9
+ * The scan instructions for one workspace. With related repositories, every
10
+ * repository is scanned into the one workspace.yml at `workspacePath`, each
11
+ * related repository's services carrying its `repository`. With a test
12
+ * repository, testDirectory is read from, and relative to, that checkout.
13
+ */
14
+ export declare function buildInitWorkspaceInstructions(target: {
15
+ workspacePath: string;
16
+ relatedRepositories?: ScanRelatedRepository[];
17
+ testRepositoryPath?: string;
18
+ }): string;
@@ -1,178 +1,47 @@
1
1
  import { getPersonaPrefix } from "../personas.js";
2
- import { AUTH_TYPES_PROMPT_LIST } from "../../utils/workspaceAuth.js";
3
- export const INIT_WORKSPACE_INSTRUCTIONS = `${getPersonaPrefix()}Your task is to scan this repository, discover ALL services, and call the skyramp_init_workspace tool with the discovered services array and the scanToken.
4
-
5
- After scanning the workspace, before calling the skyramp_init_workspace tool, you MUST:
6
- 1. Output a <thinking> block to justify the reasoning behind each field mapping for every discovered service. Follow the scanning sections first, then field definitions, then verification.
7
- 2. Then output a Discovery Summary with the exact services array you will pass to the tool:
8
- \`\`\`json
9
- [
10
- {
11
- "serviceName": "<name>",
12
- "language": "<language>",
13
- "framework": "<framework>",
14
- "testDirectory": "<path>",
15
- "api": { "schemaPath": "<path-or-url>", "baseUrl": "<url>", "authType": "<type>", "authHeader": "<header>" },
16
- "runtimeDetails": { "runtime": "<runtime>", "serverStartCommand": "<command>", "serverStopCommand": "<docker stop command>", "dockerNetwork": "<network>" }
17
- }
18
- ]
19
- \`\`\`
20
-
21
- ### List all top-level directories
22
- <list_directories>
23
- Run a directory listing of the workspace root. Every top-level directory is a potential service. Common layouts:
24
- | Layout | Example dirs | Expect |
25
- |--------|-------------|--------|
26
- | Monorepo | apps/web, apps/api, packages/shared | 1 service per app |
27
- | Microservices | services/auth, services/orders | 1 service per service dir |
28
- | Single service | src/, lib/ | 1 service (the root) |
29
-
30
- If the repo is a monorepo, check for workspace manifests BEFORE scanning individual directories:
31
- 1. JavaScript/TypeScript monorepos:
32
- - If pnpm-workspace.yaml exists, read the packages array to find all package directories (for example, ["apps/*", "packages/*"]).
33
- - If turbo.json exists, read the root package.json workspaces field to enumerate all packages.
34
- - If lerna.json exists, read the packages array in lerna.json (for example, ["packages/*"]).
35
- - If the root package.json has a "workspaces" field, use the glob patterns to identify all packages.
36
- - If nx.json exists, scan the projects in nx.json or project.json files in subdirectories.
37
- 2. Java monorepos:
38
- - If a parent pom.xml has a <modules> section, each listed module is a separate service (Maven multi-module project).
39
- - If settings.gradle or settings.gradle.kts has include statements, each included project is a separate service (Gradle multi-project).
40
- 3. Python monorepos:
41
- - If a pyproject.toml has a [tool.poetry.packages] or [tool.setuptools.packages] section with multiple paths, each is a potential service.
42
- - If multiple directories each contain their own pyproject.toml or requirements.txt, treat each as an independent service.
43
- When any of these exist, use the workspace manifest to enumerate ALL packages and apps. Each package with its own server entry point, API routes, or UI framework is a separate service. Do NOT skip frontend packages. A Next.js app, React SPA, or Vue app in the monorepo is a service.
44
- </list_directories>
45
-
46
- ### Inspect every candidate directory
47
- <inspect_directories>
48
- For each top-level directory, check for service indicator files.
49
-
50
- Language indicators (presence of any means an independent service):
51
- 1. package.json indicates typescript or javascript
52
- 2. requirements.txt, pyproject.toml, or Pipfile indicates python
53
- 3. pom.xml or build.gradle indicates java
54
-
55
- Test framework (look inside the service directory):
56
- 1. playwright.config.* indicates playwright
57
- 2. pytest.ini, conftest.py, or pyproject.toml [tool.pytest] indicates pytest
58
- 3. junit in pom.xml indicates junit
59
-
60
- API schemas (look inside the service directory and check known framework defaults):
61
- 1. openapi.json/yaml or swagger.json/yaml provides the schema file path
62
- 2. FastAPI projects serve the schema at http://localhost:{port}/openapi.json
63
- 3. Express with swagger-ui serves at http://localhost:{port}/api-docs
64
- 4. Spring Boot serves at http://localhost:{port}/v3/api-docs
65
- </inspect_directories>
66
-
67
- ### Check root-level runtime config
68
- <runtime_config>
69
- Inspect the repo root (and subdirectories like .devcontainer/) for shared runtime configuration:
70
- 1. CLAUDE.md or AGENTS.md: if either file exists at the repo root, check it for dev/test/CI setup instructions including how to start services, required environment variables, and runtime configuration.
71
- 2. Docker Compose files: scan for ALL compose files including docker-compose.yml, docker-compose.yaml, docker-compose.*.yml (such as docker-compose.testbot.yml or docker-compose.dev.yml), compose.yml, and compose.*.yaml in the repo root and subdirectories. Distinguish between application compose files and infrastructure-only compose files. Infrastructure compose files contain only supporting services like databases, Redis, Minio, mail servers, or message queues and do NOT run the application itself. Application compose files contain the actual application services that build from the repo source code (look for "build:" directives pointing to the repo, or services that map to discovered application directories). Only use application compose files for determining runtime, serverStartCommand, and serverStopCommand. When a non-default compose file is found, the serverStartCommand and serverStopCommand must reference it explicitly (such as "docker compose -f docker-compose.testbot.yml up -d --build <service-name>" and "docker compose -f docker-compose.testbot.yml stop <service-name>"). Docker Compose ALWAYS prefixes the network name with the project name. If compose has "networks: { my-net: ... }", the actual network name is "<project-name>_my-net". If there is no explicit networks section, the default network is "<project-name>_default". The project name is the basename of the working directory where docker compose runs.
72
- 3. Makefile: extract start and dev targets.
73
- 4. Root package.json scripts: extract workspace-level commands.
74
- </runtime_config>
75
-
76
- ### Build the complete services array
77
- <build_services>
78
- Create one service entry per deployable unit. You MUST include every backend/API service (Python, Java, Go, Node.js) and every frontend service (React, Vue, Angular, Next.js). Set runtime fields from docker-compose.yml if present.
79
- </build_services>
80
-
81
- ### Basic fields
82
- <basic_fields>
83
- 1. serviceName (required): A unique identifier for the service. Use the format <repoName>-<serviceDirName>-<frontend or backend> for consistency. For example: directus-api-backend, directus-app-frontend. If the directory name already ends with "backend" or "frontend", do not duplicate the suffix (use "demoshop-fullstack-backend" not "demoshop-fullstack-backend-backend"). For single-service repos where the service directory is the root, omit the directory portion such as onlineBoutique-frontend.
84
- 2. language (required): One of python, typescript, javascript, or java. Detect from package.json (typescript or javascript), requirements.txt or pyproject.toml (python), or pom.xml or build.gradle (java).
85
- 3. framework (required): One of playwright, pytest, robot, or junit. Detect from pytest.ini, playwright.config, jest.config, or junit in pom.xml. The framework MUST match the language: python uses pytest or robot, typescript or javascript uses playwright, and java uses junit.
86
- 4. testDirectory (required): A stable path relative to the repo root where generated tests for this service will be placed. For each service, use the test directory configured by that service's test framework when one is discoverable:
87
- - Playwright: Read playwright.config.ts (or .js/.mjs) and extract the testDir value.
88
- - pytest: Read pytest.ini, pyproject.toml [tool.pytest.ini_options], or setup.cfg [tool:pytest] for testpaths.
89
- - JUnit: Usually src/test/java. Check pom.xml or build.gradle for custom test source directories.
90
- If no framework-configured test directory is available, use the Skyramp deterministic fallback:
91
- - Single service: set testDirectory to tests/skyramp.
92
- - Multiple services or monorepos: set testDirectory to tests/skyramp/<serviceDirName>, where <serviceDirName> is the service directory name with path separators and whitespace replaced by hyphens.
93
- Framework config takes precedence. Use the Skyramp deterministic fallback only when no framework-configured test directory is available.
94
- NEVER set testDirectory to \`.skyramp\`, to any path inside it, or to \`.\` or the repo root, whatever the framework config or existing test files say. \`.skyramp\` is the executor's own working area: it holds the run videos and executor artefacts. skyramp_init_workspace rejects all of these, and the generation tools refuse to write there.
95
- </basic_fields>
96
-
97
- ### API fields
98
- <api_fields>
99
- 1. api.schemaPath: Path or URL to an OpenAPI or Swagger schema. Search for openapi.json, openapi.yaml, swagger.json, or swagger.yaml files. Framework defaults are: FastAPI serves /openapi.json, Express serves /api-docs, and Spring serves /v3/api-docs. For locally-run services, use a localhost URL. For cloud or externally hosted services (such as Salesforce, Vercel, or Cloudflare), use the actual deployment URL found in config or documentation.
100
- 2. api.baseUrl (required): The base URL where the service is reachable, such as "http://localhost:3000" or "https://api.example.com". Derive from docker-compose ports, app config, README, or environment variables. Use localhost for services run locally and the actual deployment URL for cloud or externally hosted services. NEVER fabricate a URL. Only use URLs found in config files, README, or environment variables.
101
- Include the API path prefix (e.g. \`/api\`, \`/api/v1\`, \`/v1\`) when one applies — not just \`host:port\`. A bare host means every test request hits the root and 404s. Derive the prefix from the strongest available signal: OpenAPI \`servers[].url\` or \`basePath\`; the app's routing config (FastAPI \`root_path\`, Express \`app.use('/api/v1', ...)\`, Rails routes prefix, Django \`urlpatterns\` mount); or the longest common leading path across the existing test suite's endpoints. If none of those yield a prefix, leave it bare AND flag it in your summary so the user can review.
102
- 3. api.authType (required): The authentication type. Valid values are: ${AUTH_TYPES_PROMPT_LIST}
103
- Detect by checking in the following order (language-agnostic, apply whichever signals match):
104
- a. Dependencies and packages (package.json, requirements.txt, go.mod, Gemfile, composer.json, pom.xml, build.gradle):
105
- - jsonwebtoken, passport-jwt, @nestjs/jwt, jose, fastapi[security], PyJWT, python-jose, github.com/golang-jwt/jwt, jjwt, or spring-security-oauth2 indicates bearer. Spring exception: if spring-security is present but the security config uses HttpSecurity.formLogin() or sessionManagement() without a JwtDecoder bean, the actual auth is session cookies so use cookie. Check the SecurityConfig or WebSecurityConfigurerAdapter class before assigning bearer to any Spring service.
106
- - passport-http or Spring basic auth indicates basic.
107
- - passport-oauth2, openid-client, doorkeeper, keycloak-connect, spring-security-oauth2-resource-server, or github.com/coreos/go-oidc indicates oauth.
108
- - rest_framework with TokenAuthentication or djangorestframework-simplejwt (Token scheme) indicates token.
109
- - express-session, cookie-session, iron-session, next-auth, gorilla/sessions, or laravel/session indicates cookie.
110
- - laravel/sanctum or laravel/passport on API routes indicates bearer; on frontend web routes indicates cookie.
111
- b. Environment variables (.env, docker-compose, README):
112
- - JWT_SECRET, ACCESS_TOKEN_SECRET, FIREBASE_SECRET, or SUPABASE_JWT_SECRET indicates bearer.
113
- - API_KEY, X_API_KEY, ADMIN_KEY, or SERVICE_KEY (used as header value, not JWT signing) indicates apiKey.
114
- - CLIENT_ID paired with CLIENT_SECRET, OAUTH_CLIENT_*, or OIDC_* indicates oauth.
115
- - SESSION_SECRET, COOKIE_SECRET, or NEXTAUTH_SECRET indicates cookie.
116
- c. Source code and middleware patterns (auth, middleware, or security config files):
117
- - Node/Express: req.headers.authorization split "Bearer" indicates bearer. "Authorization: Token" indicates token. Custom header check indicates apiKey. Session or cookie middleware indicates cookie.
118
- - FastAPI/Starlette: HTTPBearer, OAuth2PasswordBearer, or Depends(get_current_user) indicates bearer. SessionMiddleware indicates cookie.
119
- - Django/DRF: TokenAuthentication indicates token. JWTAuthentication indicates bearer. SessionAuthentication indicates cookie.
120
- - Spring: JwtDecoder or JwtAuthenticationFilter indicates bearer. HttpSecurity.formLogin() with sessions indicates cookie.
121
- - Go: ParseWithClaims or GetHeader("Authorization") indicates bearer. gorilla/sessions indicates cookie.
122
- - Rails: authenticate_or_request_with_http_token indicates bearer. before_action :authenticate_user! (Devise) indicates cookie.
123
- - Laravel: auth:sanctum on API indicates bearer. middleware("auth") on web indicates cookie.
124
- - Rust/Axum: Authorization<Bearer> extraction indicates bearer.
125
- d. Query-parameter auth: Some APIs pass credentials as a URL query param rather than a header (such as ?key=<key>, ?api_key=<key>, or ?access_token=<token>). Signals include source code reading credentials from req.query.key, request.query_params["api_key"], or @RequestParam("token"), and API docs or README showing auth examples like /endpoint?key=<your-key>.
126
- e. Fallback: For frontend or UI services, use none. For backend APIs with no header-based auth signals, use bearer.
127
- 4. api.authHeader: The exact HTTP header name carrying the credential.
128
- - For bearer, basic, oauth, or token: always "Authorization" (inferred automatically, so you may omit it).
129
- - For cookie or session: always "Cookie" (also inferred automatically).
130
- - For apiKey: this is required. Set to the actual custom header name such as "X-API-Key" or "X-Admin-Key".
131
- - For none: set authHeader to "".
132
- 5. api.authScheme: The Authorization header prefix (the word before the token). Standard types derive this automatically: bearer uses "Bearer", token uses "Token", and basic uses "Basic". Set explicitly only for custom or non-standard schemes (for example, Hawk uses "Hawk" and Digest uses "Digest"). Omit for cookie, session, or apiKey since they do not use the Authorization header.
133
- </api_fields>
134
-
135
- ### Runtime fields
136
- <runtime_fields>
137
- 1. runtimeDetails.runtime (required): One of local, docker, or k8s. Detect per service:
138
- - If the service is listed in an application docker compose file (one that builds or runs the application, not infrastructure-only files containing only databases, caches, or queues) or has a Dockerfile as its intended run method, use "docker".
139
- - If k8s manifests exist (charts/, k8s/, deploy/) AND the service is intended to run in K8s for local development, use "k8s".
140
- - If the service has no Docker or k8s configuration and is run directly via a language runtime (npm, python, java, etc.), use "local".
141
- A repo may have MIXED runtimes. A backend in docker-compose.yml uses "docker" while a frontend run with pnpm or npm locally uses "local". Include ALL services regardless of runtime.
142
- If the frontend is bundled inside the API Docker container (no separate frontend service in the compose file), both frontend and backend services should use runtime "docker", share the same baseUrl (the container's exposed URL), and use the same serverStartCommand since they run in the same container.
143
- IMPORTANT — proxy parameters are NOT runtime indicators: If proxyKubeconfig, proxyNamespace, or proxyUrl appear in the conversation context, they are for a Skyramp proxy worker that collects traffic samples for mock generation. They do NOT indicate the repo's runtime. Do not use proxy K8s params to set runtime, k8sNamespace, or k8sContext. Determine the runtime solely from the repo's own files (docker-compose.yml, Dockerfile, k8s manifests that are part of the repo's own local dev workflow). Note that many repos have K8s deployment manifests for staging/production but use Docker Compose for local development — check which setup the repo actually uses for local dev.
144
- 2. runtimeDetails.serverStartCommand: The command to start or deploy the service. It MUST match the runtime:
145
- - For "docker" runtime: Use a Docker command that rebuilds application services from the working tree before starting them, such as "docker compose up -d --build <service-name>" for the default docker-compose.yml, or "docker compose -f <compose-file> up -d --build <service-name>" when using a non-default compose file. This is always derivable from the application docker compose file and service name. If the compose service has no build context and only references an image, note that the command cannot rebuild local code.
146
- - For "k8s" runtime: Use a deploy command such as "kubectl apply -f deploy/", "helm install myrelease .", or "skaffold run". This is always derivable from the manifests or charts present in the repo.
147
- - For "local" runtime: Use an application command such as "uvicorn main:app", "npm run dev", or "java -jar app.jar". Derive from Makefile, package.json scripts, or README. If no start command is discoverable, omit this field entirely.
148
- NEVER mix runtime types with incompatible commands (for example, using "uvicorn" with runtime "docker" will cause errors). For "local" runtime, NEVER fabricate a command. Only use commands found in Makefile, package.json scripts, or README.
149
- 3. runtimeDetails.serverStopCommand: Optional command to stop the service after test execution. ONLY set when runtime is "docker" and serverStartCommand starts persistent Docker infrastructure. For docker compose starts, prefer matching stop/down commands from the same compose file. Omit this field for "local" and "k8s" runtimes, or when teardown is unsafe or not discoverable.
150
- 4. runtimeDetails.dockerNetwork: Docker network name. ONLY set when runtime is "docker". NEVER set for "local" or "k8s".
151
- 5. runtimeDetails.k8sNamespace: Kubernetes namespace. ONLY set when runtime is "k8s". NEVER set for "local" or "docker".
152
- 6. runtimeDetails.k8sContext: Kubernetes context. ONLY set when runtime is "k8s". NEVER set for "local" or "docker".
153
- </runtime_fields>
154
-
155
- ### Verification
156
- <verification>
157
- Before calling skyramp_init_workspace, confirm all of the following:
158
- 1. Always scan the repo and find services. A repo should have at least one service.
159
- 2. ALL services are included, both backend and frontend. The workspace config is a complete registry of the entire repo, not just the service relevant to your current task. A fullstack or monorepo MUST have multiple services. If you found only one, re-scan every top-level directory before proceeding.
160
- 3. Services NOT in docker-compose.yml (such as a frontend run with pnpm or npm locally) MUST still be included with runtime "local".
161
- 4. Every service has api.baseUrl set to a valid, discoverable URL. Use localhost for local services or the actual deployment URL for cloud or external services. Never fabricate a URL.
162
- 5. Every service with authType apiKey has authHeader explicitly set to the actual custom header name (such as "X-API-Key" or "X-Admin-Key"). If you cannot find the header name in the source code, env vars, or README, do NOT use authType apiKey. Use authType none instead and add a YAML comment explaining auth is unresolved.
163
- 6. framework matches language (python uses pytest or robot, typescript or javascript uses playwright, java uses junit).
164
- 7. testDirectory follows the stable resolution rules above: framework config file when present (Playwright testDir in playwright.config.ts, pytest testpaths in pytest.ini or pyproject.toml, JUnit test source dir in pom.xml or build.gradle); otherwise the deterministic default (tests/skyramp for a single service, tests/skyramp/<serviceDirName> for multiple services). No service uses \`.skyramp\`, \`.\` or the repo root.
165
- 8. If serverStartCommand is provided, it matches the runtime. If serverStopCommand is provided, runtime is "docker" and the command is a Docker command.
166
- 9. For services in docker-compose.yml: runtime MUST be "docker" and the command MUST be a docker command such as "docker compose up -d --build <service-name>" when the service has a build context. Always include it since it is derivable from the service name.
167
- 10. NEVER use application-level commands (uvicorn, npm, node, python, java, etc.) with runtime "docker".
168
- 11. For "local" runtime: if no start command is discoverable from Makefile, package.json scripts, or README, omit serverStartCommand rather than guessing.
169
- 12. dockerNetwork is set only when runtime is "docker".
170
- 13. k8sNamespace and k8sContext are set only when runtime is "k8s".
171
- 14. If force-recreating a workspace.yml due to a schema validation error, correct the schema error but keep any valid system-under-test setup (serviceName, baseUrl, auth config, runtime details) as it is.
172
- </verification>
173
-
174
- Once verified, call skyramp_init_workspace with:
175
- - workspacePath: the repository root path
176
- - services: the array built above
177
- - scanToken: the token returned by the first call to skyramp_init_scan
178
- - force: defaults to false. Set to true only if the user explicitly asks to overwrite an existing .skyramp/workspace.yml, or if the existing file must be regenerated due to a validation failure such as a schema mismatch, unknown fields, or a parse error.`;
2
+ export const INIT_WORKSPACE_INSTRUCTIONS = `${getPersonaPrefix()}Scan this repository and register every component of the system under test in .skyramp/workspace.yml.
3
+
4
+ ### Find the components
5
+ A component runs on its own: a backend API, a frontend app, or a worker with its own entry point. Shared libraries are not components. Read the workspace manifests, compose and container files, CI workflows, README, CLAUDE.md and AGENTS.md, then check every top-level directory. Register every component, frontends included; a monorepo usually has several.
6
+
7
+ ### Fields
8
+ Take every value from a file you read or a rule below; never invent one. For each component:
9
+ - serviceName: always \`<repoName>-<componentDir>\`, or \`<repoName>\` for a component at the root.
10
+ - language: the language of its tests, or of its code when it has none, in lowercase.
11
+ - framework: the framework of its API or UI tests; when it has none, the one its repository or language commonly uses. Never leave it out.
12
+ - testDirectory: where generated tests go, relative to the repository root. Use the directory its test framework config names; otherwise \`tests/skyramp\` for a single component, or \`tests/skyramp/<componentDir>\` for several, with \`/\` in the directory replaced by \`-\`. Never \`.skyramp\`, a path inside it, or the root.
13
+ - api.baseUrl: the URL its API paths are appended to: scheme, host and port where it runs locally (or its hosted URL), plus a base path only when its OpenAPI \`servers\` URL or \`basePath\` holds one the paths leave out. A frontend the backend serves shares the backend's. api.schemaPath: its OpenAPI file or URL, if any.
14
+ - api.authType: from its auth code, dependencies or environment variables; \`none\` without a signal. For \`apiKey\`, set api.authHeader to the header name.
15
+ - runtimeDetails.runtime: \`docker\` when it runs in containers, \`k8s\` when it runs on Kubernetes, else \`local\`, as the repository runs it. dockerNetwork: the network its containers join, if any.
16
+
17
+ ### Call the tool
18
+ First write a Discovery Summary: the services array, and for each value the file or rule that set it. Then call skyramp_init_workspace with workspacePath (the repository root), services and scanToken. Set force only when the user asks to overwrite, or the existing file fails validation; then keep its valid values. When the tool refuses, fix every problem it lists and call it again with the full array and the same scanToken.`;
19
+ /**
20
+ * The scan instructions for one workspace. With related repositories, every
21
+ * repository is scanned into the one workspace.yml at `workspacePath`, each
22
+ * related repository's services carrying its `repository`. With a test
23
+ * repository, testDirectory is read from, and relative to, that checkout.
24
+ */
25
+ export function buildInitWorkspaceInstructions(target) {
26
+ const related = target.relatedRepositories ?? [];
27
+ const deliveryRoot = target.testRepositoryPath ?? target.workspacePath;
28
+ const blocks = [];
29
+ if (related.length > 0) {
30
+ blocks.push(`### Target repositories
31
+ <target_repositories>
32
+ Scan each repository below as above; pass the components of all ${related.length + 1} to one skyramp_init_workspace call with workspacePath "${target.workspacePath}":
33
+ - ${target.workspacePath}: this workspace's own, with no repository.
34
+ ${related.map((r) => `- ${r.repositoryPath}: set repository to "${r.repository}" on each of its components.`).join("\n")}
35
+ Write a related repository's paths from its own root, except testDirectory: every testDirectory is relative to ${deliveryRoot}, and a related repository's fallback is \`tests/skyramp/<repoName>\`, or \`tests/skyramp/<repoName>-<componentDir>\` with several components.
36
+ </target_repositories>`);
37
+ }
38
+ if (target.testRepositoryPath) {
39
+ blocks.push(`### Test repository
40
+ <test_repository>
41
+ Generated tests go to the test repository at ${target.testRepositoryPath}. Read testDirectory from its framework config, relative to its root, with the same fallback. Register no component for it.
42
+ </test_repository>`);
43
+ }
44
+ return blocks.length
45
+ ? `${INIT_WORKSPACE_INSTRUCTIONS}\n\n${blocks.join("\n\n")}`
46
+ : INIT_WORKSPACE_INSTRUCTIONS;
47
+ }
@@ -57,7 +57,7 @@ ${opts.domainNotes}
57
57
 
58
58
  **If your rationale concludes the test is unaffected, assign IGNORE, not VERIFY.** Assign VERIFY only for a doubt that the code you read does not settle. A rule that forbids IGNORE still applies.
59
59
 
60
- **A stated requirement wins over the code.** Before you write a new value or refresh a screenshot in an existing test, compare it with what the pull request title, the description and any requirements file they name state. If the new value breaks a stated requirement, do not write it: keep that assertion on the requirement's value and make only the other edits. If no other edit remains, mark the test VERIFY. The test stays red; do not relax it. If the requirements file is unchanged and the description presents the new behaviour as intended, the file is out of date: update the test.
60
+ **A stated requirement wins over the code.** Before you write a new value or refresh a screenshot in an existing test, compare it with what the pull request title, the description and any requirements file they name state. If the new value breaks a stated requirement, do not write it: keep that assertion on the requirement's value and make only the other edits. If no other edit remains, mark the test VERIFY. The test stays red; do not relax it. Authority runs requirements > PR description > code change: an unchanged requirements file that the description contradicts still wins — keep the assertion on the file's value and report the requirement conflict.
61
61
 
62
62
  **Pre-commit verification — confirm before finalizing UPDATE/REGENERATE/DELETE:**
63
63
  1. You can quote a specific diff line${opts.blueprintSuffix} this test observes that triggered the action.
@@ -1,11 +1,12 @@
1
1
  /**
2
- * Canonical mapping of Skyramp MCP tool names to testbot progress phases.
2
+ * One entry per Skyramp MCP tool: its testbot progress phase, if it has one,
3
+ * and the entitlement code it needs when the run has a SKYRAMP_RUN_TOKEN.
4
+ * Every registered tool must have an entry; tool-phase-coverage.test.ts fails
5
+ * when one is missing.
3
6
  *
4
- * The testbot progress UI reads this map at runtime to know which tool calls
5
- * correspond to which progress steps. When adding or renaming tools, update
6
- * this map so the progress UI stays accurate.
7
- *
8
- * Tools not in this map must be listed in TOOLS_WITHOUT_PHASE.
7
+ * The testbot progress UI reads TOOL_PHASE_MAP at runtime (through the
8
+ * `@skyramp/mcp/tool-phases` package export) to know which tool calls
9
+ * correspond to which progress steps.
9
10
  *
10
11
  * Phases: analyzing, generating, executing, maintaining, reporting
11
12
  *
@@ -29,10 +30,15 @@ export type PhaseMapping = string | {
29
30
  before: string;
30
31
  after: string;
31
32
  };
33
+ export type EntitlementCode = "analyze" | "recommend" | "generate" | "execute";
34
+ export declare const NOT_GATED = "not gated";
35
+ export type ToolEntry = {
36
+ phase?: PhaseMapping;
37
+ entitlement: EntitlementCode | typeof NOT_GATED;
38
+ };
39
+ export declare const TOOLS: Readonly<Record<string, ToolEntry>>;
32
40
  export declare const TOOL_PHASE_MAP: Record<string, PhaseMapping>;
33
41
  /** Tools whose phase depends on context — listed here for consumer discovery. */
34
42
  export declare const CONTEXT_DEPENDENT_TOOLS: Set<string>;
35
43
  /** All tools that belong to the "generating" phase — used as the boundary. */
36
44
  export declare const GENERATING_TOOLS: Set<string>;
37
- /** Tools that intentionally have no progress phase (infrastructure/utility). */
38
- export declare const TOOLS_WITHOUT_PHASE: Set<string>;