feat(pdk): define VCS provider API - #2650
Conversation
Merging this PR will improve performance by 39.97%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | get_file_hashes[100] |
1.8 ms | 1.2 ms | +46.49% |
| ⚡ | WallTime | get_file_hashes[1000] |
6.3 ms | 4.7 ms | +33.75% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing lamalex:vcs/pdk-api (c126e71) with develop-2.5 (dac2d61)
| api_struct!( | ||
| /// Opaque provider-defined identity for an exact repository state. | ||
| #[serde(transparent)] | ||
| pub struct VcsStateId(pub String); |
There was a problem hiding this comment.
Maybe just type StateId = String since it doesn't provide any new functionality?
| api_struct!( | ||
| /// Opaque provider expression that resolves to a repository state. | ||
| #[serde(transparent)] | ||
| pub struct VcsReference(pub String); |
| api_struct!( | ||
| /// Provider metadata returned by `register_vcs`. | ||
| #[serde(default)] | ||
| pub struct VcsPluginMetadata { |
| /// establish an observation. User configuration controls whether a plugin | ||
| /// is selected at all; there is no second enabled state after observation. | ||
| #[serde(default)] | ||
| pub struct DetectVcsOutput { |
There was a problem hiding this comment.
It needs to provide the working/worktree dir, and repository root paths, as VirtualPaths.
| /// Provider metadata and exact states pinned by `observe_vcs`. | ||
| pub struct VcsObservation { | ||
| /// Stable provider kind, such as `git` or `jj`. | ||
| pub provider: Id, |
There was a problem hiding this comment.
This is called client on the moon side.
| /// Version of the source-control client used by the provider. | ||
| pub client_version: Option<String>, | ||
| /// Absolute or virtual path to the repository root. | ||
| pub repository_root: String, |
There was a problem hiding this comment.
All path fields need to be VirtualPath.
| pub context: MoonContext, | ||
| /// Canonical path to Moon's hooks directory, relative to the workspace. | ||
| pub hooks_dir: String, | ||
| /// Provider-native hook names that Moon intends to install. |
| /// Keys use `/` separators and must be non-empty, must not contain `.`, | ||
| /// `..`, empty components, backslashes, NULs, or names invalid on the | ||
| /// host platform, and must not be absolute. | ||
| pub changes: BTreeMap<String, VcsChangeMask>, |
| } | ||
| ); | ||
|
|
||
| api_struct!( |
There was a problem hiding this comment.
Probably just use https://crates.io/crates/bitflags
|
|
||
| api_struct!( | ||
| /// Provider metadata and exact states pinned by `observe_vcs`. | ||
| pub struct VcsObservation { |
There was a problem hiding this comment.
Still a bit confused when the observation triggers.
Overview
This PR adds the PDK contract for version control system (VCS) provider plugins.
This PR does not load or run VCS plugins.
Changes
A provider must keep one fixed observation for each plugin instance. Later queries must use that observation. They must not read newer repository state.
Purpose
This contract lets Moon support VCS providers without hard-coded provider logic.
Later PRs will add the plugin host, provider runtime, Git provider, and Jujutsu provider.