@openforge-app/plugin-sdk 0.1.0 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/backend.d.ts +2 -2
- package/dist/browserSurfaces.d.ts +78 -0
- package/dist/browserSurfaces.js +17 -0
- package/dist/browserSurfacesTesting.d.ts +60 -0
- package/dist/browserSurfacesTesting.js +240 -0
- package/dist/domain.d.ts +74 -15
- package/dist/domain.js +5 -1
- package/dist/fileIcons.d.ts +6 -0
- package/dist/fileIcons.js +84 -0
- package/dist/frontend.d.ts +5 -2
- package/dist/frontend.js +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/manifest.d.ts +80 -2
- package/dist/manifest.js +55 -1
- package/dist/markdown.d.ts +5 -1
- package/dist/markdown.js +67 -18
- package/dist/openforgePackageMetadataSchema.json +80 -4
- package/dist/pluginIconContract.d.ts +3 -0
- package/dist/pluginIconContract.js +12 -0
- package/dist/pluginIcons.d.ts +7 -0
- package/dist/pluginIcons.js +99 -0
- package/dist/publicUiExports.d.mts +16 -0
- package/dist/publicUiExports.mjs +60 -0
- package/dist/svelteHostRuntimeContract.d.mts +1 -0
- package/dist/svelteHostRuntimeContract.mjs +16 -0
- package/dist/testing/backendServicesFake.d.ts +19 -0
- package/dist/testing/backendServicesFake.js +87 -0
- package/dist/testing/commonApiFake.d.ts +23 -0
- package/dist/testing/commonApiFake.js +306 -0
- package/dist/testing/contracts.d.ts +236 -0
- package/dist/testing/contracts.js +1 -0
- package/dist/testing/frontendContributionFake.d.ts +36 -0
- package/dist/testing/frontendContributionFake.js +204 -0
- package/dist/testing/registryFake.d.ts +40 -0
- package/dist/testing/registryFake.js +124 -0
- package/dist/testing/support.d.ts +40 -0
- package/dist/testing/support.js +247 -0
- package/dist/testing.d.ts +3 -223
- package/dist/testing.js +2 -625
- package/dist/types.d.ts +251 -9
- package/dist/types.js +47 -0
- package/dist/ui/Button.svelte +49 -0
- package/dist/ui/Checkbox.svelte +137 -0
- package/dist/ui/FileTypeIcon.svelte +37 -0
- package/dist/ui/MarkdownContent.svelte +71 -11
- package/dist/ui/Modal.svelte +157 -0
- package/dist/ui/PluginPageHeader.svelte +26 -0
- package/dist/ui/PluginSidebarLink.svelte +54 -0
- package/dist/ui/PluginViewState.svelte +76 -0
- package/dist/ui/ResizablePanel.svelte +10 -0
- package/dist/ui/icons/README.md +9 -0
- package/dist/ui/icons/c.svg +1 -0
- package/dist/ui/icons/console.svg +1 -0
- package/dist/ui/icons/cpp.svg +1 -0
- package/dist/ui/icons/csharp.svg +1 -0
- package/dist/ui/icons/css.svg +3 -0
- package/dist/ui/icons/database.svg +1 -0
- package/dist/ui/icons/docker.svg +1 -0
- package/dist/ui/icons/document.svg +4 -0
- package/dist/ui/icons/file.svg +1 -0
- package/dist/ui/icons/folder-open.svg +1 -0
- package/dist/ui/icons/folder.svg +1 -0
- package/dist/ui/icons/git.svg +3 -0
- package/dist/ui/icons/go.svg +1 -0
- package/dist/ui/icons/graphql.svg +20 -0
- package/dist/ui/icons/h.svg +3 -0
- package/dist/ui/icons/html.svg +3 -0
- package/dist/ui/icons/image.svg +3 -0
- package/dist/ui/icons/java.svg +6 -0
- package/dist/ui/icons/javascript.svg +3 -0
- package/dist/ui/icons/json.svg +3 -0
- package/dist/ui/icons/kotlin.svg +1 -0
- package/dist/ui/icons/lock.svg +3 -0
- package/dist/ui/icons/markdown.svg +6 -0
- package/dist/ui/icons/nodejs.svg +6 -0
- package/dist/ui/icons/npm.svg +3 -0
- package/dist/ui/icons/pdf.svg +1 -0
- package/dist/ui/icons/php.svg +1 -0
- package/dist/ui/icons/python.svg +1 -0
- package/dist/ui/icons/react.svg +8 -0
- package/dist/ui/icons/react_ts.svg +8 -0
- package/dist/ui/icons/readme.svg +4 -0
- package/dist/ui/icons/ruby.svg +1 -0
- package/dist/ui/icons/rust.svg +1 -0
- package/dist/ui/icons/sass.svg +3 -0
- package/dist/ui/icons/settings.svg +4 -0
- package/dist/ui/icons/svelte.svg +1 -0
- package/dist/ui/icons/svg.svg +3 -0
- package/dist/ui/icons/swift.svg +1 -0
- package/dist/ui/icons/tune.svg +11 -0
- package/dist/ui/icons/typescript-def.svg +6 -0
- package/dist/ui/icons/typescript.svg +3 -0
- package/dist/ui/icons/vue.svg +1 -0
- package/dist/ui/icons/xml.svg +1 -0
- package/dist/ui/icons/yaml.svg +3 -0
- package/dist/ui/icons/zip.svg +3 -0
- package/dist/vite.js +5 -2
- package/package.json +35 -7
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { BrowserSurfaceVisualFeedback } from '../browserSurfaces';
|
|
2
|
+
import type { TestingOpenForgeRegistryFake } from './registryFake';
|
|
3
|
+
import type { BackendMethodRegistration, BackendOpenForgeAPI, BackgroundServiceRegistration, CommandRegistration, CommandShortcutMetadata, ComposeTaskRequest, ConfigureStartPromptContributionRequest, CreateTaskRequest, FrontendOpenForgeAPI, InjectionPointLocation, JsonValue, NotificationRequest, OpenForgeNavigationRequest, OpenForgePackageMetadata, PluginSettingsSectionRegistration, PluginStorage, PluginTaskPaneTabRegistration, PluginTaskUISectionRegistration, PluginViewRegistration, ShellSpawnRequest, SendTaskFollowUpRequest, StartTaskImplementationRequest, TaskLinkOpenRequest, TaskStartPrefixContext, ExternalReadDirectoryRequest, ExternalReadFileRequest, UserDataDirectoryRequest, UserDataFileRequest, UserDataFileWriteRequest } from '../types';
|
|
4
|
+
import type { Task } from '../domain';
|
|
5
|
+
export type TestingRuntimeScope = 'global' | 'project' | 'task';
|
|
6
|
+
export type TestingRuntimeKind = 'commands' | 'events' | 'views' | 'taskPane' | 'taskUI' | 'settings' | 'backend' | 'background';
|
|
7
|
+
export type TestingMaybePromise<T> = T | Promise<T>;
|
|
8
|
+
export type TestingCommandHandler = (payload?: unknown) => TestingMaybePromise<unknown>;
|
|
9
|
+
export type TestingEventHandler = (payload: unknown) => void;
|
|
10
|
+
export interface TestingOpenForgeApiOptions {
|
|
11
|
+
pluginId?: string;
|
|
12
|
+
projectId?: string | null;
|
|
13
|
+
taskId?: string | null;
|
|
14
|
+
/** The active view key reported by `navigation.get().currentView`. Defaults to `'board'`. */
|
|
15
|
+
viewId?: string;
|
|
16
|
+
packageMetadata?: OpenForgePackageMetadata;
|
|
17
|
+
storage?: PluginStorage;
|
|
18
|
+
/**
|
|
19
|
+
* Tasks returned by `tasks.list`. The mock filters them by the requested
|
|
20
|
+
* `projectId` (when given) and drops `done` tasks unless `includeDone: true`,
|
|
21
|
+
* mirroring the host capability. Defaults to an empty list.
|
|
22
|
+
*/
|
|
23
|
+
tasks?: Task[];
|
|
24
|
+
}
|
|
25
|
+
export interface TestingOpenForgeApiCalls {
|
|
26
|
+
commandInvocations: Array<{
|
|
27
|
+
id: string;
|
|
28
|
+
qualifiedId: string;
|
|
29
|
+
payload: unknown;
|
|
30
|
+
}>;
|
|
31
|
+
globalCommandInvocations: Array<{
|
|
32
|
+
qualifiedId: string;
|
|
33
|
+
payload: unknown;
|
|
34
|
+
}>;
|
|
35
|
+
backendInvocations: Array<{
|
|
36
|
+
method: string;
|
|
37
|
+
qualifiedId: string;
|
|
38
|
+
payload: unknown;
|
|
39
|
+
}>;
|
|
40
|
+
emittedEvents: Array<{
|
|
41
|
+
event: string;
|
|
42
|
+
qualifiedEvent: string;
|
|
43
|
+
payload: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
emittedGlobalEvents: Array<{
|
|
46
|
+
qualifiedEvent: string;
|
|
47
|
+
payload: unknown;
|
|
48
|
+
}>;
|
|
49
|
+
openUrl: string[];
|
|
50
|
+
clipboardWrites: string[];
|
|
51
|
+
taskLinkOpenRequests: TaskLinkOpenRequest[];
|
|
52
|
+
navigationRequests: OpenForgeNavigationRequest[];
|
|
53
|
+
notify: NotificationRequest[];
|
|
54
|
+
taskCreations: CreateTaskRequest[];
|
|
55
|
+
taskComposes: ComposeTaskRequest[];
|
|
56
|
+
startPromptContributionConfigurations: ConfigureStartPromptContributionRequest[];
|
|
57
|
+
taskImplementationStarts: StartTaskImplementationRequest[];
|
|
58
|
+
taskFollowUps: SendTaskFollowUpRequest[];
|
|
59
|
+
taskListRequests: Array<{
|
|
60
|
+
projectId: string | null;
|
|
61
|
+
includeDone: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
taskStatusUpdates: Array<{
|
|
64
|
+
taskId: string;
|
|
65
|
+
status: string;
|
|
66
|
+
}>;
|
|
67
|
+
configWrites: Array<{
|
|
68
|
+
key: string;
|
|
69
|
+
value: JsonValue;
|
|
70
|
+
projectId: string | null;
|
|
71
|
+
}>;
|
|
72
|
+
fsWrites: Array<{
|
|
73
|
+
projectId: string;
|
|
74
|
+
path: string;
|
|
75
|
+
content: string;
|
|
76
|
+
}>;
|
|
77
|
+
fsUserDataReadDirs: UserDataDirectoryRequest[];
|
|
78
|
+
fsUserDataReads: UserDataFileRequest[];
|
|
79
|
+
fsUserDataWrites: UserDataFileWriteRequest[];
|
|
80
|
+
fsExternalReadDirs: ExternalReadDirectoryRequest[];
|
|
81
|
+
fsExternalReads: ExternalReadFileRequest[];
|
|
82
|
+
shellSpawns: ShellSpawnRequest[];
|
|
83
|
+
shellWrites: Array<{
|
|
84
|
+
taskId: string;
|
|
85
|
+
terminalIndex: number;
|
|
86
|
+
data: string;
|
|
87
|
+
}>;
|
|
88
|
+
shellResizes: Array<{
|
|
89
|
+
taskId: string;
|
|
90
|
+
terminalIndex: number;
|
|
91
|
+
cols: number;
|
|
92
|
+
rows: number;
|
|
93
|
+
}>;
|
|
94
|
+
shellKills: Array<{
|
|
95
|
+
taskId: string;
|
|
96
|
+
terminalIndex: number;
|
|
97
|
+
}>;
|
|
98
|
+
shellBuffers: Array<{
|
|
99
|
+
taskId: string;
|
|
100
|
+
terminalIndex: number;
|
|
101
|
+
}>;
|
|
102
|
+
browserSurfaceGetOrCreate: Array<{
|
|
103
|
+
taskId: string;
|
|
104
|
+
id: string;
|
|
105
|
+
initialUrl?: string;
|
|
106
|
+
}>;
|
|
107
|
+
browserSurfaceAttachments: Array<{
|
|
108
|
+
taskId: string;
|
|
109
|
+
id: string;
|
|
110
|
+
element: HTMLElement;
|
|
111
|
+
}>;
|
|
112
|
+
browserSurfaceDetaches: Array<{
|
|
113
|
+
taskId: string;
|
|
114
|
+
id: string;
|
|
115
|
+
}>;
|
|
116
|
+
browserSurfaceDestroys: Array<{
|
|
117
|
+
taskId: string;
|
|
118
|
+
id: string;
|
|
119
|
+
}>;
|
|
120
|
+
browserSurfaceNavigations: Array<{
|
|
121
|
+
taskId: string;
|
|
122
|
+
id: string;
|
|
123
|
+
url: string;
|
|
124
|
+
}>;
|
|
125
|
+
browserSurfaceControls: Array<{
|
|
126
|
+
taskId: string;
|
|
127
|
+
id: string;
|
|
128
|
+
action: 'goBack' | 'goForward' | 'reload' | 'stop';
|
|
129
|
+
}>;
|
|
130
|
+
browserSurfaceSelections: Array<{
|
|
131
|
+
taskId: string;
|
|
132
|
+
id: string;
|
|
133
|
+
}>;
|
|
134
|
+
browserSurfaceFeedbackClears: Array<{
|
|
135
|
+
taskId: string;
|
|
136
|
+
id: string;
|
|
137
|
+
}>;
|
|
138
|
+
browserSurfaceFeedbackReplacements: Array<{
|
|
139
|
+
taskId: string;
|
|
140
|
+
id: string;
|
|
141
|
+
feedback: BrowserSurfaceVisualFeedback[];
|
|
142
|
+
}>;
|
|
143
|
+
browserSurfaceCaptureChecks: Array<{
|
|
144
|
+
taskId: string;
|
|
145
|
+
id: string;
|
|
146
|
+
artifactId: string;
|
|
147
|
+
}>;
|
|
148
|
+
browserSurfaceCaptures: Array<{
|
|
149
|
+
taskId: string;
|
|
150
|
+
id: string;
|
|
151
|
+
}>;
|
|
152
|
+
browserSurfaceCaptureDiscards: Array<{
|
|
153
|
+
taskId: string;
|
|
154
|
+
id: string;
|
|
155
|
+
artifactId: string;
|
|
156
|
+
}>;
|
|
157
|
+
browserSurfaceSessionResets: Array<Record<string, never>>;
|
|
158
|
+
storageGets: Array<{
|
|
159
|
+
scope: TestingRuntimeScope;
|
|
160
|
+
scopeId: string | null;
|
|
161
|
+
key: string;
|
|
162
|
+
}>;
|
|
163
|
+
storageSets: Array<{
|
|
164
|
+
scope: TestingRuntimeScope;
|
|
165
|
+
scopeId: string | null;
|
|
166
|
+
key: string;
|
|
167
|
+
value: JsonValue;
|
|
168
|
+
}>;
|
|
169
|
+
storageDeletes: Array<{
|
|
170
|
+
scope: TestingRuntimeScope;
|
|
171
|
+
scopeId: string | null;
|
|
172
|
+
key: string;
|
|
173
|
+
}>;
|
|
174
|
+
}
|
|
175
|
+
export interface TestingContributionBase {
|
|
176
|
+
id: string;
|
|
177
|
+
qualifiedId: string;
|
|
178
|
+
pluginId: string;
|
|
179
|
+
projectId: string | null;
|
|
180
|
+
}
|
|
181
|
+
export type TestingCommandContribution = TestingContributionBase & CommandRegistration & {
|
|
182
|
+
title: string;
|
|
183
|
+
icon?: string;
|
|
184
|
+
shortcut?: CommandShortcutMetadata;
|
|
185
|
+
handler: TestingCommandHandler;
|
|
186
|
+
};
|
|
187
|
+
export type TestingEventListenerContribution = TestingContributionBase & {
|
|
188
|
+
handler: TestingEventHandler;
|
|
189
|
+
global: boolean;
|
|
190
|
+
};
|
|
191
|
+
export type TestingViewContribution = TestingContributionBase & PluginViewRegistration;
|
|
192
|
+
export type TestingTaskPaneTabContribution = TestingContributionBase & PluginTaskPaneTabRegistration;
|
|
193
|
+
export type TestingTaskUISectionContribution = TestingContributionBase & PluginTaskUISectionRegistration;
|
|
194
|
+
export type TestingSettingsSectionContribution = TestingContributionBase & PluginSettingsSectionRegistration;
|
|
195
|
+
export type TestingBackendMethodContribution = TestingContributionBase & {
|
|
196
|
+
registration: BackendMethodRegistration;
|
|
197
|
+
};
|
|
198
|
+
export type TestingBackgroundServiceContribution = TestingContributionBase & BackgroundServiceRegistration & {
|
|
199
|
+
started: boolean;
|
|
200
|
+
};
|
|
201
|
+
export interface TestingInjectionPointContribution {
|
|
202
|
+
id: string;
|
|
203
|
+
location: InjectionPointLocation;
|
|
204
|
+
}
|
|
205
|
+
export interface TestingTaskStartPrefixProviderContribution {
|
|
206
|
+
id: string;
|
|
207
|
+
title: string;
|
|
208
|
+
order: number;
|
|
209
|
+
provide(context: TaskStartPrefixContext): TestingMaybePromise<string | null>;
|
|
210
|
+
}
|
|
211
|
+
export interface TestingOpenForgeRegistrySnapshot {
|
|
212
|
+
pluginId: string;
|
|
213
|
+
projectId: string | null;
|
|
214
|
+
views: TestingViewContribution[];
|
|
215
|
+
taskPaneTabs: TestingTaskPaneTabContribution[];
|
|
216
|
+
taskUISections: TestingTaskUISectionContribution[];
|
|
217
|
+
settingsSections: TestingSettingsSectionContribution[];
|
|
218
|
+
commands: TestingCommandContribution[];
|
|
219
|
+
eventListeners: TestingEventListenerContribution[];
|
|
220
|
+
backendMethods: TestingBackendMethodContribution[];
|
|
221
|
+
backgroundServices: TestingBackgroundServiceContribution[];
|
|
222
|
+
injectionPoints: TestingInjectionPointContribution[];
|
|
223
|
+
taskStartPrefixProviders: TestingTaskStartPrefixProviderContribution[];
|
|
224
|
+
}
|
|
225
|
+
export type MockFrontendOpenForgeAPI = FrontendOpenForgeAPI & {
|
|
226
|
+
readonly __testing: {
|
|
227
|
+
readonly calls: TestingOpenForgeApiCalls;
|
|
228
|
+
readonly registry: TestingOpenForgeRegistryFake;
|
|
229
|
+
};
|
|
230
|
+
};
|
|
231
|
+
export type MockBackendOpenForgeAPI = BackendOpenForgeAPI & {
|
|
232
|
+
readonly __testing: {
|
|
233
|
+
readonly calls: TestingOpenForgeApiCalls;
|
|
234
|
+
readonly registry: TestingOpenForgeRegistryFake;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TaskBrowserSurfaceState } from '../browserSurfaces';
|
|
2
|
+
import type { FrontendOpenForgeAPI } from '../types';
|
|
3
|
+
import { type TestingRegistryServices } from './support';
|
|
4
|
+
import type { TestingInjectionPointContribution, TestingTaskStartPrefixProviderContribution, TestingSettingsSectionContribution, TestingTaskPaneTabContribution, TestingTaskUISectionContribution, TestingViewContribution } from './contracts';
|
|
5
|
+
type TestingFrontendContributionApi = Pick<FrontendOpenForgeAPI, 'browserSurfaces' | 'taskLinks' | 'views' | 'taskUI' | 'taskPane' | 'settings' | 'backend' | 'injectionPoints' | 'taskStart'>;
|
|
6
|
+
export declare class TestingFrontendContributionFake {
|
|
7
|
+
private readonly services;
|
|
8
|
+
private readonly invokeBackendMethod;
|
|
9
|
+
private readonly views;
|
|
10
|
+
private readonly taskPaneTabs;
|
|
11
|
+
private readonly taskUISections;
|
|
12
|
+
private readonly settingsSections;
|
|
13
|
+
private readonly injectionPoints;
|
|
14
|
+
private readonly taskStartPrefixProviders;
|
|
15
|
+
private readonly browserSurfaces;
|
|
16
|
+
private taskLinkHandler;
|
|
17
|
+
private api;
|
|
18
|
+
constructor(services: TestingRegistryServices, invokeBackendMethod: (method: string, payload?: unknown) => Promise<unknown>);
|
|
19
|
+
createApi(): TestingFrontendContributionApi;
|
|
20
|
+
setBrowserSurfaceState(taskId: string, id: string, patch: Partial<TaskBrowserSurfaceState>): void;
|
|
21
|
+
getSnapshot(): {
|
|
22
|
+
views: TestingViewContribution[];
|
|
23
|
+
taskPaneTabs: TestingTaskPaneTabContribution[];
|
|
24
|
+
taskUISections: TestingTaskUISectionContribution[];
|
|
25
|
+
settingsSections: TestingSettingsSectionContribution[];
|
|
26
|
+
injectionPoints: TestingInjectionPointContribution[];
|
|
27
|
+
taskStartPrefixProviders: TestingTaskStartPrefixProviderContribution[];
|
|
28
|
+
};
|
|
29
|
+
private registerView;
|
|
30
|
+
private registerTaskPaneTab;
|
|
31
|
+
private registerTaskUISection;
|
|
32
|
+
private registerSettingsSection;
|
|
33
|
+
private registerTaskStartPrefixProvider;
|
|
34
|
+
private registerInjectionPoint;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { createTestingBrowserSurfaces } from '../browserSurfacesTesting';
|
|
2
|
+
import { isAllowedBrowserSurfaceUrl } from '../browserSurfaces';
|
|
3
|
+
import { assertFunction, assertTitle, createDisposable, } from './support';
|
|
4
|
+
export class TestingFrontendContributionFake {
|
|
5
|
+
services;
|
|
6
|
+
invokeBackendMethod;
|
|
7
|
+
views = new Map();
|
|
8
|
+
taskPaneTabs = new Map();
|
|
9
|
+
taskUISections = new Map();
|
|
10
|
+
settingsSections = new Map();
|
|
11
|
+
injectionPoints = new Map();
|
|
12
|
+
taskStartPrefixProviders = new Map();
|
|
13
|
+
browserSurfaces;
|
|
14
|
+
taskLinkHandler = null;
|
|
15
|
+
api = null;
|
|
16
|
+
constructor(services, invokeBackendMethod) {
|
|
17
|
+
this.services = services;
|
|
18
|
+
this.invokeBackendMethod = invokeBackendMethod;
|
|
19
|
+
this.browserSurfaces = createTestingBrowserSurfaces(services.calls);
|
|
20
|
+
}
|
|
21
|
+
createApi() {
|
|
22
|
+
if (this.api)
|
|
23
|
+
return this.api;
|
|
24
|
+
const api = {
|
|
25
|
+
browserSurfaces: this.browserSurfaces.api,
|
|
26
|
+
taskLinks: {
|
|
27
|
+
open: async (request) => {
|
|
28
|
+
this.services.calls.taskLinkOpenRequests.push(request);
|
|
29
|
+
if (!isAllowedBrowserSurfaceUrl(request.url)) {
|
|
30
|
+
throw new Error('Task links must use a valid HTTP(S) URL');
|
|
31
|
+
}
|
|
32
|
+
if (this.taskLinkHandler === null) {
|
|
33
|
+
this.services.calls.openUrl.push(request.url);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const result = await this.taskLinkHandler(request);
|
|
37
|
+
if (result === 'declined') {
|
|
38
|
+
this.services.calls.openUrl.push(request.url);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (result !== 'handled') {
|
|
42
|
+
throw new Error(`Task link handler returned an invalid result: ${String(result)}`);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
registerHandler: (handler) => {
|
|
46
|
+
if (this.taskLinkHandler !== null) {
|
|
47
|
+
throw new Error('A Task link handler is already registered');
|
|
48
|
+
}
|
|
49
|
+
this.taskLinkHandler = handler;
|
|
50
|
+
return createDisposable(() => {
|
|
51
|
+
if (this.taskLinkHandler === handler)
|
|
52
|
+
this.taskLinkHandler = null;
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
views: {
|
|
57
|
+
register: (registration) => this.registerView(registration),
|
|
58
|
+
},
|
|
59
|
+
taskUI: {
|
|
60
|
+
registerTab: (registration) => this.registerTaskPaneTab(registration),
|
|
61
|
+
registerSection: (registration) => this.registerTaskUISection(registration),
|
|
62
|
+
},
|
|
63
|
+
taskPane: {
|
|
64
|
+
registerTab: (registration) => this.registerTaskPaneTab(registration),
|
|
65
|
+
},
|
|
66
|
+
settings: {
|
|
67
|
+
registerSection: (registration) => this.registerSettingsSection(registration),
|
|
68
|
+
},
|
|
69
|
+
backend: {
|
|
70
|
+
state: 'ready',
|
|
71
|
+
whenReady: async () => undefined,
|
|
72
|
+
onReady: (handler) => {
|
|
73
|
+
handler();
|
|
74
|
+
return createDisposable(() => undefined);
|
|
75
|
+
},
|
|
76
|
+
invoke: async (method, payload) => this.invokeBackendMethod(method, payload),
|
|
77
|
+
},
|
|
78
|
+
injectionPoints: {
|
|
79
|
+
register: (registration) => this.registerInjectionPoint(registration),
|
|
80
|
+
},
|
|
81
|
+
taskStart: {
|
|
82
|
+
registerPrefixProvider: (registration) => this.registerTaskStartPrefixProvider(registration),
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
this.api = api;
|
|
86
|
+
return api;
|
|
87
|
+
}
|
|
88
|
+
setBrowserSurfaceState(taskId, id, patch) {
|
|
89
|
+
this.browserSurfaces.setState(taskId, id, patch);
|
|
90
|
+
}
|
|
91
|
+
getSnapshot() {
|
|
92
|
+
return {
|
|
93
|
+
views: Array.from(this.views.values()),
|
|
94
|
+
taskPaneTabs: Array.from(this.taskPaneTabs.values()),
|
|
95
|
+
taskUISections: Array.from(this.taskUISections.values()),
|
|
96
|
+
settingsSections: Array.from(this.settingsSections.values()),
|
|
97
|
+
injectionPoints: Array.from(this.injectionPoints.values()),
|
|
98
|
+
taskStartPrefixProviders: Array.from(this.taskStartPrefixProviders.values()).sort((left, right) => left.order - right.order || left.id.localeCompare(right.id)),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
registerView(registration) {
|
|
102
|
+
const qualifiedId = this.services.localQualifiedId('views', registration.id);
|
|
103
|
+
assertTitle('views', registration.title);
|
|
104
|
+
assertFunction('views', 'component', registration.component);
|
|
105
|
+
if (registration.navigationComponent !== undefined) {
|
|
106
|
+
assertFunction('views', 'navigationComponent', registration.navigationComponent);
|
|
107
|
+
if (registration.placement !== 'sidebar') {
|
|
108
|
+
throw new Error('views registration custom navigation requires sidebar placement');
|
|
109
|
+
}
|
|
110
|
+
if (!this.services.packageMetadata.requires?.includes('customSidebarNavigation')) {
|
|
111
|
+
throw new Error('views registration custom navigation requires the customSidebarNavigation capability');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
this.services.claims.claim('views', qualifiedId);
|
|
115
|
+
const contribution = {
|
|
116
|
+
...registration,
|
|
117
|
+
id: registration.id.trim(),
|
|
118
|
+
title: registration.title.trim(),
|
|
119
|
+
qualifiedId,
|
|
120
|
+
pluginId: this.services.pluginId,
|
|
121
|
+
projectId: this.services.projectId,
|
|
122
|
+
};
|
|
123
|
+
this.views.set(qualifiedId, contribution);
|
|
124
|
+
return createDisposable(() => {
|
|
125
|
+
this.views.delete(qualifiedId);
|
|
126
|
+
this.services.claims.release('views', qualifiedId);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
registerTaskPaneTab(registration) {
|
|
130
|
+
const qualifiedId = this.services.localQualifiedId('taskPane', registration.id);
|
|
131
|
+
assertTitle('taskPane', registration.title);
|
|
132
|
+
assertFunction('taskPane', 'component', registration.component);
|
|
133
|
+
this.services.claims.claim('taskPane', qualifiedId);
|
|
134
|
+
const contribution = {
|
|
135
|
+
...registration,
|
|
136
|
+
id: registration.id.trim(),
|
|
137
|
+
title: registration.title.trim(),
|
|
138
|
+
qualifiedId,
|
|
139
|
+
pluginId: this.services.pluginId,
|
|
140
|
+
projectId: this.services.projectId,
|
|
141
|
+
};
|
|
142
|
+
this.taskPaneTabs.set(qualifiedId, contribution);
|
|
143
|
+
return createDisposable(() => {
|
|
144
|
+
this.taskPaneTabs.delete(qualifiedId);
|
|
145
|
+
this.services.claims.release('taskPane', qualifiedId);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
registerTaskUISection(registration) {
|
|
149
|
+
const qualifiedId = this.services.localQualifiedId('taskUI', registration.id);
|
|
150
|
+
assertFunction('taskUI', 'component', registration.component);
|
|
151
|
+
this.services.claims.claim('taskUI', qualifiedId);
|
|
152
|
+
const contribution = {
|
|
153
|
+
...registration,
|
|
154
|
+
id: registration.id.trim(),
|
|
155
|
+
qualifiedId,
|
|
156
|
+
pluginId: this.services.pluginId,
|
|
157
|
+
projectId: this.services.projectId,
|
|
158
|
+
};
|
|
159
|
+
this.taskUISections.set(qualifiedId, contribution);
|
|
160
|
+
return createDisposable(() => {
|
|
161
|
+
this.taskUISections.delete(qualifiedId);
|
|
162
|
+
this.services.claims.release('taskUI', qualifiedId);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
registerSettingsSection(registration) {
|
|
166
|
+
const qualifiedId = this.services.localQualifiedId('settings', registration.id);
|
|
167
|
+
assertTitle('settings', registration.title);
|
|
168
|
+
assertFunction('settings', 'component', registration.component);
|
|
169
|
+
this.services.claims.claim('settings', qualifiedId);
|
|
170
|
+
const contribution = {
|
|
171
|
+
...registration,
|
|
172
|
+
id: registration.id.trim(),
|
|
173
|
+
title: registration.title.trim(),
|
|
174
|
+
qualifiedId,
|
|
175
|
+
pluginId: this.services.pluginId,
|
|
176
|
+
projectId: this.services.projectId,
|
|
177
|
+
};
|
|
178
|
+
this.settingsSections.set(qualifiedId, contribution);
|
|
179
|
+
return createDisposable(() => {
|
|
180
|
+
this.settingsSections.delete(qualifiedId);
|
|
181
|
+
this.services.claims.release('settings', qualifiedId);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
registerTaskStartPrefixProvider(registration) {
|
|
185
|
+
this.taskStartPrefixProviders.set(registration.id, {
|
|
186
|
+
id: registration.id,
|
|
187
|
+
title: registration.title,
|
|
188
|
+
order: registration.order ?? 0,
|
|
189
|
+
provide: (context) => registration.provide(context),
|
|
190
|
+
});
|
|
191
|
+
return createDisposable(() => {
|
|
192
|
+
this.taskStartPrefixProviders.delete(registration.id);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
registerInjectionPoint(registration) {
|
|
196
|
+
this.injectionPoints.set(registration.id, {
|
|
197
|
+
id: registration.id,
|
|
198
|
+
location: registration.location,
|
|
199
|
+
});
|
|
200
|
+
return createDisposable(() => {
|
|
201
|
+
this.injectionPoints.delete(registration.id);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TaskBrowserSurfaceState } from '../browserSurfaces';
|
|
2
|
+
import type { BackendPlugin, BackendPluginContext, FrontendPlugin, FrontendPluginContext, OpenForgePackageMetadata, PluginStorage } from '../types';
|
|
3
|
+
import type { MockBackendOpenForgeAPI, MockFrontendOpenForgeAPI, TestingOpenForgeApiCalls, TestingOpenForgeApiOptions, TestingOpenForgeRegistrySnapshot } from './contracts';
|
|
4
|
+
import { TestingSubscriptionSink } from './support';
|
|
5
|
+
export declare class TestingOpenForgeRegistryFake {
|
|
6
|
+
readonly pluginId: string;
|
|
7
|
+
readonly projectId: string | null;
|
|
8
|
+
readonly taskId: string | null;
|
|
9
|
+
readonly viewId: string;
|
|
10
|
+
readonly packageMetadata: OpenForgePackageMetadata;
|
|
11
|
+
readonly calls: TestingOpenForgeApiCalls;
|
|
12
|
+
readonly storage: PluginStorage;
|
|
13
|
+
readonly frontendSubscriptions: TestingSubscriptionSink;
|
|
14
|
+
readonly backendSubscriptions: TestingSubscriptionSink;
|
|
15
|
+
private readonly services;
|
|
16
|
+
private readonly commonApi;
|
|
17
|
+
private readonly frontendContributions;
|
|
18
|
+
private readonly backendServices;
|
|
19
|
+
private cachedFrontendApi;
|
|
20
|
+
private cachedBackendApi;
|
|
21
|
+
constructor(options?: TestingOpenForgeApiOptions);
|
|
22
|
+
get frontendApi(): MockFrontendOpenForgeAPI;
|
|
23
|
+
get backendApi(): MockBackendOpenForgeAPI;
|
|
24
|
+
get snapshot(): TestingOpenForgeRegistrySnapshot;
|
|
25
|
+
createFrontendApi(): MockFrontendOpenForgeAPI;
|
|
26
|
+
createBackendApi(): MockBackendOpenForgeAPI;
|
|
27
|
+
createFrontendContext(): FrontendPluginContext;
|
|
28
|
+
createBackendContext(): BackendPluginContext;
|
|
29
|
+
activateFrontend(plugin: FrontendPlugin): Promise<void>;
|
|
30
|
+
activateBackend(plugin: BackendPlugin): Promise<void>;
|
|
31
|
+
setBrowserSurfaceState(taskId: string, id: string, patch: Partial<TaskBrowserSurfaceState>): void;
|
|
32
|
+
disposeAll(): Promise<void>;
|
|
33
|
+
getSnapshot(): TestingOpenForgeRegistrySnapshot;
|
|
34
|
+
private createContext;
|
|
35
|
+
}
|
|
36
|
+
export declare function createOpenForgeRegistryFake(options?: TestingOpenForgeApiOptions): TestingOpenForgeRegistryFake;
|
|
37
|
+
export declare function createMockOpenForgeApi(options?: TestingOpenForgeApiOptions): MockFrontendOpenForgeAPI;
|
|
38
|
+
export declare function createMockFrontendOpenForgeApi(options?: TestingOpenForgeApiOptions): MockFrontendOpenForgeAPI;
|
|
39
|
+
export declare function createMockBackendOpenForgeApi(options?: TestingOpenForgeApiOptions): MockBackendOpenForgeAPI;
|
|
40
|
+
export declare function createMockPluginContext(options?: TestingOpenForgeApiOptions): FrontendPluginContext;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { TestingBackendServicesFake } from './backendServicesFake';
|
|
2
|
+
import { TestingCommonApiFake } from './commonApiFake';
|
|
3
|
+
import { TestingFrontendContributionFake } from './frontendContributionFake';
|
|
4
|
+
import { TestingRegistryServices, TestingSubscriptionSink, } from './support';
|
|
5
|
+
export class TestingOpenForgeRegistryFake {
|
|
6
|
+
pluginId;
|
|
7
|
+
projectId;
|
|
8
|
+
taskId;
|
|
9
|
+
viewId;
|
|
10
|
+
packageMetadata;
|
|
11
|
+
calls;
|
|
12
|
+
storage;
|
|
13
|
+
frontendSubscriptions = new TestingSubscriptionSink();
|
|
14
|
+
backendSubscriptions = new TestingSubscriptionSink();
|
|
15
|
+
services;
|
|
16
|
+
commonApi;
|
|
17
|
+
frontendContributions;
|
|
18
|
+
backendServices;
|
|
19
|
+
cachedFrontendApi = null;
|
|
20
|
+
cachedBackendApi = null;
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.services = new TestingRegistryServices(options);
|
|
23
|
+
this.pluginId = this.services.pluginId;
|
|
24
|
+
this.projectId = this.services.projectId;
|
|
25
|
+
this.taskId = this.services.taskId;
|
|
26
|
+
this.viewId = this.services.viewId;
|
|
27
|
+
this.packageMetadata = this.services.packageMetadata;
|
|
28
|
+
this.calls = this.services.calls;
|
|
29
|
+
this.storage = this.services.storage;
|
|
30
|
+
this.commonApi = new TestingCommonApiFake(this.services);
|
|
31
|
+
this.backendServices = new TestingBackendServicesFake(this.services);
|
|
32
|
+
this.frontendContributions = new TestingFrontendContributionFake(this.services, (method, payload) => this.backendServices.invokeMethod(method, payload));
|
|
33
|
+
}
|
|
34
|
+
get frontendApi() {
|
|
35
|
+
return this.createFrontendApi();
|
|
36
|
+
}
|
|
37
|
+
get backendApi() {
|
|
38
|
+
return this.createBackendApi();
|
|
39
|
+
}
|
|
40
|
+
get snapshot() {
|
|
41
|
+
return this.getSnapshot();
|
|
42
|
+
}
|
|
43
|
+
createFrontendApi() {
|
|
44
|
+
if (this.cachedFrontendApi)
|
|
45
|
+
return this.cachedFrontendApi;
|
|
46
|
+
const api = {
|
|
47
|
+
...this.commonApi.createApi(),
|
|
48
|
+
...this.frontendContributions.createApi(),
|
|
49
|
+
__testing: {
|
|
50
|
+
calls: this.calls,
|
|
51
|
+
registry: this,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
this.cachedFrontendApi = api;
|
|
55
|
+
return api;
|
|
56
|
+
}
|
|
57
|
+
createBackendApi() {
|
|
58
|
+
if (this.cachedBackendApi)
|
|
59
|
+
return this.cachedBackendApi;
|
|
60
|
+
const api = {
|
|
61
|
+
...this.commonApi.createBackendApi(),
|
|
62
|
+
...this.backendServices.createApi(),
|
|
63
|
+
__testing: {
|
|
64
|
+
calls: this.calls,
|
|
65
|
+
registry: this,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
this.cachedBackendApi = api;
|
|
69
|
+
return api;
|
|
70
|
+
}
|
|
71
|
+
createFrontendContext() {
|
|
72
|
+
return this.createContext(this.frontendSubscriptions);
|
|
73
|
+
}
|
|
74
|
+
createBackendContext() {
|
|
75
|
+
return this.createContext(this.backendSubscriptions);
|
|
76
|
+
}
|
|
77
|
+
async activateFrontend(plugin) {
|
|
78
|
+
await plugin.activate(this.frontendApi, this.createFrontendContext());
|
|
79
|
+
}
|
|
80
|
+
async activateBackend(plugin) {
|
|
81
|
+
const existingServices = this.backendServices.captureBackgroundServiceIds();
|
|
82
|
+
await plugin.activate(this.backendApi, this.createBackendContext());
|
|
83
|
+
await this.backendServices.startNewBackgroundServices(existingServices);
|
|
84
|
+
}
|
|
85
|
+
setBrowserSurfaceState(taskId, id, patch) {
|
|
86
|
+
this.frontendContributions.setBrowserSurfaceState(taskId, id, patch);
|
|
87
|
+
}
|
|
88
|
+
async disposeAll() {
|
|
89
|
+
await this.backendSubscriptions.disposeAll();
|
|
90
|
+
await this.frontendSubscriptions.disposeAll();
|
|
91
|
+
}
|
|
92
|
+
getSnapshot() {
|
|
93
|
+
return {
|
|
94
|
+
pluginId: this.pluginId,
|
|
95
|
+
projectId: this.projectId,
|
|
96
|
+
...this.frontendContributions.getSnapshot(),
|
|
97
|
+
...this.commonApi.getSnapshot(),
|
|
98
|
+
...this.backendServices.getSnapshot(),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
createContext(subscriptions) {
|
|
102
|
+
return {
|
|
103
|
+
pluginId: this.pluginId,
|
|
104
|
+
apiVersion: 1,
|
|
105
|
+
packageMetadata: this.packageMetadata,
|
|
106
|
+
subscriptions,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export function createOpenForgeRegistryFake(options = {}) {
|
|
111
|
+
return new TestingOpenForgeRegistryFake(options);
|
|
112
|
+
}
|
|
113
|
+
export function createMockOpenForgeApi(options = {}) {
|
|
114
|
+
return createMockFrontendOpenForgeApi(options);
|
|
115
|
+
}
|
|
116
|
+
export function createMockFrontendOpenForgeApi(options = {}) {
|
|
117
|
+
return createOpenForgeRegistryFake(options).frontendApi;
|
|
118
|
+
}
|
|
119
|
+
export function createMockBackendOpenForgeApi(options = {}) {
|
|
120
|
+
return createOpenForgeRegistryFake(options).backendApi;
|
|
121
|
+
}
|
|
122
|
+
export function createMockPluginContext(options = {}) {
|
|
123
|
+
return createOpenForgeRegistryFake(options).createFrontendContext();
|
|
124
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AgentCommandMetadata, CommandDescriptor, Disposable, JsonValue, OpenForgeContextSnapshot, OpenForgeNavigationRequest, OpenForgeNavigationSnapshot, OpenForgePackageMetadata, PluginStorage, StartPromptContribution, SubscriptionSink } from '../types';
|
|
2
|
+
import type { Task } from '../domain';
|
|
3
|
+
import type { TestingCommandContribution, TestingMaybePromise, TestingOpenForgeApiCalls, TestingOpenForgeApiOptions, TestingRuntimeKind } from './contracts';
|
|
4
|
+
export declare function createDisposable(dispose: () => TestingMaybePromise<void>): Disposable;
|
|
5
|
+
export declare class TestingSubscriptionSink implements SubscriptionSink {
|
|
6
|
+
readonly subscriptions: Disposable[];
|
|
7
|
+
add(subscription: Disposable | (() => void)): void;
|
|
8
|
+
disposeAll(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createTestingCalls(): TestingOpenForgeApiCalls;
|
|
11
|
+
export declare function createMemoryPluginStorage(calls?: TestingOpenForgeApiCalls): PluginStorage;
|
|
12
|
+
export declare function commandDescriptor(command: TestingCommandContribution): CommandDescriptor;
|
|
13
|
+
export declare function normalizeAgentCommandMetadata(metadata: unknown): AgentCommandMetadata | undefined;
|
|
14
|
+
export declare function isJsonValue(value: unknown, seen?: Set<object>): value is JsonValue;
|
|
15
|
+
export declare function assertLocalId(kind: TestingRuntimeKind, id: string): void;
|
|
16
|
+
export declare function assertTitle(kind: TestingRuntimeKind, title: string): void;
|
|
17
|
+
export declare function assertFunction(kind: TestingRuntimeKind, field: string, value: unknown): void;
|
|
18
|
+
export declare class TestingContributionClaims {
|
|
19
|
+
private readonly ids;
|
|
20
|
+
claim(kind: TestingRuntimeKind, qualifiedId: string): void;
|
|
21
|
+
release(kind: TestingRuntimeKind, qualifiedId: string): void;
|
|
22
|
+
private key;
|
|
23
|
+
}
|
|
24
|
+
export declare class TestingRegistryServices {
|
|
25
|
+
readonly pluginId: string;
|
|
26
|
+
readonly projectId: string | null;
|
|
27
|
+
readonly taskId: string | null;
|
|
28
|
+
readonly viewId: string;
|
|
29
|
+
readonly packageMetadata: OpenForgePackageMetadata;
|
|
30
|
+
readonly calls: TestingOpenForgeApiCalls;
|
|
31
|
+
readonly storage: PluginStorage;
|
|
32
|
+
readonly config: Map<string, JsonValue>;
|
|
33
|
+
readonly seededTasks: Task[];
|
|
34
|
+
readonly claims: TestingContributionClaims;
|
|
35
|
+
constructor(options?: TestingOpenForgeApiOptions);
|
|
36
|
+
localQualifiedId(kind: TestingRuntimeKind, id: string): string;
|
|
37
|
+
getContextSnapshot(): OpenForgeContextSnapshot;
|
|
38
|
+
getNavigationSnapshot(overrides?: OpenForgeNavigationRequest): OpenForgeNavigationSnapshot;
|
|
39
|
+
startPromptContributions(projectId: string): StartPromptContribution[];
|
|
40
|
+
}
|