Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions rust/contracts/rust-core-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4986,12 +4986,12 @@ and the directories are absolute host paths used only as substitution text.
| `build.detect` | `{ workspaceRoot, plugins: [{ manifest }], options?: { <buildSystemID>: { <optionID>: value } }, instanceOptions?: { <buildSystemID>: { <root>: { <optionID>: value } } }, instanceDefaults?: { <buildSystemID>: { <optionID>: value } }, emptySelections?: { <buildSystemID>: { <root>: [optionID] } }, ignoredPaths?: [pattern] }` | `detection`: `{ instances, rejected: [{ index, error }], shadowed: [{ pluginID, buildSystemID, by }] }`; each instance is `{ id, pluginID, buildSystemID, displayName, root, markers, modelSource, optionFingerprint, options, droppedOptions }` plus `model` or `modelError` for `static` and `hostIntegration` sources; a `provider` source has neither. `options` contains accepted stored values after Core scope/root merging, including explicit empty selections; `droppedOptions` names rejected stored values without rewriting the source document. The scan does not enter a directory `ignoredPaths` names; omitted (or `null`), it is Core's default `[".*"]`, every directory whose name starts with a dot, and `[]` ignores nothing beyond the shared scan policy. Hosts pass `storage.ignoredPaths.patterns` from `build.resolveStoredOptions`. An unusable list rejects with `plugin.build.invalidIgnoredPath` (see `build.editIgnoredPaths`). |
| `build.projectOptions` | `{ document }`, host-read persisted v1 Build options, without a manifest | `document`: validated storage with version 1, systems and optional `ignoredPaths`; options, instance defaults, root values, explicit empty selections and saved custom choices are retained. Missing system fields normalize to empty maps; malformed, unsupported or oversized documents reject with `plugin.build.invalidOptionsDocument`. This pure operation never reads or writes a file and does not replace declared option resolution. |
| `build.resolveStoredOptions` | `{ document, local: { version: 1, document, emptySelections?: { <systemID>: { <root>: [optionID] } } } }`, without a manifest | `storage: { document, local, emptySelections, ignoredPaths: { patterns, source } }`: checked team/local merge; local values override matching keys, unrelated systems/roots/choices stay intact. `ignoredPaths` is the list `build.detect` uses: a local list replaces the team's whole (`source: "local"`), then the team's (`"team"`), then Core's default `[".*"]` (`"default"`). No filesystem I/O. Local documents are machine/workspace preferences, not team files or plugin-native configuration. Their storage syntax is [build-local-options-v1.schema.json](build-local-options-v1.schema.json), with additional cross-field membership and byte limits checked by Core. |
| `build.editStoredOption` | `{ document, local, root, optionID, value, modelValues? }` in the standard manifest/build-system envelope | `edit: { local, options }`: changes one declared local preference. `null` removes the local override and restores team/declaration inheritance. Invalid or partially accepted edits reject before persistence. Workspace multi-selections preserve sibling-only values; explicit per-root empty markers apply only to workspace multi-select declarations. Platforms compare both native source revisions, atomically write only the local document and read back. |
| `build.editStoredOption` | `{ document, local, root, optionID, value?, selectedChoices?, modelValues?, modelDefaults?, modelExcludePrefixes?, modelSelection? }` in the standard manifest/build-system envelope | `edit: { local, options }`: changes one declared local preference. Pass exactly one of raw `value` or positive `selectedChoices` for a multi-select. Explicit `value: null` removes the local override. When the checked set equals the defaults, Core clears the local override only if the edited root would inherit those defaults and sibling-only selections and empty markers would survive. See [the option edit fixture](../fixtures/build/option-edit-v1.json). Invalid or partially accepted edits reject before persistence. Workspace multi-selections preserve sibling-only values; explicit per-root empty markers apply only to workspace multi-select declarations. Platforms compare both native source revisions, atomically write only the local document and read back. |
| `build.editIgnoredPaths` | `{ document, local, patterns: [pattern] \| null }`, without a manifest; `patterns` is required | `edit: { local, ignoredPaths: { patterns, source } }`: the local document with its `ignoredPaths` replaced, or removed for `null` so the team list or the default applies again; `[]` is kept as an explicit choice to ignore nothing. A pattern uses `.gitignore` syntax relative to the workspace root and names directories only: as in one ignore file the last matching pattern decides, `!pattern` keeps a directory even if Git ignores it (the shared scan policy's caches and build outputs stay pruned), a pattern with a `/` before its end is anchored at the root and any other matches a directory name at any depth. At most 256 patterns of at most 1024 bytes; an empty or whitespace-padded entry, a comment, a lone `!`, a control character or an unparsable glob rejects with `plugin.build.invalidIgnoredPath` at `ignoredPaths[<index>]`, the first entry not accepted (`ignoredPaths` when they cannot be compiled together). The team document is only read; an unusable list stored in either document makes it `plugin.build.invalidOptionsDocument`. Platforms publish the local document as for `build.editStoredOption`. |
| `build.invocationPlan` | `{ root, platform: "macos" \| "linux" \| "windows" }` | `invocation`: `{ buildSystemID, root, executables, environmentInputs, runtimeDependencies, version, minimumVersion }` with project-file paths joined to `root`; every runtime dependency with a known probe, host-managed ones included, carries `version: { arguments }` |
| `build.checkToolVersion` | `{ runtime?, output }` | `version`: `{ satisfied, version? }`; `runtime` checks that runtime dependency instead of the tool |
| `build.resolveModelInputs` | `{revision, sources: [{manifest, instances: [{buildSystemID, root, state, model?, options?}]}]}` from installed enabled current-workspace sources | `modelInputs`: version 1 public snapshot with exact optional producer slots, state, normalized projects/targets/content roots, configuration fingerprint and explicitly shared options; no tasks/run/settings/private functions; see the [plugin contract](https://github.com/1lck/Lithe-IDEA/blob/preview/shared/plugins/contract/v1/README.md#optional-read-only-model-inputs) |
| `build.resolveOptions` | `{ options, modelValues? }` | `options`: `{ options: [{ id, displayName, kind, scope?, value, source, choices, allowCustom }], dropped, fingerprint }` |
| `build.resolveOptions` | `{ options?, inheritedOptions?, selectedChoices?, modelValues?, modelDefaults?, modelExcludePrefixes?, modelSelection? }` | `options`: `{ options: [{ id, displayName, kind, scope?, value, selectedChoices?, source, choices: [{ value, title?, fromModel?, custom?, defaultActive? }], allowCustom }], dropped, fingerprint }` |
| `build.configurationPlan` | plan fields and optional host-selected `tool` | `plan.provider` for `lithe/build/configuration`; no mutation, project or output-file parameters |
| `build.decodeConfiguration` | `{ result }` | `configuration`: bounded `litheBuildConfiguration` v1 native sources/fields; see the plugin contract |
| `build.configurationEditPlan` | `{ root, options?, workspaceStateDirectory, outputFile, snapshot, edits: { sourceID, revision, values }, tool? }` | Provider request `lithe/build/editConfiguration`; existing private staging only, no document bytes |
Expand All @@ -5003,16 +5003,29 @@ and the directories are absolute host paths used only as substitution text.
| `build.decodeTestDiscovery` | common plan fields plus canonical `result` | `discovery.tests` with validated `{id, suite, case, project?, target?}` selectors; bounded at 10,000 items/32 MiB, deterministic and exactly runnable; malformed replies reject in full |
| `build.runEntrypointsPlan` | common plan fields plus `file` (workspace-relative, inside the instance), `refresh?`, `tool?`; no project/output file | `plan.provider` for `lithe/build/runEntrypoints` with `file`, only when a run declares `entrypoints: true`; decoder `litheRunEntrypoints` |
| `build.decodeRunEntrypoints` | common plan fields plus canonical `result` | `entrypoints.entrypoints`: `[{run, name, entrypoint, project:{name, path}}]` in the provider's order without exact duplicates; at most 64; each names an entrypoint run, a 1–256 byte name, a 1–4,096 byte entrypoint and a project inside the instance; malformed replies reject in full with `plugin.build.invalidOutput` |
| `build.prepareRunPlan` | common plan fields, `run`, required `project`, `target` (required for a target run, refused for an entrypoint run), `userArguments?`, `launchOptions?`, `workspaceRoot?` (required for an explicit launch cwd); no output file | `plan.provider` for `lithe/build/prepareRun`, selected declaration/tags/paths/options validated; typed launch options must match the run's declared execution kind, a service or task run requires them, and an entrypoint run requires `launchOptions.entrypoint` and sends no `target` |
| `build.prepareRunPlan` | common plan fields, `run`, required `project`, `target` (required for a target run, refused for an entrypoint run), `userArguments?`, `optionOverrides?`, `launchOptions?`, `workspaceRoot?` (required for an explicit launch cwd); no output file | `plan.provider` for `lithe/build/prepareRun`, selected declaration/tags/paths/options validated; typed launch options must match the run's declared execution kind, a service or task run requires them, and an entrypoint run requires `launchOptions.entrypoint` and sends no `target` |
| `build.decodeRunPreparation` | `workspaceRoot`, instance `root`, raw `result`, same optional `launchOptions` | `launch` with portable `{executable:{kind,value},arguments,workingDirectory,environment}`; bounded strings and workspace directory containment, `plugin.build.invalidOutput` on invalid result |
| `build.prepareDebugPlan` | same selected fields as `build.prepareRunPlan`; run declares same-plugin `debug.adapter` | `plan.provider` for `lithe/build/prepareDebug`; no cross-package reference, and launch options are refused: they apply only to running a target |
| `build.decodeDebugPreparation` | `workspaceRoot`, instance `root`, selected `run`, raw `result` | `preparation` with declaration-owned `adapter`, normalized `root`, `program`, `arguments`, `workingDirectory`, `environment`; program is an existing regular file contained in the instance after canonicalization |
| `build.decodeModel` | `{ workspaceRoot, root, output?, outputFile?, result?, options? }`; `result` is the provider's JSON answer | `model`: `{ projects, targets, tasks, contentRoots, optionValues, run }`; `run` entries carry `buildSystem: { id, root, projectID, targetID?, optionFingerprint }` |
| `build.decodeModel` | `{ workspaceRoot, root, output?, outputFile?, result?, options? }`; `result` is the provider's JSON answer | `model`: `{ projects, targets, tasks, contentRoots, optionValues, optionDefaults?, optionExcludePrefixes?, optionSelection?, run }`; `run` entries carry `buildSystem: { id, root, projectID, targetID?, optionFingerprint }` |
| `build.decodeTestResults` | `{ workspaceRoot, root, project?, projects?, output, notBeforeMillis?, suite? }`; without `project` the reports of the root and every listed model project are read | `results`: `{ tests: [{ suite, case, status, message?, durationMillis?, path?, line?, invocations }], summary: { total, passed, failed, errors, skipped }, success }`; repeated invocations of one case merge into the most severe status |
| `build.decodeDiagnostics` | `{ workspaceRoot, root, output }` | `diagnostics`: `[{ path, line, column?, severity, message }]`, deduplicated, inside the workspace only |
| `build.decodeDependencies` | `{ workspaceRoot, root, project?, output?, outputFile?, result? }` | `dependencies`: `{ project, dependencies: [{ name, group?, version?, scope?, properties?, children }], truncated }` |
| `build.syncFingerprint` | `{ workspaceRoot, root, projects, options? }` | `sync`: `{ fingerprint, watch }` |
| `build.modelTree` | `{ model: { projects, targets, tasks }, query?, groupHeadings?: { <group>: heading } }`; `model` is a `build.decodeModel` result, other model fields are ignored | `tree`: `{ project?, nodes, truncated? }`; see below |
| `build.modelTree` | `{ model: { projects, targets, tasks, optionValues?, optionDefaults?, optionExcludePrefixes?, optionSelection? }, options?, query?, groupHeadings?: { <group>: heading } }`; `model` is a `build.decodeModel` result, other model fields are ignored | `tree`: `{ project?, nodes, truncated? }`; see below |

When the plugin reports actual active choices, `build.decodeModel` returns
`optionSelection: { fingerprint, activeChoices: { <optionID>: [...] } }`.
Hosts pass this snapshot as `modelSelection` when resolving or editing options
and in the tree's `model`. Core uses observed choices only when the fingerprint
matches the effective invocation options. An explicit empty array represents
no active choices. Without a matching snapshot the checked state is derived
from the stored options and declared or model defaults. The defaults and
normalized invocation value remain distinct from the tool's observed choices.
To edit per-run build options, pass instance options as `inheritedOptions` and
explicit run choices as `options`. Each run choice replaces its inherited key.
`build.prepareRunPlan` applies the same precedence using instance `options`
and `optionOverrides` returned by `runConfig.providerLaunchInputs`.

Invocation candidates also include `{ kind: "toolchain", toolchainID, root }`.
Hosts resolve them through the same canonical project/subproject
Expand Down Expand Up @@ -5077,10 +5090,13 @@ themselves. It reads no file and starts no process.
matches, keeps everything; the matching `project` then carries
`matched: true`.
- A node is `{ kind, key, label?, detail?, tooltip?, group?, projectID?,
targetID?, taskID?, matched?, children? }`, `kind` one of `project`,
targetID?, taskID?, optionID?, optionValue?, checked?, defaultActive?,
matched?, children? }`, `kind` one of `option`, `optionChoice`, `project`,
`folder`, `task`, `targets`, `target`, `dependencies`, `tests`. `key` is
opaque, unique in the instance and stable across reloads and filters, so
hosts remember open nodes by it. `projectID` and `targetID` are what a task
hosts remember open nodes by it. Each `presentation: "tree"` option with at
least one choice adds an `option` node at the top of `nodes` (whose `detail`
summarizes the checked choices) with `optionChoice` children. `projectID` and `targetID` are what a task
runs on (absent: the whole instance); `taskID` is a declared task's ID or a
model task's ID. `targets`, `dependencies` and `tests` nodes have no label.
- The model may hold at most 2,000 projects and 10,000 targets and 10,000
Expand Down
50 changes: 43 additions & 7 deletions rust/crates/build/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,26 @@ struct ResolveOptionsRequest {
/// Stored option values by option ID.
#[serde(default)]
options: BTreeMap<String, Value>,
/// Lower-priority instance options when editing per-run overrides.
#[serde(default)]
inherited_options: BTreeMap<String, Value>,
/// Positive choices checked in an option editor, encoded into `options`
/// before resolution.
#[serde(default)]
selected_choices: BTreeMap<String, Vec<String>>,
/// The loaded model's `optionValues`; absent before a model exists, so
/// values only the model can confirm are kept rather than dropped.
#[serde(default)]
model_values: Option<BTreeMap<String, Vec<String>>>,
/// The loaded model's `optionDefaults`.
#[serde(default)]
model_defaults: Option<BTreeMap<String, Vec<String>>>,
/// The loaded model's `optionExcludePrefixes`.
#[serde(default)]
model_exclude_prefixes: Option<BTreeMap<String, String>>,
/// The loaded model's observed choices, valid for its option fingerprint.
#[serde(default)]
model_selection: Option<options::ModelOptionSelection>,
}

fn with_build_system<M: BuildManifest, T: DeserializeOwned>(
Expand Down Expand Up @@ -130,15 +146,35 @@ pub fn build_resolve_options_command<M: BuildManifest>(payload: Value) -> Result
"build.resolveOptions",
"options",
|build_system, request: &ResolveOptionsRequest| {
let resolved = options::resolve(
build_system,
&request.options,
request.model_values.as_ref(),
);
Ok(options::describe(
let facts = options::ModelOptionFacts {
values: request.model_values.as_ref(),
defaults: request.model_defaults.as_ref(),
exclude_prefixes: request.model_exclude_prefixes.as_ref(),
};
let mut stored = request.inherited_options.clone();
stored.extend(request.options.clone());
for (id, selected) in &request.selected_choices {
let option = build_system.option(id).ok_or_else(|| {
PluginRejection::new("plugin.build.invalidOption", "Unknown declared option")
})?;
let encoded = options::encode_selected_choices(
option,
selected,
request.inherited_options.contains_key(id),
&facts,
)?;
if encoded.is_null() {
stored.remove(id);
} else {
stored.insert(id.clone(), encoded);
}
}
let resolved = options::resolve_with_facts(build_system, &stored, facts);
Ok(options::describe_with_facts(
build_system,
&resolved,
request.model_values.as_ref(),
facts,
request.model_selection.as_ref(),
))
},
)
Expand Down
20 changes: 16 additions & 4 deletions rust/crates/build/src/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,34 @@ fn instance(
"modelSource": model_source_name(declaration.model.as_ref()),
});
let mut model_values = None;
let mut model_defaults = None;
let mut model_exclude_prefixes = None;
if matches!(declaration.model, Some(ModelSource::Static { .. })) {
let source = source_marker(declaration, workspace, root);
match read_model(declaration, workspace, root, None, None, None).and_then(|model| {
let value = model_value(declaration, &model, root, stored, source.as_deref())?;
Ok((model.option_values, value))
Ok((model, value))
}) {
Ok((values, value)) => {
model_values = Some(values);
Ok((model, value)) => {
model_values = Some(model.option_values);
model_defaults = Some(model.option_defaults);
model_exclude_prefixes = Some(model.option_exclude_prefixes);
instance["model"] = value;
}
Err(error) => {
instance["modelError"] = json!({ "code": error.code, "message": error.message });
}
}
}
let resolved = options::resolve(declaration, stored, model_values.as_ref());
let resolved = options::resolve_with_facts(
declaration,
stored,
options::ModelOptionFacts {
values: model_values.as_ref(),
defaults: model_defaults.as_ref(),
exclude_prefixes: model_exclude_prefixes.as_ref(),
},
);
// Hosts must not recreate scope/default/root merging when handing this
// exact instance to a provider. Explicit empty selections remain chosen.
instance["options"] = json!(resolved.chosen_values);
Expand Down
Loading
Loading