Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/mcp-provider-devops/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"@salesforce/core": "^8.24.3",
"@salesforce/source-deploy-retrieve": "^12.31.7",
"@salesforce/ts-types": "^2.0.12",
"axios": "^1.10.0",
"zod": "^3.25.76"
},
"devDependencies": {
Expand Down
55 changes: 23 additions & 32 deletions packages/mcp-provider-devops/src/commitLiteWorkItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import axios from 'axios';
import { getConnection, getRequiredOrgs } from './shared/auth.js';
import { type Connection } from '@salesforce/core';
import { execFileSync } from 'child_process';
import { normalizeAndValidateRepoPath } from './shared/pathUtils.js';
import path from 'path';
Expand All @@ -8,68 +7,60 @@ import * as os from 'os';
import { RegistryAccess } from '@salesforce/source-deploy-retrieve';
import { convertToSourceComponents } from './shared/sfdxService.js';

const API_VERSION = 'v65.0';

interface Change {
fullName: string;
type: string;
operation: string;
}

interface CommitWorkItemParams {
export interface CommitWorkItemParams {
connection: Connection;
workItem: { id: string };
requestId: string;
commitMessage: string;
username: string;
repoPath?: string;
}


/**
* Commits work item changes (lite flow) using the provided Connection.
* API: POST /services/data/v65.0/connect/devops/workItems/<id>/commitlite
*/
export async function commitWorkItem({
connection,
workItem,
requestId,
commitMessage,
username,
repoPath
}: CommitWorkItemParams): Promise<any> {
const connection = await getConnection(username);
const accessToken = connection.accessToken;
const instanceUrl = connection.instanceUrl;

if (!accessToken || !instanceUrl) {
throw new Error('Missing access token or instance URL. Please check if you are authenticated to the org.');
}


const workingDir = normalizeAndValidateRepoPath(repoPath);

const computedChanges = buildComputedChanges(workingDir);

const { commitSha, branch } = AddAndCommitChanges(workingDir, commitMessage);

const url = `${instanceUrl}/services/data/v65.0/connect/devops/workItems/${workItem.id}/commitlite`;

const headers = {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
};
const { commitSha } = AddAndCommitChanges(workingDir, commitMessage);

const pathUrl = `/services/data/${API_VERSION}/connect/devops/workItems/${workItem.id}/commitlite`;
const requestBody = {
requestId,
commitMessage,
'commitId': commitSha,
commitId: commitSha,
changes: computedChanges
};

try {
const response = await axios.post(url, requestBody, { headers });

return {
await connection.request({
method: 'POST',
url: pathUrl,
body: JSON.stringify(requestBody),
headers: { 'Content-Type': 'application/json' }
});
return {
content: [{
type: "text",
text: `Changes committed successfully.
type: "text",
text: `Changes committed successfully.
Commit SHA: ${commitSha}
Agent execution guide (perform these steps now)
- Push the commit: 'git push'`,
actionRequired: true
actionRequired: true
}],
isError: false
};
Expand Down
189 changes: 0 additions & 189 deletions packages/mcp-provider-devops/src/commitWorkItem.ts

This file was deleted.

85 changes: 32 additions & 53 deletions packages/mcp-provider-devops/src/createPullRequest.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,33 @@
import axios from 'axios';
import { getConnection } from './shared/auth.js';

interface CreatePullRequestParams {
workItemId: string;
username: string;
}

export async function createPullRequest({
workItemId,
username
}: CreatePullRequestParams): Promise<any> {
if (!workItemId) {
throw new Error('Work item ID is required to create pull request.');
}

if (!username) {
throw new Error('Salesforce username is required to create pull request.');
}

try {
const connection = await getConnection(username);
const accessToken = connection.accessToken;
const instanceUrl = connection.instanceUrl;

if (!accessToken || !instanceUrl) {
throw new Error('Missing access token or instance URL. Please check if you are authenticated to the org.');
}

const apiVersion = 'v65.0';
const url = `${instanceUrl}/services/data/${apiVersion}/connect/devops/workItems/${workItemId}/review`;

const headers = {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json'
};

const requestBody = {};


const response = await axios.post(url, requestBody, { headers });


return {
success: true,
pullRequestResult: response.data,
message: 'Pull request created successfully',
workItemId
};
} catch (error: any) {
const errorMessage = error.response?.data?.message || error.message;
throw new Error(`Failed to create pull request: ${errorMessage}`);
}
import { type Connection } from '@salesforce/core';

const API_VERSION = 'v65.0';

/**
* Creates a pull request for a work item using the provided Connection.
* API: POST /services/data/v65.0/connect/devops/workItems/<workItemId>/review
*/
export async function createPullRequest(connection: Connection, workItemId: string): Promise<any> {
if (!workItemId) {
throw new Error('Work item ID is required to create pull request.');
}

const path = `/services/data/${API_VERSION}/connect/devops/workItems/${workItemId}/review`;
try {
const response = await connection.request({
method: 'POST',
url: path,
body: JSON.stringify({}),
headers: { 'Content-Type': 'application/json' }
});
return {
success: true,
pullRequestResult: response ?? {},
message: 'Pull request created successfully',
workItemId
};
} catch (error: any) {
const data = error.response?.data ?? error.body ?? error;
const errorMessage = (typeof data === 'object' && data?.message) || error.message;
throw new Error(`Failed to create pull request: ${errorMessage}`);
}
}
Loading