This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,30 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Threading.Tasks;
using Codice.Client.Commands;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class AnnotateTools
{
internal static async Task<List<AnnotatedLine>> GetFileAnnotations(
string filePath,
long revisionId = -1)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
string fullPath = UVCSToolContext.GetFullPath(filePath);
return await UnityVersionControlApiProvider.Instance.GetAnnotations(wkInfo, fullPath, revisionId);
}
internal static async Task<RevisionInfo> GetRevisionInfo(
long revisionId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetRevisionInfo(wkInfo, revisionId);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20182c74c3d7e4592a8dbbd5ec385f0d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
#if AIA_PRESENT
using System.Threading.Tasks;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class BranchTools
{
internal static async Task<BranchInfo> GetBranchInfo(
string branchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetBranchInfo(wkInfo, branchName);
}
internal static async Task CreateBranch(
string branchName,
string comment = null,
string parentBranchName = null,
long changesetId = -1)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.CreateBranch(wkInfo, branchName, comment, parentBranchName, changesetId);
}
internal static async Task RenameBranch(
string branchName,
string newBranchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.RenameBranch(wkInfo, branchName, newBranchName);
}
internal static async Task LaunchSwitchToBranchUI(
string branchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchSwitchToBranchUI(wkInfo, branchName);
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8b317c5d61224f9d9a2210d02cd11fc5
timeCreated: 1776102358
@@ -0,0 +1,17 @@
#if AIA_PRESENT
using System.Threading.Tasks;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class ChangesetTools
{
internal static async Task<ChangesetInfo> GetChangesetInfo(
long changesetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetChangesetInfo(wkInfo, changesetId);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 92c1d3e4bce3245e98922b64c6c91c29
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,148 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Threading.Tasks;
using Codice.CM.Common;
using PlasticGui.WorkspaceWindow.Configuration;
using CodeReviewStatus = Codice.CM.Common.CodeReviewStatus;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class CodeReviewTools
{
internal enum CodeCommentType
{
Change,
Question
}
internal enum ReplyCommentType
{
Answer,
Discard
}
internal static async Task<ReviewInfo> CreateCodeReviewForBranch(
string branchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.CreateCodeReviewForBranch(wkInfo, branchName);
}
internal static async Task<ReviewInfo> CreateCodeReviewForChangeset(
long changesetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.CreateCodeReviewForChangeset(
wkInfo, changesetId);
}
internal static async Task<long> CreateConversationComment(
long reviewId,
string commentText)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.AddCodeReviewComment(
wkInfo, reviewId, -1, -1, "-1", commentText,
CodeReviewCommentType.Conversation);
}
internal static async Task<long> CreateCodeComment(
long reviewId,
long revisionId,
long changesetId,
string locationSpec,
string commentText,
CodeCommentType commentType)
{
CodeReviewCommentType type = commentType == CodeCommentType.Change
? CodeReviewCommentType.Change
: CodeReviewCommentType.Question;
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.AddCodeReviewComment(
wkInfo, reviewId, revisionId, changesetId, locationSpec, commentText, type);
}
internal static async Task<string> GetCodeReviewLink(
long reviewId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetCodeReviewLink(wkInfo, reviewId);
}
internal static async Task AddCurrentUserAsReviewer(
long reviewId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.AddCurrentUserAsReviewer(wkInfo, reviewId);
}
internal static async Task SetReviewStatus(
long reviewId,
CodeReviewStatus status,
string comment)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.UpdateCurrentUserReviewerStatus(
wkInfo, reviewId, status, comment);
}
internal static async Task<List<ReviewInfo>> GetReviewsInStatus(
CodeReviewStatus status,
long targetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
var queryResult = await UnityVersionControlApiProvider.Instance.FindQuery(
wkInfo,
"find review where status = " + (int)status +
" and targetid = " + targetId);
var result = new List<ReviewInfo>();
if (queryResult.Result.Length > 0 && queryResult.Result[0] != null)
{
foreach (ReviewInfo review in queryResult.Result[0])
result.Add(review);
}
return result;
}
internal static async Task<List<CodeReviewCommentInfo>> GetReviewComments(
long reviewId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
var queryResult = await UnityVersionControlApiProvider.Instance.FindQuery(
wkInfo, "find changereviewcomment where reviewid = " + reviewId);
var result = new List<CodeReviewCommentInfo>();
if (queryResult.Result.Length > 0 && queryResult.Result[0] != null)
{
foreach (CodeReviewCommentInfo comment in queryResult.Result[0])
result.Add(comment);
}
return result;
}
internal static async Task ReRequestReview(
long reviewId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ReRequestReview(wkInfo, reviewId);
}
internal static async Task<long> ReplyComment(
long reviewId,
long parentCommentId,
string commentText,
ReplyCommentType replyType)
{
CodeReviewCommentType type = replyType == ReplyCommentType.Discard
? CodeReviewCommentType.Discarded
: CodeReviewCommentType.Comment;
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.ReplyComment(
wkInfo, reviewId, parentCommentId, commentText, type);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7fff45d1f569c420b8f74192089db9b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,107 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Codice.Client.BaseCommands;
using Codice.Client.Commands;
using Unity.AI.Assistant.FunctionCalling;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class DiffTools
{
internal static async Task<List<ClientDiff>> GetBranchDifferences(
string branchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetBranchDifferences(wkInfo, branchName);
}
internal static async Task<List<ClientDiff>> GetChangesetDifferences(
long changesetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetChangesetDifferences(wkInfo, changesetId);
}
internal static async Task<List<ClientDiff>> GetChangesetsDifferences(
long srcChangesetId,
long dstChangesetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetChangesetsDifferences(
wkInfo, srcChangesetId, dstChangesetId);
}
internal static async Task<List<ClientDiff>> GetLabelDifferences(
string labelName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetLabelDifferences(wkInfo, labelName);
}
internal static async Task<List<ClientDiff>> GetShelveDifferences(
long shelveId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetShelveDifferences(wkInfo, shelveId);
}
internal static async Task<List<ChangeInfo>> GetPendingChanges()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetPendingChanges(wkInfo);
}
internal static async Task<Dictionary<long, string>> DownloadRevisionsToFiles(
ToolExecutionContext context,
List<long> revisionIds)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
string tmpDir = GetTempDirName();
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Create, tmpDir);
Directory.CreateDirectory(tmpDir);
string[] destPaths = revisionIds
.Select(id => Path.Combine(tmpDir, "rev_" + id))
.ToArray();
await UnityVersionControlApiProvider.Instance.DownloadRevisionsToFiles(
wkInfo, revisionIds, destPaths);
var result = new Dictionary<long, string>();
for (int i = 0; i < revisionIds.Count; i++)
result[revisionIds[i]] = destPaths[i];
return result;
}
internal static async Task CleanupDiffTempFiles(ToolExecutionContext context)
{
try
{
string tmpDir = GetTempDirName();
if (Directory.Exists(tmpDir))
{
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Delete, tmpDir);
Directory.Delete(tmpDir, true);
}
}
catch (System.Exception ex)
{
UnityEngine.Debug.LogWarning($"Failed to clean up UVCS diff temp files: {ex.Message}");
}
}
static string GetTempDirName()
{
return Path.Combine(UVCSToolContext.GetProjectPath(), TempDirName, DiffTempDirName);
}
const string TempDirName = "Temp";
const string DiffTempDirName = "UVCSDiff";
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b1a0cd79ba7574b54829e9268cf8879c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,20 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Threading.Tasks;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class HistoryTools
{
internal static async Task<List<RepObjectInfo>> GetFileHistory(
string filePath)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
string fullPath = UVCSToolContext.GetFullPath(filePath);
return await UnityVersionControlApiProvider.Instance.GetFileHistory(wkInfo, fullPath);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af0b1b09645584728aee1e67a2308ae2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,77 @@
#if AIA_PRESENT
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Unity.AI.Assistant.FunctionCalling;
using Unity.PlasticSCM.Editor.Assistant.UI.Interactions;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class InteractionTools
{
internal static async Task<string> SelectFromList(
ToolExecutionContext context,
string title,
string message,
string label,
List<string> choices)
{
var interaction = new DropDownInteraction(
title,
message,
label,
"Select",
choices);
try
{
return await context.Interactions.WaitForUser(interaction);
}
catch (OperationCanceledException)
{
throw new OperationCanceledException("User cancelled the selection.");
}
}
internal static async Task<string> SelectOption(
ToolExecutionContext context,
string title,
string message,
List<OptionChoice> options)
{
var interaction = new RadioGroupInteraction(
title,
message,
options);
try
{
return await context.Interactions.WaitForUser(interaction);
}
catch (OperationCanceledException)
{
throw new OperationCanceledException("User cancelled the selection.");
}
}
internal static async Task<bool> AskForConfirmation(
ToolExecutionContext context,
string action,
string detail)
{
var interaction = new ConfirmationInteraction(
action,
detail,
"Confirm",
"Cancel");
var approved = await context.Interactions.WaitForUser(interaction);
if (!approved)
throw new OperationCanceledException("User cancelled the action.");
return true;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2ca5588a9dbe40d9bb6103b561232b5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,44 @@
#if AIA_PRESENT
using System.Threading.Tasks;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class LabelTools
{
internal static async Task<MarkerInfo> CreateLabel(
string labelName,
string comment,
long changesetId = -1)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
var markerInfo = await UnityVersionControlApiProvider.Instance.CreateLabel(
wkInfo, labelName, changesetId, comment);
return markerInfo;
}
internal static async Task RenameLabel(
string labelName,
string newLabelName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.RenameLabel(wkInfo, labelName, newLabelName);
}
internal static async Task ApplyLabel(
string labelName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ApplyLabel(wkInfo, labelName);
}
internal static async Task DeleteLabel(
string labelName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.DeleteLabel(wkInfo, labelName);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 694966d2f478f43cc8689c1a3196780b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Threading.Tasks;
using Codice.CM.Common;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class LockTools
{
internal static async Task<List<LockInfo>> ListLocks()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.ListLocks(wkInfo);
}
internal static async Task<LockRule> GetLockRule()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetLockRule(wkInfo);
}
internal static async Task ReleaseLocks(
List<long> lockIds)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ReleaseLocks(wkInfo, lockIds);
}
internal static async Task RemoveLocks(
List<long> lockIds)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.RemoveLocks(wkInfo, lockIds);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51f820daaf42148c9a1196a13d81c206
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,96 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Threading.Tasks;
using Codice.CM.Common;
using Unity.AI.Assistant.FunctionCalling;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class ProjectManagementTools
{
internal static async Task<List<string>> GetKnownUVCSServers()
{
return await UnityVersionControlApiProvider.Instance.GetKnownServers();
}
internal static async Task<List<RepositoryInfo>> GetAllRepositories(
string server)
{
return await UnityVersionControlApiProvider.Instance.GetAllRepositories(server);
}
internal static async Task<List<RepositoryInfo>> GetAllProjects(
string server)
{
return await UnityVersionControlApiProvider.Instance.GetAllProjects(server);
}
internal static async Task<WorkspaceInfo> GetWorkspaceFromPath(
string path)
{
return await UnityVersionControlApiProvider.Instance.GetWorkspaceFromPath(path);
}
internal static async Task CreateRepository(
string repositoryName,
string server)
{
await UnityVersionControlApiProvider.Instance.CreateRepository(repositoryName, server);
}
internal static async Task<WorkspaceInfo> CreateWorkspace(
ToolExecutionContext context,
string workspaceName,
string workspacePath,
string repositoryName)
{
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Modify, workspacePath);
return await UnityVersionControlApiProvider.Instance.CreateWorkspace(
workspaceName,
workspacePath,
repositoryName);
}
internal static async Task PerformInitialCheckin(ToolExecutionContext context)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Read, wkInfo.ClientPath);
await UnityVersionControlApiProvider.Instance.PerformInitialCheckin(wkInfo);
}
internal static async Task RefreshUIAfterCreateWorkspace()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.RefreshUIAfterCreateWorkspace(wkInfo);
}
internal static async Task<long> CheckinPendingChanges(
ToolExecutionContext context,
string comment)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Modify, wkInfo.ClientPath);
return await UnityVersionControlApiProvider.Instance.CheckinPendingChanges(wkInfo, comment);
}
internal static async Task<long> ShelvePendingChanges(
ToolExecutionContext context,
string comment,
bool undoPendingChangesAfterShelve = false)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Modify, wkInfo.ClientPath);
return await UnityVersionControlApiProvider.Instance.ShelvePendingChanges(
wkInfo, comment, undoPendingChangesAfterShelve);
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3ed71107e5b54d4bb42de7103a3577a9
timeCreated: 1775729843
@@ -0,0 +1,26 @@
#if AIA_PRESENT
using System.Threading.Tasks;
using Codice.CM.Common;
using PlasticGui;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class QueryTools
{
internal static async Task<QueryResult> FindQuery(
string query)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.FindQuery(wkInfo, query);
}
internal static async Task<SelectorInformation> GetWorkspaceConfiguration()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
return await UnityVersionControlApiProvider.Instance.GetSelectorUserInformation(wkInfo);
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ff096cb057cc465abed4e21161cac8b8
timeCreated: 1776096745
@@ -0,0 +1,98 @@
#if AIA_PRESENT
using System.Threading.Tasks;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class UITools
{
internal static async Task RefreshView(
ViewType viewType)
{
await UnityVersionControlApiProvider.Instance.RefreshView(viewType);
}
internal static async Task ShowView(
ViewType viewType)
{
await UnityVersionControlApiProvider.Instance.ShowView(viewType);
}
internal static async Task ShowBranchExplorer()
{
await UnityVersionControlApiProvider.Instance.ShowBranchExplorer();
}
internal static async Task ShowFileHistory(
string filePath)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
string fullPath = UVCSToolContext.GetFullPath(filePath);
await UnityVersionControlApiProvider.Instance.ShowFileHistory(wkInfo, fullPath);
}
internal static async Task ShowBranchesView(
string branchName = null)
{
if (string.IsNullOrEmpty(branchName))
{
await UnityVersionControlApiProvider.Instance.ShowView(ViewType.BranchesView);
return;
}
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowBranchesView(wkInfo, branchName);
}
internal static async Task ShowChangesetsView(
long changesetId = -1)
{
if (changesetId == -1)
{
await UnityVersionControlApiProvider.Instance.ShowView(ViewType.ChangesetsView);
return;
}
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowChangesetsView(wkInfo, changesetId);
}
internal static async Task ShowShelvesView(
long shelveId = -1)
{
if (shelveId == -1)
{
await UnityVersionControlApiProvider.Instance.ShowView(ViewType.ShelvesView);
return;
}
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowShelvesView(wkInfo, shelveId);
}
internal static async Task LaunchMergeFromBranchUI(
string branchName)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchMergeFromBranchUI(wkInfo, branchName);
}
internal static async Task LaunchMergeFromChangesetUI(
long changesetId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchMergeFromChangesetUI(
wkInfo, changesetId);
}
internal static async Task LaunchApplyShelveUI(
long shelveId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchApplyShelveUI(wkInfo, shelveId);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f56e27ecc3894d8db9d599e039eab01
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,331 @@
#if AIA_PRESENT
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using PlasticGui;
using Unity.AI.Assistant.FunctionCalling;
using Unity.Plastic.Newtonsoft.Json.Linq;
using Unity.PlasticSCM.Editor.Assistant.UI.Interactions;
using CodeReviewStatus = Codice.CM.Common.CodeReviewStatus;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class UVCSExecuteTool
{
[AgentTool(
"Single entry point for ALL Unity Version Control (UVCS) operations. "
+ "Pick the 'operation' to run and pass its arguments as a JSON object string in 'parametersJson'. "
+ "Each operation maps to a specific UVCS capability (querying branches/changesets/history/reviews/locks/labels, "
+ "diffing, checkin/shelve, undo/revert, navigating the UVCS UI, and asking the user to choose or confirm). "
+ "Refer to the UVCS tool reference for the exact JSON parameter shape and return value of each operation. "
+ "Example: operation=FindQuery, parametersJson={\"query\":\"find branch where name like 'scm%'\"}. "
+ "Operations that take no parameters can omit 'parametersJson'.",
"Unity.UVCS.Execute")]
internal static async Task<object> Execute(
ToolExecutionContext context,
[ToolParameter("The UVCS operation to run. Must be one of the listed values.")]
UVCSOperation operation,
[ToolParameter("JSON object string with the parameters for the chosen operation "
+ "(e.g. {\"branchName\":\"/main/task001\"}). See the UVCS tool reference for the exact "
+ "shape of each operation. Omit for operations that take no parameters.")]
string parametersJson = null)
{
JObject p = ParseParams(operation, parametersJson);
switch (operation)
{
// Onboarding / project management
case UVCSOperation.GetKnownServers:
return await ProjectManagementTools.GetKnownUVCSServers();
case UVCSOperation.GetAllRepositories:
return await ProjectManagementTools.GetAllRepositories(
GetParam<string>(p, operation, "server"));
case UVCSOperation.GetAllProjects:
return await ProjectManagementTools.GetAllProjects(
GetParam<string>(p, operation, "server"));
case UVCSOperation.GetWorkspaceFromPath:
return await ProjectManagementTools.GetWorkspaceFromPath(
GetParam<string>(p, operation, "path"));
case UVCSOperation.CreateRepository:
await ProjectManagementTools.CreateRepository(
GetParam<string>(p, operation, "repositoryName"),
GetParam<string>(p, operation, "server"));
return null;
case UVCSOperation.CreateWorkspace:
return await ProjectManagementTools.CreateWorkspace(
context,
GetParam<string>(p, operation, "workspaceName"),
GetParam<string>(p, operation, "workspacePath"),
GetParam<string>(p, operation, "repositoryName"));
case UVCSOperation.PerformInitialCheckin:
await ProjectManagementTools.PerformInitialCheckin(context);
return null;
case UVCSOperation.RefreshUIAfterCreateWorkspace:
await ProjectManagementTools.RefreshUIAfterCreateWorkspace();
return null;
case UVCSOperation.CheckinPendingChanges:
return await ProjectManagementTools.CheckinPendingChanges(
context, GetParam<string>(p, operation, "comment"));
case UVCSOperation.ShelvePendingChanges:
return await ProjectManagementTools.ShelvePendingChanges(
context,
GetParam<string>(p, operation, "comment"),
GetOptionalParam(p, "undoPendingChangesAfterShelve", false));
// Query
case UVCSOperation.FindQuery:
return await QueryTools.FindQuery(GetParam<string>(p, operation, "query"));
case UVCSOperation.GetWorkspaceConfiguration:
return await QueryTools.GetWorkspaceConfiguration();
// Branches
case UVCSOperation.GetBranchInfo:
return await BranchTools.GetBranchInfo(GetParam<string>(p, operation, "branchName"));
case UVCSOperation.CreateBranch:
await BranchTools.CreateBranch(
GetParam<string>(p, operation, "branchName"),
GetOptionalParam<string>(p, "comment", null),
GetOptionalParam<string>(p, "parentBranchName", null),
GetOptionalParam(p, "changesetId", -1L));
return null;
case UVCSOperation.RenameBranch:
await BranchTools.RenameBranch(
GetParam<string>(p, operation, "branchName"),
GetParam<string>(p, operation, "newBranchName"));
return null;
case UVCSOperation.LaunchSwitchToBranchUI:
await BranchTools.LaunchSwitchToBranchUI(GetParam<string>(p, operation, "branchName"));
return null;
// Annotate / revisions
case UVCSOperation.GetFileAnnotations:
return await AnnotateTools.GetFileAnnotations(
GetParam<string>(p, operation, "filePath"),
GetOptionalParam(p, "revisionId", -1L));
case UVCSOperation.GetRevisionInfo:
return await AnnotateTools.GetRevisionInfo(GetParam<long>(p, operation, "revisionId"));
// History
case UVCSOperation.GetFileHistory:
return await HistoryTools.GetFileHistory(GetParam<string>(p, operation, "filePath"));
// Diff
case UVCSOperation.GetBranchDifferences:
return await DiffTools.GetBranchDifferences(GetParam<string>(p, operation, "branchName"));
case UVCSOperation.GetChangesetDifferences:
return await DiffTools.GetChangesetDifferences(GetParam<long>(p, operation, "changesetId"));
case UVCSOperation.GetChangesetsDifferences:
return await DiffTools.GetChangesetsDifferences(
GetParam<long>(p, operation, "srcChangesetId"),
GetParam<long>(p, operation, "dstChangesetId"));
case UVCSOperation.GetLabelDifferences:
return await DiffTools.GetLabelDifferences(GetParam<string>(p, operation, "labelName"));
case UVCSOperation.GetShelveDifferences:
return await DiffTools.GetShelveDifferences(GetParam<long>(p, operation, "shelveId"));
case UVCSOperation.GetPendingChanges:
return await DiffTools.GetPendingChanges();
case UVCSOperation.DownloadRevisionsToFiles:
return await DiffTools.DownloadRevisionsToFiles(
context, GetParam<List<long>>(p, operation, "revisionIds"));
case UVCSOperation.CleanupDiffTempFiles:
await DiffTools.CleanupDiffTempFiles(context);
return null;
// Changesets
case UVCSOperation.GetChangesetInfo:
return await ChangesetTools.GetChangesetInfo(GetParam<long>(p, operation, "changesetId"));
// Code review
case UVCSOperation.CreateCodeReviewForBranch:
return await CodeReviewTools.CreateCodeReviewForBranch(
GetParam<string>(p, operation, "branchName"));
case UVCSOperation.CreateCodeReviewForChangeset:
return await CodeReviewTools.CreateCodeReviewForChangeset(
GetParam<long>(p, operation, "changesetId"));
case UVCSOperation.CreateConversationComment:
return await CodeReviewTools.CreateConversationComment(
GetParam<long>(p, operation, "reviewId"),
GetParam<string>(p, operation, "commentText"));
case UVCSOperation.CreateCodeComment:
return await CodeReviewTools.CreateCodeComment(
GetParam<long>(p, operation, "reviewId"),
GetParam<long>(p, operation, "revisionId"),
GetParam<long>(p, operation, "changesetId"),
GetParam<string>(p, operation, "locationSpec"),
GetParam<string>(p, operation, "commentText"),
GetParam<CodeReviewTools.CodeCommentType>(p, operation, "commentType"));
case UVCSOperation.GetCodeReviewLink:
return await CodeReviewTools.GetCodeReviewLink(GetParam<long>(p, operation, "reviewId"));
case UVCSOperation.AddCurrentUserAsReviewer:
await CodeReviewTools.AddCurrentUserAsReviewer(GetParam<long>(p, operation, "reviewId"));
return null;
case UVCSOperation.SetReviewStatus:
await CodeReviewTools.SetReviewStatus(
GetParam<long>(p, operation, "reviewId"),
GetParam<CodeReviewStatus>(p, operation, "status"),
GetParam<string>(p, operation, "comment"));
return null;
case UVCSOperation.GetReviewsInStatus:
return await CodeReviewTools.GetReviewsInStatus(
GetParam<CodeReviewStatus>(p, operation, "status"),
GetParam<long>(p, operation, "targetId"));
case UVCSOperation.GetReviewComments:
return await CodeReviewTools.GetReviewComments(GetParam<long>(p, operation, "reviewId"));
case UVCSOperation.ReplyComment:
return await CodeReviewTools.ReplyComment(
GetParam<long>(p, operation, "reviewId"),
GetParam<long>(p, operation, "parentCommentId"),
GetParam<string>(p, operation, "commentText"),
GetParam<CodeReviewTools.ReplyCommentType>(p, operation, "replyType"));
case UVCSOperation.ReRequestReview:
await CodeReviewTools.ReRequestReview(GetParam<long>(p, operation, "reviewId"));
return null;
// Labels
case UVCSOperation.CreateLabel:
return await LabelTools.CreateLabel(
GetParam<string>(p, operation, "labelName"),
GetParam<string>(p, operation, "comment"),
GetOptionalParam(p, "changesetId", -1L));
case UVCSOperation.RenameLabel:
await LabelTools.RenameLabel(
GetParam<string>(p, operation, "labelName"),
GetParam<string>(p, operation, "newLabelName"));
return null;
case UVCSOperation.ApplyLabel:
await LabelTools.ApplyLabel(GetParam<string>(p, operation, "labelName"));
return null;
case UVCSOperation.DeleteLabel:
await LabelTools.DeleteLabel(GetParam<string>(p, operation, "labelName"));
return null;
// Locks
case UVCSOperation.ListLocks:
return await LockTools.ListLocks();
case UVCSOperation.GetLockRule:
return await LockTools.GetLockRule();
case UVCSOperation.ReleaseLocks:
await LockTools.ReleaseLocks(GetParam<List<long>>(p, operation, "lockIds"));
return null;
case UVCSOperation.RemoveLocks:
await LockTools.RemoveLocks(GetParam<List<long>>(p, operation, "lockIds"));
return null;
// Undo / revert
case UVCSOperation.UndoChanges:
await UndoTools.UndoChanges(context, GetParam<List<string>>(p, operation, "paths"));
return null;
case UVCSOperation.UndoUnchanged:
await UndoTools.UndoUnchanged();
return null;
case UVCSOperation.RevertToRevision:
await UndoTools.RevertToRevision(
context,
GetParam<string>(p, operation, "filePath"),
GetParam<long>(p, operation, "revisionId"));
return null;
// UI navigation
case UVCSOperation.RefreshView:
await UITools.RefreshView(GetParam<ViewType>(p, operation, "viewType"));
return null;
case UVCSOperation.ShowView:
await UITools.ShowView(GetParam<ViewType>(p, operation, "viewType"));
return null;
case UVCSOperation.ShowBranchExplorer:
await UITools.ShowBranchExplorer();
return null;
case UVCSOperation.ShowFileHistory:
await UITools.ShowFileHistory(GetParam<string>(p, operation, "filePath"));
return null;
case UVCSOperation.ShowBranchesView:
await UITools.ShowBranchesView(GetOptionalParam<string>(p, "branchName", null));
return null;
case UVCSOperation.ShowChangesetsView:
await UITools.ShowChangesetsView(GetOptionalParam(p, "changesetId", -1L));
return null;
case UVCSOperation.ShowShelvesView:
await UITools.ShowShelvesView(GetOptionalParam(p, "shelveId", -1L));
return null;
case UVCSOperation.LaunchMergeFromBranchUI:
await UITools.LaunchMergeFromBranchUI(GetParam<string>(p, operation, "branchName"));
return null;
case UVCSOperation.LaunchMergeFromChangesetUI:
await UITools.LaunchMergeFromChangesetUI(GetParam<long>(p, operation, "changesetId"));
return null;
case UVCSOperation.LaunchApplyShelveUI:
await UITools.LaunchApplyShelveUI(GetParam<long>(p, operation, "shelveId"));
return null;
// User interaction
case UVCSOperation.SelectFromList:
return await InteractionTools.SelectFromList(
context,
GetParam<string>(p, operation, "title"),
GetParam<string>(p, operation, "message"),
GetParam<string>(p, operation, "label"),
GetParam<List<string>>(p, operation, "choices"));
case UVCSOperation.SelectOption:
return await InteractionTools.SelectOption(
context,
GetParam<string>(p, operation, "title"),
GetParam<string>(p, operation, "message"),
GetParam<List<OptionChoice>>(p, operation, "options"));
case UVCSOperation.AskForConfirmation:
return await InteractionTools.AskForConfirmation(
context,
GetParam<string>(p, operation, "action"),
GetParam<string>(p, operation, "detail"));
default:
throw new ArgumentException(
"Unknown UVCS operation '" + operation + "'.");
}
}
static JObject ParseParams(UVCSOperation operation, string parametersJson)
{
if (string.IsNullOrWhiteSpace(parametersJson))
return new JObject();
try
{
return JObject.Parse(parametersJson);
}
catch (Exception ex)
{
throw new ArgumentException(
"Could not parse parametersJson for operation '" + operation + "': " + ex.Message +
". Provide a JSON object, for example {\"branchName\":\"/main/task001\"}.");
}
}
static T GetParam<T>(JObject p, UVCSOperation operation, string name)
{
JToken token = p[name];
if (token == null || token.Type == JTokenType.Null)
throw new ArgumentException(
"Operation '" + operation + "' requires parameter '" + name + "' in parametersJson.");
try
{
return token.ToObject<T>();
}
catch (Exception ex)
{
throw new ArgumentException(
"Parameter '" + name + "' for operation '" + operation + "' is invalid: " + ex.Message);
}
}
static T GetOptionalParam<T>(JObject p, string name, T defaultValue)
{
JToken token = p[name];
if (token == null || token.Type == JTokenType.Null)
return defaultValue;
return token.ToObject<T>();
}
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5dfac2b13e9764409aa8a40c87c86404
@@ -0,0 +1,262 @@
#if AIA_PRESENT
using System;
using PlasticGui;
using Unity.AI.Assistant;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
// URL schema for uvcs:// links:
//
// show/changeset/<id> → Open Changesets view, select changeset
// show/branch/<branchName> → Open Branches view, select branch
// show/shelve/<id> → Open Shelves view, select shelve
// show/history/<filePath> → Open file history view
// (filePath is project-relative, e.g. Assets/Foo.cs)
//
// open/<ViewType> → Open a UVCS view tab (uses ViewType enum names)
// open/BranchExplorerView → Open the Branch Explorer window
//
// refresh/<ViewType> → Refresh a UVCS view
//
// merge/branch/<branchName> → Launch merge from branch
// merge/changeset/<id> → Launch merge from changeset
// merge/shelve/<id> → Launch apply shelve UI
[LinkHandler(UVCS_PREFIX)]
internal class UVCSLinkHandler : ILinkHandler
{
const string UVCS_PREFIX = "uvcs";
internal const string k_MalformedLinkMsg =
@"Invalid UVCS link ""{0}"": the link format is not recognized.";
const string k_ActionShow = "show";
const string k_ActionOpen = "open";
const string k_ActionRefresh = "refresh";
const string k_ActionMerge = "merge";
const string k_EntityChangeset = "changeset";
const string k_EntityBranch = "branch";
const string k_EntityShelve = "shelve";
const string k_EntityHistory = "history";
void ILinkHandler.Handle(ILinkHandler.Context context, string prefix, string url)
{
if (prefix != UVCS_PREFIX)
return;
HandleLink(url);
}
internal static void HandleLink(string url)
{
var parts = url.Split(new[] { '/' }, 2);
if (parts.Length < 2)
{
LogMalformedLink(url);
return;
}
string action = parts[0];
string remainder = parts[1];
switch (action)
{
case k_ActionShow:
HandleShow(remainder, url);
break;
case k_ActionOpen:
HandleOpen(remainder, url);
break;
case k_ActionRefresh:
HandleRefresh(remainder, url);
break;
case k_ActionMerge:
HandleMerge(remainder, url);
break;
default:
LogMalformedLink(url);
break;
}
}
static void HandleShow(string remainder, string fullUrl)
{
var parts = remainder.Split(new[] { '/' }, 2);
if (parts.Length < 2 || string.IsNullOrEmpty(parts[1]))
{
LogMalformedLink(fullUrl);
return;
}
string entityType = parts[0];
string entityValue = parts[1];
switch (entityType)
{
case k_EntityChangeset:
if (!long.TryParse(entityValue, out long changesetId))
{
LogMalformedLink(fullUrl);
return;
}
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowChangesetsView(wkInfo, changesetId);
});
break;
case k_EntityBranch:
string branchName = "/" + entityValue;
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowBranchesView(wkInfo, branchName);
});
break;
case k_EntityShelve:
if (!long.TryParse(entityValue, out long shelveId))
{
LogMalformedLink(fullUrl);
return;
}
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowShelvesView(wkInfo, shelveId);
});
break;
case k_EntityHistory:
string fullPath = UVCSToolContext.GetFullPath(entityValue);
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.ShowFileHistory(wkInfo, fullPath);
});
break;
default:
LogMalformedLink(fullUrl);
break;
}
}
static void HandleOpen(string remainder, string fullUrl)
{
var parts = remainder.Split(new[] { '/' }, 2);
string viewName = parts[0];
if (!TryParseViewType(viewName, out ViewType viewType))
{
LogMalformedLink(fullUrl);
return;
}
switch (viewType)
{
case ViewType.BranchExplorerView:
FireAndForget(async () =>
{
await UnityVersionControlApiProvider.Instance.ShowBranchExplorer();
});
break;
default:
FireAndForget(async () =>
{
await UnityVersionControlApiProvider.Instance.ShowView(viewType);
});
break;
}
}
static void HandleRefresh(string remainder, string fullUrl)
{
if (!TryParseViewType(remainder, out ViewType viewType))
{
LogMalformedLink(fullUrl);
return;
}
FireAndForget(async () =>
{
await UnityVersionControlApiProvider.Instance.RefreshView(viewType);
});
}
static void HandleMerge(string remainder, string fullUrl)
{
var parts = remainder.Split(new[] { '/' }, 2);
if (parts.Length < 2 || string.IsNullOrEmpty(parts[1]))
{
LogMalformedLink(fullUrl);
return;
}
string entityType = parts[0];
string entityValue = parts[1];
switch (entityType)
{
case k_EntityBranch:
string branchName = "/" + entityValue;
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchMergeFromBranchUI(wkInfo, branchName);
});
break;
case k_EntityChangeset:
if (!long.TryParse(entityValue, out long changesetId))
{
LogMalformedLink(fullUrl);
return;
}
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchMergeFromChangesetUI(
wkInfo, changesetId);
});
break;
case k_EntityShelve:
if (!long.TryParse(entityValue, out long shelveId))
{
LogMalformedLink(fullUrl);
return;
}
FireAndForget(async () =>
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.LaunchApplyShelveUI(wkInfo, shelveId);
});
break;
default:
LogMalformedLink(fullUrl);
break;
}
}
static bool TryParseViewType(string value, out ViewType viewType)
{
return Enum.TryParse(value, out viewType)
&& Enum.IsDefined(typeof(ViewType), viewType);
}
static void LogMalformedLink(string url)
{
Debug.LogWarningFormat(k_MalformedLinkMsg, url);
}
static async void FireAndForget(Func<System.Threading.Tasks.Task> action)
{
try
{
await action();
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0e803e84de9d4aa4a2ba0fcf7577ab6b
timeCreated: 1776835956
@@ -0,0 +1,100 @@
#if AIA_PRESENT
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
// The set of operations dispatched by UVCSExecuteTool.Execute.
// Each value maps to a specific UVCS tool method. The member names are part of the
// tool contract: they are exposed to the LLM as the allowed values of the 'operation'
// parameter, and the skill/evals refer to them as Unity.UVCS.Execute(<Operation>).
enum UVCSOperation
{
// Onboarding / project management
GetKnownServers,
GetAllRepositories,
GetAllProjects,
GetWorkspaceFromPath,
CreateRepository,
CreateWorkspace,
PerformInitialCheckin,
RefreshUIAfterCreateWorkspace,
CheckinPendingChanges,
ShelvePendingChanges,
// Query
FindQuery,
GetWorkspaceConfiguration,
// Branches
GetBranchInfo,
CreateBranch,
RenameBranch,
LaunchSwitchToBranchUI,
// Annotate / revisions
GetFileAnnotations,
GetRevisionInfo,
// History
GetFileHistory,
// Diff
GetBranchDifferences,
GetChangesetDifferences,
GetChangesetsDifferences,
GetLabelDifferences,
GetShelveDifferences,
GetPendingChanges,
DownloadRevisionsToFiles,
CleanupDiffTempFiles,
// Changesets
GetChangesetInfo,
// Code review
CreateCodeReviewForBranch,
CreateCodeReviewForChangeset,
CreateConversationComment,
CreateCodeComment,
GetCodeReviewLink,
AddCurrentUserAsReviewer,
SetReviewStatus,
GetReviewsInStatus,
GetReviewComments,
ReplyComment,
ReRequestReview,
// Labels
CreateLabel,
RenameLabel,
ApplyLabel,
DeleteLabel,
// Locks
ListLocks,
GetLockRule,
ReleaseLocks,
RemoveLocks,
// Undo / revert
UndoChanges,
UndoUnchanged,
RevertToRevision,
// UI navigation
RefreshView,
ShowView,
ShowBranchExplorer,
ShowFileHistory,
ShowBranchesView,
ShowChangesetsView,
ShowShelvesView,
LaunchMergeFromBranchUI,
LaunchMergeFromChangesetUI,
LaunchApplyShelveUI,
// User interaction
SelectFromList,
SelectOption,
AskForConfirmation
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 86d3b998a081a44079e6548f6d3cf446
@@ -0,0 +1,36 @@
#if AIA_PRESENT
using System;
using System.IO;
using System.Threading.Tasks;
using Codice.CM.Common;
using UnityEngine;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class UVCSToolContext
{
internal static async Task<WorkspaceInfo> GetCurrentWorkspaceAsync()
{
WorkspaceInfo wkInfo = await UnityVersionControlApiProvider.Instance
.GetWorkspaceFromPath(Application.dataPath);
if (wkInfo == null)
throw new ArgumentException(
"No Unity Version Control workspace was found for the current Unity project. " +
"Make sure the project is checked out under a UVCS workspace before invoking UVCS tools.");
return wkInfo;
}
internal static string GetProjectPath()
{
return Path.GetDirectoryName(Application.dataPath);
}
internal static string GetFullPath(string projectRelativePath)
{
return Path.GetFullPath(Path.Combine(GetProjectPath(), projectRelativePath));
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c35635b884e9b433d9ff4a91be986974
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,39 @@
#if AIA_PRESENT
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Unity.AI.Assistant.FunctionCalling;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
static class UndoTools
{
internal static async Task UndoChanges(
ToolExecutionContext context,
List<string> paths)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Modify, wkInfo.ClientPath);
var fullPaths = paths.Select(UVCSToolContext.GetFullPath).ToList();
await UnityVersionControlApiProvider.Instance.UndoChanges(wkInfo, fullPaths);
}
internal static async Task UndoUnchanged()
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
await UnityVersionControlApiProvider.Instance.UndoUnchanged(wkInfo);
}
internal static async Task RevertToRevision(
ToolExecutionContext context,
string filePath,
long revisionId)
{
var wkInfo = await UVCSToolContext.GetCurrentWorkspaceAsync();
string fullPath = UVCSToolContext.GetFullPath(filePath);
await context.Permissions.CheckFileSystemAccess(PermissionItemOperation.Modify, fullPath);
await UnityVersionControlApiProvider.Instance.RevertToRevision(wkInfo, fullPath, revisionId);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d906ae3822c94f0792daca02e35a3f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,25 @@
#if AIA_PRESENT
using Unity.PlasticSCM.Editor.Api;
namespace Unity.PlasticSCM.Editor.Assistant.Tools
{
internal static class UnityVersionControlApiProvider
{
static UnityVersionControlApiProvider()
{
Instance = new UnityVersionControlApi();
}
internal static IUnityVersionControlApi Instance
{
get;
private set;
}
internal static void SetForTesting(IUnityVersionControlApi api)
{
Instance = api;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 60ba29b8797e46d7968dd0be1ae27bb0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: