Add the Command Palette module (#37908)

Windows Command Palette ("CmdPal") is the next iteration of PowerToys Run. With extensibility at its core, the Command Palette is your one-stop launcher to start _anything_.

By default, CmdPal is bound to <kbd>Win+Alt+Space</kbd>.

![cmdpal-pr-002](https://github.com/user-attachments/assets/5077ec04-1009-478a-92d6-0a30989d44ac)
![cmdpal-pr-003](https://github.com/user-attachments/assets/63b4762a-9c19-48eb-9242-18ea48240ba0)

----

This brings the current preview version of CmdPal into the upstream PowerToys repo. There are still lots of bugs to work out, but it's reached the state we're ready to start sharing it with the world. From here, we can further collaborate with the community on the features that are important, and ensuring that we've got a most robust API to enable developers to build whatever extensions they want. 

Most of the built-in PT Run modules have already been ported to CmdPal's extension API. Those include:
* Installed apps
* Shell commands
* File search (powered by the indexer)
* Windows Registry search
* Web search
* Windows Terminal Profiles
* Windows Services
* Windows settings


There are a couple new extensions built-in
* You can now search for packages on `winget` and install them right from the palette. This also powers searching for extensions for the palette
* The calculator has an entirely new implementation. This is currently less feature complete than the original PT Run one - we're looking forward to updating it to be more complete for future ingestion in Windows
* "Bookmarks" allow you to save shortcuts to files, folders, and webpages as top-level commands in the palette. 

We've got a bunch of other samples too, in this repo and elsewhere

### PowerToys specific notes

CmdPal will eventually graduate out of PowerToys to live as its own application, which is why it's implemented just a little differently than most other modules. Enabling CmdPal will install its `msix` package. 

The CI was minorly changed to support CmdPal version numbers independent of PowerToys itself. It doesn't make sense for us to start CmdPal at v0.90, and in the future, we want to be able to rev CmdPal independently of PT itself. 


Closes #3200, closes #3600, closes #7770, closes #34273, closes #36471, closes #20976, closes #14495
  
  
-----

TODOs et al


**Blocking:**
- [ ] Images and descriptions in Settings and OOBE need to be properly defined, as mentioned before
  - [ ] Niels is on it
- [x] Doesn't start properly from PowerToys unless the fix PR is merged.
  - https://github.com/zadjii-msft/PowerToys/pull/556 merged
- [x] I seem to lose focus a lot when I press on some limits, like between the search bar and the results.
  - This is https://github.com/zadjii-msft/PowerToys/issues/427
- [x] Turned off an extension like Calculator and it was still working.
  - Need to get rid of that toggle, it doesn't do anything currently
- [x] `ListViewModel.<FetchItems>` crash
  - Pretty confident that was fixed in https://github.com/zadjii-msft/PowerToys/pull/553

**Not blocking / improvements:**
- Show the shortcut through settings, as mentioned before, or create a button that would open CmdPalette settings.
- When PowerToys starts, CmdPalette is always shown if enabled. That's weird when just starting PowerToys/ logging in to the computer with PowerToys auto-start activated. I think this should at least be a setting.
- Needing to double press a result for it to do the default action seems quirky. If one is already selected, I think just pressing should be enough for it to do the action.
  - This is currently a setting, though we're thinking of changing the setting even more: https://github.com/zadjii-msft/PowerToys/issues/392
- There's no URI extension. Was surprised when typing a URL that it only proposed a web search.
- [x] There's no System commands extension. Was expecting to be able to quickly restart the computer by typing restart but it wasn't there.
  - This is in PR https://github.com/zadjii-msft/PowerToys/pull/452  
  
---------

Co-authored-by: joadoumie <98557455+joadoumie@users.noreply.github.com>
Co-authored-by: Jordi Adoumie <jordiadoumie@microsoft.com>
Co-authored-by: Mike Griese <zadjii@gmail.com>
Co-authored-by: Niels Laute <niels.laute@live.nl>
Co-authored-by: Michael Hawker <24302614+michael-hawker@users.noreply.github.com>
Co-authored-by: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com>
Co-authored-by: Seraphima <zykovas91@gmail.com>
Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
Co-authored-by: Kristen Schau <47155823+krschau@users.noreply.github.com>
Co-authored-by: Eric Johnson <ericjohnson327@gmail.com>
Co-authored-by: Ethan Fang <ethanfang@microsoft.com>
Co-authored-by: Yu Leng (from Dev Box) <yuleng@microsoft.com>
Co-authored-by: Clint Rutkas <clint@rutkas.com>
This commit is contained in:
Mike Griese
2025-03-19 03:39:57 -05:00
committed by GitHub
parent a62acf7a71
commit f68f408be3
984 changed files with 69758 additions and 277 deletions

View File

@@ -0,0 +1,102 @@
Param(
[string]$Configuration = "release",
[string]$VersionOfSDK = "0.0.0",
[string]$BuildStep = "all",
[switch]$IsAzurePipelineBuild = $false,
[switch]$Help = $false
)
$StartTime = Get-Date
if ($Help) {
Write-Host @"
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Syntax:
Build.cmd [options]
Description:
Builds the Command Palette SDK
Options:
-Configuration <configuration>
Only build the selected configuration(s)
Example: -Configuration Release
Example: -Configuration "Debug,Release"
-VersionOfSDK <version>
Set the version number of the build sdk nuget package
Example: -VersionOfSDK "1.0.0"
-Help
Display this usage message.
"@
Exit
}
$ErrorActionPreference = "Stop"
$buildPlatforms = "x64","arm64"
$msbuildPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
if ($IsAzurePipelineBuild) {
$nugetPath = "nuget.exe";
} else {
$nugetPath = (Join-Path $PSScriptRoot "NugetWrapper.cmd")
}
if (($BuildStep -ieq "all") -Or ($BuildStep -ieq "build")) {
& $nugetPath restore (Join-Path $PSScriptRoot "..\..\..\..\..\PowerToys.sln")
Try {
foreach ($config in $Configuration.Split(",")) {
foreach ($platform in $buildPlatforms) {
$msbuildArgs = @(
("$PSScriptRoot\..\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.csproj"),
("/p:Platform="+$platform),
("/p:Configuration="+$config),
("/binaryLogger:CmdPal.Extensions.$platform.$config.binlog"),
("/p:VersionNumber="+$VersionOfSDK)
)
& $msbuildPath $msbuildArgs
}
}
} Catch {
$formatString = "`n{0}`n`n{1}`n`n"
$fields = $_, $_.ScriptStackTrace
Write-Host ($formatString -f $fields) -ForegroundColor RED
Exit 1
}
}
if (($BuildStep -ieq "all") -Or ($BuildStep -ieq "pack")) {
foreach ($config in $Configuration.Split(",")) {
if ($config -eq "release")
{
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\..\_build"
& $nugetPath pack (Join-Path $PSScriptRoot "Microsoft.CommandPalette.Extensions.SDK.nuspec") -Version $VersionOfSDK -OutputDirectory "$PSScriptRoot\..\_build"
} else {
Write-Host @"
WARNING: You are currently building as '$config' configuration.
CmdPalSDK nuget creation only supports 'release' configuration right now.
"@ -ForegroundColor YELLOW
}
}
}
if ($IsAzurePipelineBuild) {
Write-Host "##vso[task.setvariable variable=VersionOfSDK;]$VersionOfSDK"
Write-Host "##vso[task.setvariable variable=VersionOfSDK;isOutput=true;]$VersionOfSDK"
}
$TotalTime = (Get-Date)-$StartTime
$TotalMinutes = [math]::Floor($TotalTime.TotalMinutes)
$TotalSeconds = [math]::Ceiling($TotalTime.TotalSeconds)
Write-Host @"
Total Running Time:
$TotalMinutes minutes and $TotalSeconds seconds
"@ -ForegroundColor CYAN

View File

@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Microsoft.CommandPalette.Extensions</id>
<version>0.0.0</version>
<title>Command Palette Extension SDK</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>Command Palette SDK provides support for creating Command Palette extensions on Windows.</description>
<releaseNotes>Release notes are available in the Power Toys repository.</releaseNotes>
<tags>Command Palette Extension SDK</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<projectUrl>https://github.com/microsoft/powertoys</projectUrl>
<readme>docs\README.md</readme>
<dependencies>
<group targetFramework="net8.0-windows10.0.19041.0">
<dependency id="Microsoft.Windows.CsWinRT" version="2.2.0" />
</group>
</dependencies>
</metadata>
<files>
<!-- TODO : Add NOTICE.txt and LICENSE files -->
<file src="Microsoft.CommandPalette.Extensions.props" target="build\"/>
<file src="Microsoft.CommandPalette.Extensions.targets" target="build\"/>
<!-- AnyCPU Managed dlls from SDK.Lib project -->
<file src="..\Microsoft.CommandPalette.Extensions.Toolkit\x64\release\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.dll" target="lib\net8.0-windows10.0.19041.0\"/>
<file src="..\Microsoft.CommandPalette.Extensions.Toolkit\x64\release\Microsoft.CommandPalette.Extensions.Toolkit\Microsoft.CommandPalette.Extensions.Toolkit.deps.json" target="lib\net8.0-windows10.0.19041.0\"/>
<!-- Native dlls and winmd from SDK cpp project -->
<!-- TODO: we may not need this, since there are no implementations in the Microsoft.CommandPalette.Extensions namespace -->
<file src="..\Microsoft.CommandPalette.Extensions\x64\release\Microsoft.CommandPalette.Extensions\Microsoft.CommandPalette.Extensions.dll" target="runtimes\win-x64\native\"/>
<file src="..\Microsoft.CommandPalette.Extensions\arm64\release\Microsoft.CommandPalette.Extensions\Microsoft.CommandPalette.Extensions.dll" target="runtimes\win-arm64\native\"/>
<!-- Not putting in the following the lib folder because we don't want plugin project to directly reference the winmd -->
<file src="..\Microsoft.CommandPalette.Extensions\x64\release\Microsoft.CommandPalette.Extensions\Microsoft.CommandPalette.Extensions.winmd" target="winmd\"/>
<file src="..\README.md" target="docs\" />
</files>
</package>

View File

@@ -0,0 +1,5 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CmdPalSDKPackageDir>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..'))</CmdPalSDKPackageDir>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,7 @@
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(CmdPalSDKPackageDir)\winmd\*.winmd" Visible="false">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,13 @@
@echo OFF
setlocal
if "%VisualStudioVersion%" == "" set VisualStudioVersion=15.0
if not exist %TEMP%\nuget.6.4.0.exe (
echo Nuget.exe not found in the temp dir, downloading.
powershell -Command "& { Invoke-WebRequest https://dist.nuget.org/win-x86-commandline/v6.4.0/nuget.exe -outfile $env:TEMP\nuget.6.4.0.exe }"
)
%TEMP%\nuget.6.4.0.exe %*
exit /B %ERRORLEVEL%