import { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import * as types from '../common/types.js';
export const getPipelineTools = () => [
{
name: "get_pipeline",
description: "[Pipeline Management] Get details of a specific pipeline in an organization",
inputSchema: zodToJsonSchema(types.GetPipelineSchema),
},
{
name: "list_pipelines",
description: "[Pipeline Management] Get a list of pipelines in an organization with filtering options",
inputSchema: zodToJsonSchema(types.ListPipelinesSchema),
},
{
name: "generate_pipeline_yaml",
description: "[Pipeline Management] Generate only the YAML configuration for a pipeline without creating it.\n\n" +
"**๐ Use Cases:**\n" +
"- Preview YAML before creating pipeline\n" +
"- Generate YAML for manual deployment\n" +
"- Debug pipeline configuration\n\n" +
"**๐ Recommended Workflow:**\n" +
"1. ๐ฏ Parse user description for explicit parameters\n" +
"2. ๐ If missing context, prefer IDE detection (terminal + file reading) over API calls\n" +
"3. ๐ Call this tool with collected parameters\n\n" +
"**๐ก Parameter Collection Strategy:**\n" +
"- For QUICK pipeline creation: Use IDE detection (git config, file reading)\n" +
"- For PRECISE parameter selection: Consider list_repositories, list_service_connections when needed\n" +
"- Balance efficiency vs. accuracy based on user intent\n\n" +
"**โก Built-in capabilities:** Handles default service connections internally, auto-extracts project name from repo URL",
inputSchema: zodToJsonSchema(types.CreatePipelineFromDescriptionSchema),
},
{
name: "create_pipeline_from_description",
description: "[Pipeline Management] Create a pipeline using structured parameters extracted from user descriptions and environment context.\n\n" +
"**๐ง Built-in Capabilities:**\n" +
"- โ
Automatically retrieves default service connection IDs when not specified\n" +
"- โ
Handles repository and service connection logic internally\n" +
"- โ
Auto-extracts project name from repository URL (git@host:org/repo.git โ repo)\n" +
"- โ
Supports both IDE detection and explicit parameter specification\n\n" +
"**๐ Recommended Workflow:**\n" +
"1. ๐ฏ PARSE user description for explicit parameters\n" +
"2. ๐ DETECT missing info from IDE environment FIRST:\n" +
" - Run `git config --get remote.origin.url` โ repoUrl\n" +
" - Run `git branch --show-current` โ branch\n" +
" - Auto-extract serviceName from repoUrl\n" +
" - Check project files for tech stack:\n" +
" * pom.xml โ buildLanguage='java', buildTool='maven'\n" +
" * build.gradle โ buildLanguage='java', buildTool='gradle'\n" +
" * package.json + package-lock.json โ buildLanguage='nodejs', buildTool='npm'\n" +
" * package.json + yarn.lock โ buildLanguage='nodejs', buildTool='yarn'\n" +
" * requirements.txt โ buildLanguage='python', buildTool='pip'\n" +
" * go.mod โ buildLanguage='go', buildTool='go'\n" +
" * *.csproj โ buildLanguage='dotnet', buildTool='dotnet'\n" +
"3. ๐ CALL this tool with collected parameters\n\n" +
"**โ ๏ธ Important Guidelines:**\n" +
"- DO NOT call list_repositories unless user explicitly asks to choose from available repositories\n" +
"- DO NOT call list_service_connections unless user explicitly asks to choose from available connections\n" +
"- ALWAYS try IDE detection first before making any API calls\n" +
"- If IDE detection fails, THEN consider API calls as fallback\n\n" +
"**๐ฏ Parameter Priority:**\n" +
"1. ๐ค USER EXPLICIT (highest) - buildLanguage, buildTool, versions, deployTarget\n" +
"2. ๐ IDE DETECTION (preferred) - repoUrl, branch, serviceName, tech stack\n" +
"3. ๐ค TOOL DEFAULTS (automatic) - serviceConnectionId, organizationId\n\n" +
"**๐ IDE Detection Rules (MUST TRY FIRST):**\n" +
"- ๐ Repository: `git config --get remote.origin.url` โ repoUrl\n" +
"- ๐ฟ Branch: `git branch --show-current` โ branch\n" +
"- ๐ท๏ธ Service Name: Auto-extracted from repoUrl (git@host:org/repo.git โ repo)\n" +
"- โ Java Maven: pom.xml exists โ buildLanguage='java', buildTool='maven'\n" +
"- ๐๏ธ Java Gradle: build.gradle exists โ buildLanguage='java', buildTool='gradle'\n" +
"- ๐ข Node npm: package.json + package-lock.json โ buildLanguage='nodejs', buildTool='npm'\n" +
"- ๐งถ Node yarn: package.json + yarn.lock โ buildLanguage='nodejs', buildTool='yarn'\n" +
"- ๐ Python: requirements.txt โ buildLanguage='python', buildTool='pip'\n" +
"- ๐น Go: go.mod โ buildLanguage='go', buildTool='go'\n" +
"- ๐ .NET: *.csproj โ buildLanguage='dotnet', buildTool='dotnet'\n\n" +
"**๐ Version Detection (from project files):**\n" +
"- โ JDK: Read pom.xml <maven.compiler.source> โ jdkVersion\n" +
"- ๐ข Node: Read package.json engines.node โ nodeVersion\n" +
"- ๐ Python: Read .python-version, pyproject.toml โ pythonVersion\n" +
"- ๐น Go: Read go.mod go directive โ goVersion\n\n" +
"**๐ฏ Deployment Parsing:**\n" +
"- '้จ็ฝฒๅฐไธปๆบ/VM/่ๆๆบ' โ deployTarget='vm'\n" +
"- '้จ็ฝฒๅฐKubernetes/K8s' โ deployTarget='k8s'\n" +
"- 'ๅชๆๅปบ/ๆๅปบๅถๅ' โ deployTarget='none'\n\n" +
"**๐ Service Connection Strategy (3 scenarios):**\n" +
"1. **User specifies ID explicitly** (e.g., 'ไฝฟ็จๆๅก่ฟๆฅID abc123')\n" +
" โ โ
Pass serviceConnectionId=abc123 directly, NO list_service_connections call needed\n" +
"2. **User doesn't specify any ID** (most common case)\n" +
" โ โ
Pass serviceConnectionId=null, tool will auto-retrieve default ID internally\n" +
"3. **User wants to choose from available options** (e.g., 'ๆพ็คบๅฏ็จ็ๆๅก่ฟๆฅ่ฎฉๆ้ๆฉ')\n" +
" โ ๐ Call list_service_connections first, then let user choose, then create pipeline\n\n" +
"**๐ค When to Use Other Tools:**\n" +
"- User asks to \"select from available repositories\" โ use list_repositories first\n" +
"- User wants to \"choose from service connections\" โ use list_service_connections first\n" +
"- User wants to see options before deciding โ gather info first, then create\n" +
"- For quick creation with current repo โ directly use IDE detection\n\n" +
"**โ
Required:** organizationId, name, buildLanguage, buildTool",
inputSchema: zodToJsonSchema(types.CreatePipelineFromDescriptionSchema),
},
{
name: "smart_list_pipelines",
description: "[Pipeline Management] Intelligently search pipelines with natural language time references (e.g., 'today', 'this week')",
inputSchema: zodToJsonSchema(
z.object({
organizationId: z.string().describe("Organization ID"),
timeReference: z.string().optional().describe("Natural language time reference such as 'today', 'yesterday', 'this week', 'last month', etc."),
pipelineName: z.string().optional().describe("Pipeline name filter"),
statusList: z.string().optional().describe("Pipeline status list, comma separated (SUCCESS,RUNNING,FAIL,CANCELED,WAITING)"),
perPage: z.number().int().min(1).max(30).default(10).optional().describe("Number of items per page"),
page: z.number().int().min(1).default(1).optional().describe("Page number")
})
),
},
{
name: "create_pipeline_run",
description: "[Pipeline Management] Run a pipeline with optional parameters",
inputSchema: zodToJsonSchema(types.CreatePipelineRunSchema),
},
{
name: "get_latest_pipeline_run",
description: "[Pipeline Management] Get information about the latest pipeline run",
inputSchema: zodToJsonSchema(types.GetLatestPipelineRunSchema),
},
{
name: "get_pipeline_run",
description: "[Pipeline Management] Get details of a specific pipeline run instance",
inputSchema: zodToJsonSchema(types.GetPipelineRunSchema),
},
{
name: "list_pipeline_runs",
description: "[Pipeline Management] Get a list of pipeline run instances with filtering options",
inputSchema: zodToJsonSchema(types.ListPipelineRunsSchema),
},
{
name: "list_pipeline_jobs_by_category",
description: "[Pipeline Management] Get pipeline execution tasks by category. Currently only supports DEPLOY category.",
inputSchema: zodToJsonSchema(types.ListPipelineJobsByCategorySchema),
},
{
name: "list_pipeline_job_historys",
description: "[Pipeline Management] Get the execution history of a pipeline task. Retrieve all execution records for a specific task in a pipeline.",
inputSchema: zodToJsonSchema(types.ListPipelineJobHistorysSchema),
},
{
name: "execute_pipeline_job_run",
description: "[Pipeline Management] Manually run a pipeline task. Start a specific job in a pipeline run instance.",
inputSchema: zodToJsonSchema(types.ExecutePipelineJobRunSchema),
},
{
name: "get_pipeline_job_run_log",
description: "[Pipeline Management] Get the execution logs of a pipeline job. Retrieve the log content for a specific job in a pipeline run.",
inputSchema: zodToJsonSchema(types.GetPipelineJobRunLogSchema),
},
{
name: "update_pipeline",
description: "[Pipeline Management] Update an existing pipeline in Yunxiao by pipelineId. Use this to update pipeline YAML, stages, jobs, etc.",
inputSchema: zodToJsonSchema(types.UpdatePipelineSchema),
},
];