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
39 changes: 38 additions & 1 deletion docs/PLUGIN_API_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,46 @@ need a source change, a recompile, or both · `tooling` = API-stability
milestone. **[verified]** = read from the checked-in ABI dump. **[reconstructed]**
= diffed from `plugin-api/src` history (predates the dump; symbol-accurate).

### 26.36 — unreleased
### 26.40 — unreleased
- **added — An embedding capability a backend can declare** _(ADFA-6053)_ **[verified]**
A backend that has an embedding model can now say so. The only embedding entry point
before this was `LlmInferenceService.getEmbeddings(String, String)`, which addresses a
backend by id and hands back a bare `float[]`: the caller learns neither which model
produced the vector nor how long it is, and pays one round trip per text. Indexing a
project is thousands of chunks, so that is thousands of requests, and a stored vector
carries no provenance — swapping the model behind a backend silently degrades every
vector already on disk instead of invalidating it.
`LlmInferenceService.EmbeddingBackend extends LlmBackend` is an optional capability
interface, like `ToolCallingBackend` and `HistoryCapableBackend`: implement it and the
consumer finds it with `instanceof`, there is no flag to set. It declares
`embed(List<String>)` returning `CompletableFuture<List<float[]>>` index-aligned with
the input, `getEmbeddingDimensions()`, and `getEmbeddingModelId()` — the model's
identity, not the backend's, because two models of equal width are mutually
incomparable and a width check alone cannot detect a swap.
The batch either completes whole or fails whole; it never yields a short list, a list
padded with nulls, or a placeholder vector, so a caller can never store a partially-real
batch. `embed` must not block the calling thread and must be safe for concurrent calls
(indexing and a user's query can be in flight at once), and it snapshots the caller's
list before returning, so a caller may reuse or clear its own list as soon as the call
comes back; the caller owns the returned list and arrays outright. It reports every failure by
completing the future exceptionally and throws synchronously only for a caller's own
mistake — `NullPointerException` for a null argument or element, `IllegalArgumentException`
for an empty list. The static `EmbeddingBackend.requireValidBatch(List<String>)` does
those checks and returns the snapshot, so a backend calls it first in `embed`.
Purely additive: a new interface with three new methods and one static helper, nothing
existing changed (the ABI dump diff is seven added lines and no removals), so an already-built `.cgp` keeps
loading and running against the refreshed jar. `getEmbeddings(String, String)` stays —
the Vector-Search plugin is a live caller. Floor `plugin.min_ide_version` at `26.40` if
you implement or consume `EmbeddingBackend`; an older IDE has no such type, and a
consumer's `instanceof` against it there fails to resolve the class.
- **added — `SnippetContribution.language` accepts `kotlin`** _(ADFA-6189)_
The host keys Kotlin snippets under `kt`, so a contribution declaring `kotlin` registered
under a language nothing looks up and never appeared in a `.kt` file. The id is now
lower-cased and `kotlin` is aliased to `kt`; `java`, `kt` and `xml` are unchanged.
Accepted ids are `java`, `kt` (or `kotlin`) and `xml` — anything else registers but is
never queried.

### 26.37 — 2026-09-08
- **added — Build provenance in every `.cgp`** _(ADFA-5394)_ **[verified]**
A plugin artifact now records the commit it was built from, so a crash report or a
support question can be traced back to source. Nothing in the pipeline carried a git
Expand Down Expand Up @@ -97,6 +129,8 @@ milestone. **[verified]** = read from the checked-in ABI dump. **[reconstructed]
either state. Neither can be applied by the IDE
on a plugin's behalf: `Window` has no theme attribute for its type, and a toast is
posted by the system against whatever context built it.

### 26.36 — 2026-09-01
- **added — File-targeted editor save** _(ADFA-5259)_
Save a named file's open buffer and find out whether the bytes actually landed.
`saveCurrentFile` follows whichever tab the user has focused and returns as soon
Expand Down Expand Up @@ -382,3 +416,6 @@ Map any commit to the release that first shipped it:
```bash
git tag --list --contains <sha> | grep -E '^[0-9]{2}\.[0-9]{2}$' | sort -V | head -1
```

When a release is tagged, replace its bucket's `unreleased` with the tag date and move
any entry the tag does not contain up to the next bucket.
2 changes: 1 addition & 1 deletion docs/plugin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The surface a plugin binds to is broader than one module. All of the following a
- Core: `IPlugin` (lifecycle), `PluginContext`, `PluginLogger`, `ServiceRegistry`, `ResourceManager`.
- Extension interfaces plugins **implement**: `UIExtension`, `EditorExtension`, `EditorTabExtension`, `DocumentationExtension`, `BuildActionExtension`, `SnippetExtension`, `ProjectExtension`, `FileOpenExtension`, `SettingsExtension`.
- IDE service interfaces plugins **call** (via `ServiceRegistry.get(X::class.java)`): `IdeProjectService`, `IdeEditorService`, `IdeFileService`, `IdeEnvironmentService`, `IdeArchiveService`, `IdeBuildService`, `IdeUIService`, `IdeEditorTabService`, `IdeTooltipService`, `IdeThemeService`, `IdeFeatureFlagService`, `IdeCommandService`, `IdeTemplateService`, `IdeSnippetService`, `IdeSidebarService`.
- Cross-plugin service interfaces, where **one plugin implements what another calls** (via `SharedServices`): `LlmInferenceService` — implemented by ai-core, called by every AI plugin — together with the types nested in it that a *backend* plugin implements (`LlmBackend`, `HistoryCapableBackend`, `ToolCallingBackend`, `CancellableBackend`, `ConfigurableBackend`) and the value types either side constructs (`ChatMessage`, `LlmConfig`, `LlmResponse`, `SystemPromptRequest`, `ToolDefinition`, `ToolCallRequest`). Also `ToolSourceRegistry` — implemented by ai-core, called by any plugin contributing tools to the agent — with `ToolSource` and `ToolSpec`, which a *contributing* plugin implements, `ToolInvocation`, which ai-core constructs and passes to `ToolSource.invoke`, and `ToolOutcome`, which the source returns.
- Cross-plugin service interfaces, where **one plugin implements what another calls** (via `SharedServices`): `LlmInferenceService` — implemented by ai-core, called by every AI plugin — together with the types nested in it that a *backend* plugin implements (`LlmBackend`, `HistoryCapableBackend`, `ToolCallingBackend`, `CancellableBackend`, `ConfigurableBackend`, `EmbeddingBackend`) and the value types either side constructs (`ChatMessage`, `LlmConfig`, `LlmResponse`, `SystemPromptRequest`, `ToolDefinition`, `ToolCallRequest`). Also `ToolSourceRegistry` — implemented by ai-core, called by any plugin contributing tools to the agent — with `ToolSource` and `ToolSpec`, which a *contributing* plugin implements, `ToolInvocation`, which ai-core constructs and passes to `ToolSource.invoke`, and `ToolOutcome`, which the source returns.
- Utility classes plugins **instantiate**: `KeystoreSecretStore` (AES/GCM over the Android Keystore, alias supplied by the caller). Host-side implementation rather than an interface, so plugins share one copy in the process instead of compiling their own.
- Data classes plugins **construct** (e.g. `MenuItem`, `TabItem`, `EditorTabItem`, `NavigationItem`, `ToolbarAction`, `FabAction`, `PluginBuildAction`, `SnippetContribution`, `PluginTooltipEntry`, `PluginSettingsEntry`).
- Enums / sealed types plugins **reference**: `PluginPermission`, `ShowAsAction`, `ArchiveFormat`, `BuildActionCategory`, `ToolbarActionIds`, `CommandSpec`, `CommandResult`, `ExtractResult`, `KeystoreSecretStore.Stored`. Sealed, so a plugin `when`s over the cases exhaustively — adding one is a **breaking** change, not an additive one.
Expand Down
7 changes: 7 additions & 0 deletions plugin-api/api/plugin-api.api
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,13 @@ public abstract interface class com/itsaky/androidide/plugins/services/LlmInfere
public abstract fun getSettingsFragmentClassName ()Ljava/lang/String;
}

