From e3e887d6a4fcea8228cfc0df353d4831723e97c2 Mon Sep 17 00:00:00 2001 From: Blomios Date: Sun, 2 Aug 2026 13:35:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(sdk,plugins):=20APIs=20publiques=20lanceme?= =?UTF-8?q?nt=20commandes=20+=20outillage=20+=20=C3=A9v=C3=A9nements=20+?= =?UTF-8?q?=20config=20(#125,#126,#127,#130)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/app-tauri/Cargo.toml | 1 + frontend/src/domain/index.ts | 228 +++++++++++++++++++++++++++++++++++ frontend/src/ports/index.ts | 140 +++++++++++++++++++++ 3 files changed, 369 insertions(+) diff --git a/crates/app-tauri/Cargo.toml b/crates/app-tauri/Cargo.toml index 0318b97..4c3e6fe 100644 --- a/crates/app-tauri/Cargo.toml +++ b/crates/app-tauri/Cargo.toml @@ -56,3 +56,4 @@ vector-onnx = ["infrastructure/vector-onnx", "backend/vector-onnx"] [dev-dependencies] uuid = { workspace = true } async-trait = { workspace = true } +tauri = { workspace = true, features = ["test"] } diff --git a/frontend/src/domain/index.ts b/frontend/src/domain/index.ts index d66c3cb..69f20a2 100644 --- a/frontend/src/domain/index.ts +++ b/frontend/src/domain/index.ts @@ -1760,6 +1760,234 @@ export interface PluginRuntimeContributionCatalog { plugins: PluginRuntimePlugin[]; } +// --------------------------------------------------------------------------- +// Plugin SDK workspace/project-structure API (#124 + #129) +// --------------------------------------------------------------------------- + +/** A UTF-8 workspace file returned by the public plugin workspace API. */ +export interface PluginWorkspaceTextFile { + path: string; + content: string; +} + +/** A binary workspace file returned by the public plugin workspace API. */ +export interface PluginWorkspaceBinaryFile { + path: string; + bytes: Uint8Array; +} + +/** One entry in a plugin-visible workspace directory listing. */ +export interface PluginWorkspaceDirEntry { + name: string; + path: string; + isDir: boolean; +} + +/** Directory listing returned by the public plugin workspace API. */ +export interface PluginWorkspaceDirectoryListing { + path: string; + entries: PluginWorkspaceDirEntry[]; +} + +/** Basic plugin-visible stat result for one workspace path. */ +export interface PluginWorkspaceStat { + path: string; + exists: boolean; + isFile: boolean; + isDir: boolean; + len: number | null; +} + +export type PluginProjectStructureEntryKind = "file" | "directory"; + +/** One bounded project-structure entry returned to plugins. */ +export interface PluginProjectStructureEntry { + path: string; + name: string; + kind: PluginProjectStructureEntryKind; +} + +/** Generic convention detected from marker files. */ +export interface PluginProjectConvention { + id: string; + markerPath: string; +} + +/** Generic logical module inferred from marker files. */ +export interface PluginProjectModule { + path: string; + markerPath: string; + conventionId: string; +} + +/** Bounded, generic project-structure query result for plugins. */ +export interface PluginProjectStructure { + projectId: string; + rootPath: string; + entries: PluginProjectStructureEntry[]; + conventions: PluginProjectConvention[]; + modules: PluginProjectModule[]; + truncated: boolean; +} + +// --------------------------------------------------------------------------- +// Plugin SDK command-task API (#125) +// --------------------------------------------------------------------------- + +export type PluginCommandTaskState = + | "queued" + | "running" + | "waiting" + | "completed" + | "failed" + | "cancelled" + | "expired"; + +/** One command-backed task launched through the public plugin task API. */ +export interface PluginCommandTask { + taskId: string; + ownerAgentId: string; + projectId: string; + kind: string; + state: PluginCommandTaskState; + exitCode: number | null; + summary: string | null; + stdoutTail: string | null; + stderrTail: string | null; + createdAtMs: number; + updatedAtMs: number; +} + +// --------------------------------------------------------------------------- +// Plugin SDK external-toolchain diagnostics API (#126) +// --------------------------------------------------------------------------- + +export type PluginToolStatus = "ok" | "failed" | "missing"; +export type PluginEnvStatus = "ok" | "missing" | "mismatch"; +export type PluginFileKind = "file" | "directory" | "other" | "missing"; +export type PluginExpectedFileKind = "file" | "directory" | "any"; +export type PluginDiagnosticLevel = "info" | "warning" | "error"; + +/** Generic diagnostic result for external tools, env vars and workspace files. */ +export interface PluginToolchainDiagnostic { + projectId: string; + cwd: string; + ok: boolean; + tools: PluginToolDiagnostic[]; + env: PluginEnvDiagnostic[]; + files: PluginFileDiagnostic[]; + messages: PluginDiagnosticMessage[]; +} + +export interface PluginToolDiagnostic { + id: string; + executable: string; + present: boolean; + ok: boolean; + status: PluginToolStatus; + required: boolean; + exitCode: number | null; + version: string | null; + stdout: string | null; + stderr: string | null; + error: string | null; +} + +export interface PluginEnvDiagnostic { + name: string; + present: boolean; + ok: boolean; + required: boolean; + value: string | null; + status: PluginEnvStatus; +} + +export interface PluginFileDiagnostic { + path: string; + exists: boolean; + ok: boolean; + required: boolean; + kind: PluginFileKind; + expectedKind: PluginExpectedFileKind | null; + len: number | null; +} + +export interface PluginDiagnosticMessage { + level: PluginDiagnosticLevel; + message: string; +} + +// --------------------------------------------------------------------------- +// Plugin SDK public event/watch API (#127) +// --------------------------------------------------------------------------- + +export type PluginPublicEventType = "workspaceFileChanged" | "backgroundTaskChanged"; + +export interface PluginEventSubscription { + subscriptionId: string; + projectId: string; + eventTypes: PluginPublicEventType[]; + capacity: number; + retention: "bestEffortBounded" | "disposed" | string; +} + +export interface PluginEventBatch { + subscriptionId: string; + events: PluginPublicEvent[]; + dropped: number; +} + +export type PluginPublicEvent = PluginWorkspaceFileChangedEvent | PluginBackgroundTaskChangedEvent; + +export interface PluginWorkspaceFileChangedEvent { + type: "workspaceFileChanged"; + sequence: number; + occurredAtMs: number; + projectId: string; + path: string; + operation: string; +} + +export interface PluginBackgroundTaskChangedEvent { + type: "backgroundTaskChanged"; + sequence: number; + occurredAtMs: number; + projectId: string; + taskId: string; + ownerAgentId: string; + state: string; +} + +// --------------------------------------------------------------------------- +// Plugin SDK structured configuration documents API (#130) +// --------------------------------------------------------------------------- + +export type JsonValue = + | null + | boolean + | number + | string + | JsonValue[] + | { [key: string]: JsonValue }; + +export type PluginConfigDocumentFormat = "json"; +export type PluginConfigUpdateMode = "mergePatch" | "replace"; + +export interface PluginConfigDocument { + projectId: string; + path: string; + format: PluginConfigDocumentFormat; + value: JsonValue; +} + +export interface PluginConfigDocumentWriteResult { + projectId: string; + path: string; + format: PluginConfigDocumentFormat; + mode: PluginConfigUpdateMode; + bytesWritten: number; +} + /** Manifest declaration of a top-level menu (carnet ยง7.1). */ export interface PluginTopLevelMenuContribution { id: string; diff --git a/frontend/src/ports/index.ts b/frontend/src/ports/index.ts index a3ef41a..0fc6743 100644 --- a/frontend/src/ports/index.ts +++ b/frontend/src/ports/index.ts @@ -43,11 +43,26 @@ import type { PairingCode, PermissionSet, PluginAdmin, + PluginCommandTask, + PluginConfigDocument, + PluginConfigDocumentFormat, + PluginConfigDocumentWriteResult, + PluginConfigUpdateMode, + PluginEventBatch, + PluginEventSubscription, + PluginPublicEventType, + PluginExpectedFileKind, PluginInstallResult, + PluginToolchainDiagnostic, + PluginProjectStructure, PluginReview, PluginRuntimeContributionCatalog, PluginSourceKind, PluginUninstallResult, + PluginWorkspaceBinaryFile, + PluginWorkspaceDirectoryListing, + PluginWorkspaceStat, + PluginWorkspaceTextFile, ProjectMcpToolPermissions, PageDirection, Project, @@ -1361,6 +1376,126 @@ export interface PluginGateway { openPluginsFolder(pluginId?: string): Promise; } +export interface PluginWorkspacePathInput { + projectId: string; + path: string; +} + +export interface PluginWorkspaceWriteTextInput extends PluginWorkspacePathInput { + content: string; +} + +export interface PluginWorkspaceWriteBinaryInput extends PluginWorkspacePathInput { + bytes: Uint8Array; +} + +export interface PluginProjectStructureQuery { + projectId: string; + path?: string; + maxDepth?: number; + maxEntries?: number; +} + +export interface PluginWorkspaceGateway { + readText(input: PluginWorkspacePathInput): Promise; + readBinary(input: PluginWorkspacePathInput): Promise; + writeText(input: PluginWorkspaceWriteTextInput): Promise; + writeBinary(input: PluginWorkspaceWriteBinaryInput): Promise; + listDir(input: PluginWorkspacePathInput): Promise; + stat(input: PluginWorkspacePathInput): Promise; + queryProjectStructure(input: PluginProjectStructureQuery): Promise; +} + +export interface PluginRunCommandInput { + projectId: string; + ownerAgentId: string; + label: string; + command: string; + args?: string[]; + cwd?: string; + env?: Array<[string, string]>; + recordOnly?: boolean; + deadlineMs?: number; +} + +export interface PluginTaskStatusInput { + taskId: string; +} + +export interface PluginTaskGateway { + runCommand(input: PluginRunCommandInput): Promise; + getStatus(input: PluginTaskStatusInput): Promise; +} + +export interface PluginToolRequirementInput { + id: string; + executable: string; + versionArgs?: string[]; + required?: boolean; + env?: Array<[string, string]>; +} + +export interface PluginEnvRequirementInput { + name: string; + required?: boolean; + equals?: string; +} + +export interface PluginFileRequirementInput { + path: string; + required?: boolean; + kind?: PluginExpectedFileKind; +} + +export interface PluginToolchainDiagnosticRequest { + projectId: string; + cwd?: string; + tools?: PluginToolRequirementInput[]; + env?: PluginEnvRequirementInput[]; + files?: PluginFileRequirementInput[]; +} + +export interface PluginToolchainGateway { + diagnose(input: PluginToolchainDiagnosticRequest): Promise; +} + +export interface PluginEventSubscribeInput { + projectId: string; + eventTypes?: PluginPublicEventType[]; + capacity?: number; +} + +export interface PluginEventPollInput { + subscriptionId: string; + maxEvents?: number; +} + +export interface PluginEventUnsubscribeInput { + subscriptionId: string; +} + +export interface PluginEventGateway { + subscribe(input: PluginEventSubscribeInput): Promise; + poll(input: PluginEventPollInput): Promise; + unsubscribe(input: PluginEventUnsubscribeInput): Promise; +} + +export interface PluginConfigDocumentReadInput { + projectId: string; + path: string; + format?: PluginConfigDocumentFormat; +} + +export interface PluginConfigDocumentUpdateInput extends PluginConfigDocumentReadInput { + mode?: PluginConfigUpdateMode; + value: PluginConfigDocument["value"]; +} + +export interface PluginConfigGateway { + readDocument(input: PluginConfigDocumentReadInput): Promise; + updateDocument(input: PluginConfigDocumentUpdateInput): Promise; +} + export interface Gateways { system: SystemGateway; agent: AgentGateway; @@ -1386,4 +1521,9 @@ export interface Gateways { focusedProject: FocusedProjectGateway; uiPreferences: UiPreferencesGateway; plugin: PluginGateway; + pluginWorkspace: PluginWorkspaceGateway; + pluginTask: PluginTaskGateway; + pluginToolchain: PluginToolchainGateway; + pluginEvents: PluginEventGateway; + pluginConfig: PluginConfigGateway; }