Pickle is a Windows-first shell that hosts the real PowerShell 7 engine (Microsoft.PowerShell.SDK, in-process,
custom PSHost) and replaces the interactive experience: its own line editor (syntax highlighting, autosuggestions,
completion menu, fuzzy history), a themeable prompt, Terminal.Gui panels (files, git, jobs, processes, network, network tools, disks, winget, Windows Update,
Task Scheduler, Windows Sandbox, settings, command wizards), built-in network tools, on-demand tool installs, a plugin system,
Linux-syntax translation, aliases and sync.
C# / .NET 10. GitHub repo: Daolyap/Pickle (formerly milkshell); the product, binary (pickle) and namespaces are Pickle.
| What | Command |
|---|---|
| Everything (restore, build with warnings-as-errors, format check, tests) — run before every commit | scripts/check.sh (scripts/check.ps1 on Windows) |
| Fix formatting | scripts/check.sh --fix |
| Only some tests | scripts/check.sh --quick --filter LineEditor |
| Real-terminal end-to-end tests (pty + pyte; ConPTY via pywinpty on Windows) | scripts/check.sh --e2e or python3 tests/Pickle.E2E/run_e2e.py -k vim |
| Run the shell | dotnet run --project src/Pickle (or src/Pickle/bin/Debug/net10.0/pickle) |
| Run one command | pickle -c 'Get-Date' · headless (stdin lines): pickle --headless |
| Single-file binaries | scripts/publish.sh win-x64 linux-x64 → artifacts/publish/<rid>/ (Fedora RPM: packaging/rpm/build-rpm.sh) |
| Code knowledge graph (graphify) | scripts/graph.sh, then graphify query "…" / graphify explain X / graphify path A B |
.NET lives in ~/.dotnet in cloud sessions (the SessionStart hook installs it and sets PATH/DOTNET_ROOT).
Tests use xunit.v3 on Microsoft.Testing.Platform: dotnet test --solution Pickle.slnx, filters go after --
(e.g. -- --filter-method "*Snapshot*"). Isolate state with PICKLE_HOME=<dir> when running the binary by hand.
Diagrams (projects, data flow, trust boundaries, feature → folder): docs/architecture.md. Hubs, communities and
cross-file links from graphify: docs/graph-report.md (the full graphify-out/graph.json is git-ignored; rebuild it
with scripts/graph.sh in ~10 s and query it instead of grepping when you need "what calls/uses X").
src/Pickle.Abstractions Contracts only (plugins, registries, services, theme/config models, KeyChord, Ansi, TextWidth).
Plugins reference just this. Changing it affects everyone — add, don't break.
src/Pickle.Core The shell engine. Key folders:
Hosting/ PickleHost/UI/RawUI (PSHost), ShellEngine (runspace, IPickleShell), Repl, ProgressPane
Terminal/ ITerminal + ConsoleTerminal. ALL terminal I/O goes through ITerminal.
Input/ LineEditor (ILineEditor + IEditorBuffer), DefaultKeyBindings
Syntax/ Render/ Highlighter (PowerShell tokenizer → styles), frame renderer
History/ Completion/ JSONL history, autosuggest, fuzzy matcher, completion engine + menu overlay
Prompt/ ThemeProvider, PromptEngine, segments
Aliases/ Translation/ Profile/ alias functions, Linux-syntax rewriters + shims, profile loading
Config/ Plugins/ Sync/ Git/ config store, plugin host, sync, git CLI service
System/ Process, network and disk monitors (/proc on Linux, Win32 on Windows) for the system panels
Cmdlets/ [Cmdlet] classes (auto-registered). `pk` = Invoke-PickleCommand
Modules/ Embedded .psm1/.psd1 modules (extracted at startup to DataDir/modules/<hash>)
Contracts/ Internal seams between Core components (IPromptRenderer, IAutosuggestProvider, ...)
PickleRuntime.cs Composition root inside the process; implements IPickleContext
PickleApp.cs Mode dispatch (interactive / -c / file / headless)
src/Pickle.Tui Terminal.Gui v2 panels. PanelHost (IPanelHost), TuiPlugin, Panels/<Feature>/
src/Pickle.Windows Windows services (winget, WUA, Task Scheduler, elevation broker, Windows Terminal fragment)
src/Pickle.Wizards Wizard schema engine + Definitions/*.json (embedded)
src/Pickle.Network Network tools engines (scan, sweep, DNS client, trace, whois, cert, subnet, http, WoL) + pk commands
src/Pickle pickle.exe: Program.cs (arg modes) + BuiltInPlugins.cs (the list of built-in plugins)
tests/Pickle.Testing VirtualTerminal, TestPickle, Snapshot, Fakes/ — shared test doubles
tests/*.Tests xunit.v3 per project · tests/Pickle.E2E pty harness (Python)
themes/*.json Built-in themes (embedded into Pickle.Core)
- Startup:
Program→PickleApp.Run→new PickleRuntime(constructs every component with its final class) →InitializeComponents()(components register actions/commands/segments) →Start()(open runspace, load plugins,OnStarted(), profile) →Repl.Run(). - Components get collaborators from
PickleRuntimelazily (never in constructors). ImplementContracts.IRuntimeComponentforInitialize/OnStarted. - Built-in features are
IPicklePlugins listed insrc/Pickle/BuiltInPlugins.cs; they only seeIPickleContext. - The REPL runs typed lines with
AddScript(line).AddCommand("Out-Default")so native programs own the console.$?/$LASTEXITCODEare read right after (ShellEngine.QueryStatus). - Threading: interactive pipelines run synchronously from the REPL thread.
IPickleShell.InvokeAsyncruns nested when called from inside a pipeline, waits for idle otherwise;ShellTarget.Backgrounduses a runspace pool. - Panels run modally on the REPL thread via
IPanelHost.Show(fresh Terminal.GuiIApplicationeach time) and return aPanelResult(insert text / replace input / run command / cd). - Cmdlets find their runtime with
PickleRuntime.Resolve(Host)(derive fromPickleCmdlet).
- Warnings are errors. Nullable is on. Run
scripts/check.shbefore committing; CI runs it on Linux + Windows. - Windows-only code (winget, WUA COM, Task Scheduler, registry, P/Invoke): mark
[SupportedOSPlatform("windows")]and guard callers withOperatingSystem.IsWindows()— the CA1416 analyzer enforces this. Every Windows service has an interface in Abstractions and a fake intests/Pickle.Testing/Fakesso UI/commands test on Linux. - Never touch
System.ConsoleoutsideConsoleTerminal(and the elevated helper). UseITerminalsoVirtualTerminaltests see everything. - No shell-string injection: pass user values to PowerShell as parameters
(
InvokeAsync("param($p) ...", new Dictionary<string, object?>{["p"]=value})) and to processes viaProcessStartInfo.ArgumentList. When generated script text must embed a value, usePowerShellText.SingleQuote(PowerShell also treats ‘ ’ ‚ ‛ as quotes — never hand-rollReplace("'", "''")). - Never start a program by bare name: resolve it with
Commands.ExecutableLocator.Find(absolute PATH entries only; Windows and .NET's Unix resolver would otherwise run a copy planted in the current directory). Automatic git calls go throughGitService, which also disables repo-configured fsmonitor/filters/textconv. - Package versions live only in
Directory.Packages.props. Don't add packages without need. - New config setting: add a property with a default in
Abstractions/Config.cs(and the JSON schema). - New
pksubcommand: derive fromPickleCommandBase(Abstractions:CommandArgs,CommandOutput,Display.Columns) or implementIPickleCommand; register it in your plugin's/component'sInitialize. Plugin authoring guide:docs/plugins.md(keep it in sync when plugin-facing APIs change). - New cmdlet:
[Cmdlet]class derivingPickleCmdletinPickle.Core/Cmdlets— registration is automatic. - New key action:
KeyBindings.RegisterAction(name, ...); default chord goes inInput/DefaultKeyBindings.cs. - Comments: only for non-obvious why. No multi-paragraph docstrings.
- Recipes for common additions live in
.claude/skills/(add-wizard, add-panel, add-prompt-segment, add-translation, release).
using var t = TestPickle.Create(start: true);gives an isolated runtime with an open runspace and aVirtualTerminal(t.Terminal.Type("ls").Press("Tab", "Enter"),t.Terminal.GetScreenText(),GetStyledScreen()shows colors as«fg=#B5E36B,bold»text«»).- Snapshots:
Snapshot.Match(t.Terminal.GetScreenText())→__snapshots__/<Class>.<Method>.txtnext to the test. First run writes it (commit it!);PICKLE_UPDATE_SNAPSHOTS=1re-records. CI fails on missing snapshots. - Terminal.Gui:
TuiHarness.InitApp()(virtual time + headless ANSI driver on every OS — never a bareapp.Init(), which gets the console driver on Windows CI), input injection (app.InjectKey(...)),StopAfterFirstIteration = true. - E2E: add
test_*functions totests/Pickle.E2E/run_e2e.pyor ane2e_*.pymodule (real pty; covers native programs and panels). CI also runse2e_inputon Windows in a real ConPTY (keep those tests free of Linux-only commands).
- Single-file publish: PowerShell's built-in modules live under
runtimes/<os>/lib/net10.0/Modulesand are added toPSModulePathexplicitly (ShellEngine.FindBundledModulesDirectories). PSResourceGet, ThreadJob and Archive are not in the SDK:src/Pickle/BundledModules.targetsdownloads them (pinned SHA-256) into<output>/Modules/; cache inartifacts/module-cache,-p:PickleBundleModules=falsefor offline builds. NativeAOT is not possible (PowerShell uses reflection/dynamic code). - Terminal.Gui v2 must use the instance model (
Application.Create()); never touch the staticApplication.Init/Run(it throws once the instance model was used in-process). - The Verify snapshot library is intentionally not used (its build-time license check); use
Pickle.Testing.Snapshot. $PSStyleis one static instance per process, shared by every runspace. Tests asserting on it (or other process-wide PowerShell state) must use[Collection(ProcessWideStateCollection.Name)](non-parallel).PSReadLineis not used; a shim module maps commonSet-PSReadLineOptioncalls to Pickle config.