-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds manage SharePoint Online resources GitHub Copilot Chat command. C…
…loses #255, #331 (#341) ## 🎯 Aim The aim of this PR is to: - improve the general chat prompt to guide the user to the use the correct chat command for the user intent - add a new `/manage` command that will allow to retrieve data from SharePoint ## 📷 Result https://github.com/user-attachments/assets/7a1f1994-95c9-45ca-9015-94fb1a58c715 https://github.com/user-attachments/assets/24a722a7-3770-4252-be14-2a63f818c7d4 ## ✅ What was done - [x] improved general chat prompt - [x] added manage chat command - [x] added script to parse CLI commands to create grounding data for list and get commands for LLM - [x] added separate LLM request to explain the CLI response - [x] improved transfer to `/code` chat command to include previous history context ## 🔗 Related issue Closes #255, #331
- Loading branch information
Showing
12 changed files
with
2,202 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
param ([string[]]$workspacePath) | ||
|
||
$cliLocalProjectPath = "$workspacePath\cli-microsoft365" | ||
|
||
if (-not (Test-Path -Path $cliLocalProjectPath -PathType Container)) { | ||
return | ||
} | ||
|
||
[hashtable]$commandsData = @{} | ||
|
||
$allSpoCommands = Get-ChildItem -Path "$workspacePath\cli-microsoft365\docs\docs\cmd\spo\*.mdx" -Recurse -Force -Exclude "_global*" | ||
|
||
foreach ($command in $allSpoCommands) { | ||
$commandDocs = ConvertFrom-Markdown -Path $command | ||
$html = New-Object -Com 'HTMLFile' | ||
$html.write([ref]$commandDocs.Html) | ||
|
||
$title = $html.all.tags('h1')[0] | ||
$commandTitle = $title.innerText | ||
|
||
if (-not ($commandTitle -match "\b(list|get)$")) { | ||
continue | ||
} | ||
|
||
$titleIndex = @($html.all).IndexOf($title) | ||
|
||
$usage = $html.all.tags('h2') | Where-Object { $_.tagName -eq 'H2' } | Select-Object -First 1 | ||
$usageIndex = @($html.all).IndexOf($usage) | ||
|
||
$commandDescription = @($html.all)[($titleIndex + 1)..($usageIndex - 1)] | ||
$commandDescription = $commandDescription | ForEach-Object { $_.innerText } | ||
|
||
$subTitles = $html.all.tags('h2') | Where-Object { $_.tagName -eq 'H2' } | Select-Object -First 5 | ||
$optionsStartIndex = @($html.all).IndexOf($subTitles[1]) | ||
$optionsEndIndex = @($html.all).IndexOf($subTitles[2]) | ||
$commandOptions = @($html.all)[($optionsStartIndex + 1)..($optionsEndIndex - 1)] | ||
$commandOptions = $commandOptions | Where-Object { $_.nodeName -eq 'CODE' } | ForEach-Object { $_.innerText } | ||
$commandOptions = $commandOptions | ForEach-Object { $_.Replace("`r`n", '') } | ||
|
||
$examples = $subTitles[2].innerText | ||
$examplesStartIndex = @($html.all).IndexOf($subTitles[2]) | ||
$examplesEndIndex = @($html.all).IndexOf($subTitles[3]) | ||
if (-not ($examples -match "Example")) { | ||
$examples = $subTitles[3].innerText | ||
$examplesStartIndex = @($html.all).IndexOf($subTitles[3]) | ||
$examplesEndIndex = @($html.all).IndexOf($subTitles[4]) | ||
} | ||
$commandExamples = @($html.all)[($examplesStartIndex + 1)..($examplesEndIndex - 1)] | ||
$commandExamples = $commandExamples | Where-Object { $_.nodeName -match 'CODE|P' } | ForEach-Object { $_.innerText } | ||
$commandExamples = $commandExamples | Select-Object -Unique | ||
$commandExamples = $commandExamples -split '\r?\n' | ||
$commandExamplesObjects = @() | ||
for ($i = 0; $i -lt $commandExamples.Length; $i += 2) { | ||
$example = $commandExamples[$i] | ||
$description = $commandExamples[$i + 1] | ||
$commandExamplesObject = @{ | ||
Example = $example | ||
Description = $description | ||
} | ||
$commandExamplesObjects += $commandExamplesObject | ||
} | ||
|
||
$commandsData["m365 $commandTitle"] = @{ | ||
Description = $commandDescription | ||
Options = $commandOptions | ||
Examples = $commandExamplesObjects | ||
} | ||
} | ||
|
||
$dataArray = @() | ||
foreach ($key in $commandsData.Keys) { | ||
$orderedHashtable = [ordered]@{ | ||
Command = $key | ||
Description = $commandsData[$key].Description | ||
Options = $commandsData[$key].Options | ||
Examples = $commandsData[$key].Examples | ||
} | ||
$dataArray += $orderedHashtable | ||
} | ||
|
||
$dataArray | ConvertTo-Json -Depth 3 | Out-File "$workspacePath\vscode-viva\src\chat\cli-for-microsoft365-spo-commands.ts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.