public abstract interface class com/itsaky/androidide/plugins/services/LlmInferenceService$EmbeddingBackend : com/itsaky/androidide/plugins/services/LlmInferenceService$LlmBackend {
Comment thread
jatezzz marked this conversation as resolved.
Resolved
public abstract fun embed (Ljava/util/List;)Ljava/util/concurrent/CompletableFuture;
public abstract fun getEmbeddingDimensions ()I
public abstract fun getEmbeddingModelId ()Ljava/lang/String;
public static fun requireValidBatch (Ljava/util/List;)Ljava/util/List;
}

public abstract interface class com/itsaky/androidide/plugins/services/LlmInferenceService$HistoryCapableBackend : com/itsaky/androidide/plugins/services/LlmInferenceService$LlmBackend {
public abstract fun generateStreamingWithHistory (Ljava/util/List;Ljava/lang/String;Lcom/itsaky/androidide/plugins/services/LlmInferenceService$LlmConfig;Lcom/itsaky/androidide/plugins/services/LlmInferenceService$StreamCallback;)V
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Service for LLM inference operations. Provided by ai-core plugin.
*
* <p>
* {@link LlmBackend} is the one type here that plugins <em>implement</em> rather than call, so it carries only what every backend can answer. Anything a backend may or may not do is a separate interface extending it -- {@link HistoryCapableBackend}, {@link ToolCallingBackend}, {@link CancellableBackend}, {@link ConfigurableBackend} -- and the consumer asks with {@code instanceof} before it calls. A capability is therefore declared by the type, not by a flag a backend can set inconsistently with the methods it overrode.
* {@link LlmBackend} is the one type here that plugins <em>implement</em> rather than call, so it carries only what every backend can answer. Anything a backend may or may not do is a separate interface extending it -- {@link HistoryCapableBackend}, {@link ToolCallingBackend}, {@link CancellableBackend}, {@link ConfigurableBackend}, {@link EmbeddingBackend} -- and the consumer asks with {@code instanceof} before it calls. A capability is therefore declared by the type, not by a flag a backend can set inconsistently with the methods it overrode.
*/
public interface LlmInferenceService {

Expand Down Expand Up @@ -102,6 +102,9 @@ void generateStreamingWithTools(
/**
* Generates embeddings for the given text.
*
* <p>
* Addresses a backend by id and returns a bare vector, so the caller learns neither which model produced it nor how long it is, and pays one round trip per text. {@link EmbeddingBackend} carries both and takes a batch; prefer it for anything a caller stores or repeats. This method stays because plugins already built against it call it.
*
* @param text
* the input text to embed (must not be null)
* @param backendId
Expand Down Expand Up @@ -251,6 +254,85 @@ interface ConfigurableBackend extends LlmBackend {
String getSettingsFragmentClassName();
}

/**
* An {@link LlmBackend} that turns text into vectors.
*
* <p>
* Implementing this is the declaration, exactly as with {@link ToolCallingBackend}: a backend that has no embedding model does not implement it, and the consumer asks with {@code instanceof} before it calls. Nothing here is reachable through {@link LlmInferenceService#getEmbeddings}, which addresses a backend by id and cannot report what produced the vector it returns.
*
* <p>
* The batch is the unit of work, not a convenience over a single-text call. Indexing a project is thousands of chunks, and one round trip per chunk against a remote provider is the difference between a feature that finishes on a phone and one that does not.
*
* <p>
* <b>Failure contract.</b> A batch completes whole or fails whole. The returned future either yields a list the same size as {@code texts}, positionally aligned with it, or completes exceptionally; it never yields a short list, a list padded with nulls, or a list holding a placeholder vector. A caller storing the result would otherwise persist entries it cannot tell apart from real ones, and a vector that is merely plausible never reports itself as wrong -- it just stops matching.
*
* <p>
* <b>Threading.</b> {@link #embed} may be called from any thread and must not block the calling one: start the work and return the future. Implementations must be safe for concurrent calls, because indexing and a user's query can be in flight at once. {@link #getEmbeddingModelId} and {@link #getEmbeddingDimensions} are consulted on the caller's thread, so they answer from state the backend already holds rather than performing I/O.
*
* <p>
* <b>Errors.</b> Neither accessor throws. {@link #embed} reports every failure -- transport, authentication, rate limiting, a model that rejected an input -- by completing the future exceptionally, and throws synchronously only for a caller's own mistake, {@link NullPointerException} for a null argument or element and {@link IllegalArgumentException} for an empty list. A consumer that cannot tell a failure from a refusal to start has to guard both paths at every call site.
*/
interface EmbeddingBackend extends LlmBackend {

/**
* Validates a batch against {@link #embed}'s synchronous contract and snapshots it, so every backend enforces the contract the same way. Call it first in {@code embed}, before starting any work.
*
* @param texts
* the batch as passed to {@link #embed}
* @return a copy of {@code texts} that later caller mutations cannot reach
* @throws IllegalArgumentException
* if {@code texts} is empty
* @throws NullPointerException
* if {@code texts} or any element of it is null
*/
@NonNull
static List<String> requireValidBatch(List<String> texts) {
List<String> batch = new ArrayList<>(Objects.requireNonNull(texts, "texts"));
if (batch.isEmpty()) {
throw new IllegalArgumentException("texts must not be empty");
}
for (String text : batch) {
Objects.requireNonNull(text, "texts must not contain a null element");
}
return batch;
}

/**
* Embeds a batch of texts in one call.
*
* @param texts
* the texts to embed; must not be null, must not be empty, and must contain no null element. The implementation snapshots the list before it returns, so a caller may reuse or clear its own list the moment the call comes back without disturbing the batch in flight.
* @return a future yielding one vector per input, in input order, each of {@link #getEmbeddingDimensions} length -- or completed exceptionally, leaving the whole batch unproduced (never null). The caller owns the returned list and its arrays outright; the implementation must not retain or share them, for example from a cache.
* @throws IllegalArgumentException
* if {@code texts} is empty
* @throws NullPointerException
* if {@code texts} or any element of it is null
*/
@NonNull
CompletableFuture<List<float[]>> embed(@NonNull List<String> texts);
Comment thread
jatezzz marked this conversation as resolved.
Resolved
Comment thread
jatezzz marked this conversation as resolved.
Resolved

/**
* Gets the number of components in every vector this backend produces.
*
* <p>
* Constant for the lifetime of the backend instance, so a consumer may size its storage once. It is not on its own an identity: two unrelated models commonly share a width, and comparing their vectors yields a similarity that looks ordinary and means nothing. Pair it with {@link #getEmbeddingModelId} wherever provenance is recorded.
*
* @return the vector length, always positive
*/
int getEmbeddingDimensions();

/**
* Gets the stable identifier of the model producing these vectors, for example {@code "text-embedding-3-small"}.
*
* <p>
* This is the model's identity, not the backend's -- {@link LlmBackend#getId} names the backend, and one backend may be reconfigured onto a different model without changing it. Vectors from two different models are incomparable whether or not their widths agree, so a consumer that persists vectors records this alongside them and reindexes when it changes. Without it a model swap silently degrades every stored vector instead of invalidating it.
*
* @return the embedding model identifier, never empty
*/
@NonNull
String getEmbeddingModelId();
}

/**
* An {@link LlmBackend} that renders earlier turns of a conversation.
*
Expand Down
Loading
Loading