@pragma-sh/plugin 0.1.0
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/README.md +27 -0
- package/dist/catalog.cjs +77 -0
- package/dist/catalog.d.cts +363 -0
- package/dist/catalog.d.ts +363 -0
- package/dist/catalog.js +15 -0
- package/dist/icons.cjs +57 -0
- package/dist/icons.d.cts +13 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +10 -0
- package/dist/index.cjs +217 -0
- package/dist/index.d.cts +533 -0
- package/dist/index.d.ts +533 -0
- package/dist/index.js +151 -0
- package/dist/jsx-runtime.cjs +61 -0
- package/dist/jsx-runtime.d.cts +5 -0
- package/dist/jsx-runtime.d.ts +5 -0
- package/dist/jsx-runtime.js +14 -0
- package/dist/react-dom.cjs +73 -0
- package/dist/react-dom.d.cts +12 -0
- package/dist/react-dom.d.ts +12 -0
- package/dist/react-dom.js +26 -0
- package/dist/react.cjs +127 -0
- package/dist/react.d.cts +39 -0
- package/dist/react.d.ts +39 -0
- package/dist/react.js +80 -0
- package/dist/shared/chunk-2jf7fbtp.js +10 -0
- package/dist/shared/chunk-qjw1esw6.js +4 -0
- package/dist/shared/chunk-yjtz35sp.js +33 -0
- package/dist/ui.cjs +61 -0
- package/dist/ui.d.cts +21 -0
- package/dist/ui.d.ts +21 -0
- package/dist/ui.js +14 -0
- package/dist/version.cjs +47 -0
- package/dist/version.d.cts +7 -0
- package/dist/version.d.ts +7 -0
- package/dist/version.js +6 -0
- package/package.json +96 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { AgentFeature as SharedAgentFeature } from "@pragma-sh/constants";
|
|
2
|
+
import { ComponentType, ReactNode } from "react";
|
|
3
|
+
import { PragmaClient } from "@pragma-sh/sdk";
|
|
4
|
+
/** Imperative durable JSON storage bound by the host to one plugin. */
|
|
5
|
+
interface PluginStorage {
|
|
6
|
+
get<T>(key: string, initialValue: T): Promise<T>;
|
|
7
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** The active project a plugin is rendered against, or `null` when none is selected. */
|
|
11
|
+
interface PluginProject {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}
|
|
16
|
+
/** Options for {@link PluginContext.notify} / `useNotify()`. */
|
|
17
|
+
interface PluginNotifyOptions {
|
|
18
|
+
variant?: "info" | "success" | "warning" | "error";
|
|
19
|
+
description?: string;
|
|
20
|
+
/** Also send a native OS notification through Pragma's notification bridge. */
|
|
21
|
+
native?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Context passed to every plugin callback: contribution `when` guards, command
|
|
25
|
+
* `run` handlers, agent event handlers, and `activate`.
|
|
26
|
+
*/
|
|
27
|
+
interface PluginContext<TConfig = unknown> {
|
|
28
|
+
/** This plugin's stable id, derived from its `package.json` name. */
|
|
29
|
+
pluginId: string;
|
|
30
|
+
/** Absolute plugin package directory when available in this runtime. */
|
|
31
|
+
pluginDir?: string;
|
|
32
|
+
/** This plugin's user-supplied config, already validated against its `config` schema. */
|
|
33
|
+
config: TConfig;
|
|
34
|
+
/** The active project, or `null` when no project is selected. */
|
|
35
|
+
project: PluginProject | null;
|
|
36
|
+
/** Typed SDK client for talking to the local Pragma gateway. */
|
|
37
|
+
sdk: PragmaClient;
|
|
38
|
+
/** Shows an in-app notification. */
|
|
39
|
+
notify: (message: string, options?: PluginNotifyOptions) => void;
|
|
40
|
+
/** Durable storage scoped to this plugin. Available in desktop-hosted callbacks. */
|
|
41
|
+
storage?: PluginStorage;
|
|
42
|
+
}
|
|
43
|
+
/** Payload emitted for `pragma://plugin/<pluginId>/<path>` deep links. */
|
|
44
|
+
interface PluginDeepLinkEvent {
|
|
45
|
+
pluginId: string;
|
|
46
|
+
path: string;
|
|
47
|
+
url: string;
|
|
48
|
+
params: Record<string, string[]>;
|
|
49
|
+
}
|
|
50
|
+
/** An icon contributed alongside a sidebar tab, command, or agent. */
|
|
51
|
+
type PluginIcon = ComponentType<{
|
|
52
|
+
className?: string;
|
|
53
|
+
}>;
|
|
54
|
+
/** Values passed directly to every host-rendered plugin component. */
|
|
55
|
+
interface PluginComponentProps<TWebViewPayload = unknown> {
|
|
56
|
+
/** Payload supplied when this component renders as a plugin web view. */
|
|
57
|
+
webViewPayload?: TWebViewPayload;
|
|
58
|
+
}
|
|
59
|
+
/** A host-rendered plugin component. Hooks remain available for reactive host state. */
|
|
60
|
+
type PluginComponent<TWebViewPayload = unknown> = {
|
|
61
|
+
bivarianceHack(props: PluginComponentProps<TWebViewPayload>): ReactNode;
|
|
62
|
+
}["bivarianceHack"];
|
|
63
|
+
/** A guard evaluated by the host to decide whether a contribution should render. */
|
|
64
|
+
type PluginWhen<TConfig = unknown> = (ctx: PluginContext<TConfig>) => boolean;
|
|
65
|
+
/** A tab contributed to the project sidebar. */
|
|
66
|
+
interface SidebarTabDefinition<TConfig = unknown> {
|
|
67
|
+
id: string;
|
|
68
|
+
title: string;
|
|
69
|
+
icon?: PluginIcon;
|
|
70
|
+
component: PluginComponent;
|
|
71
|
+
when?: PluginWhen<TConfig>;
|
|
72
|
+
}
|
|
73
|
+
/** A page contributed to Pragma Settings. */
|
|
74
|
+
interface SettingsPageDefinition<TConfig = unknown> {
|
|
75
|
+
id: string;
|
|
76
|
+
title: string;
|
|
77
|
+
icon?: PluginIcon;
|
|
78
|
+
component: PluginComponent;
|
|
79
|
+
when?: PluginWhen<TConfig>;
|
|
80
|
+
}
|
|
81
|
+
/** Options used when opening a plugin web view tab. */
|
|
82
|
+
interface OpenWebViewOptions<TPayload = unknown> {
|
|
83
|
+
/** Overrides the tab title; falls back to the web view title, then id. */
|
|
84
|
+
title?: string;
|
|
85
|
+
/** JSON-serializable data made available through `useWebViewPayload`. */
|
|
86
|
+
payload?: TPayload;
|
|
87
|
+
/** Stable key used by the host to focus an existing matching web view tab. */
|
|
88
|
+
dedupeKey?: string;
|
|
89
|
+
}
|
|
90
|
+
/** A plugin-defined React view that renders inside a workspace tab web view. */
|
|
91
|
+
interface WebViewDefinition<TPayload = unknown> {
|
|
92
|
+
id: string;
|
|
93
|
+
title?: string;
|
|
94
|
+
component: PluginComponent<TPayload>;
|
|
95
|
+
/** Opens this web view as a workspace tab. */
|
|
96
|
+
open(options?: OpenWebViewOptions<TPayload>): Promise<void>;
|
|
97
|
+
}
|
|
98
|
+
/** An item contributed to the workspace topper bar. */
|
|
99
|
+
interface TopperItemDefinition<TConfig = unknown> {
|
|
100
|
+
align: "left" | "right";
|
|
101
|
+
component: PluginComponent;
|
|
102
|
+
when?: PluginWhen<TConfig>;
|
|
103
|
+
}
|
|
104
|
+
/** A card contributed to the project sidebar. */
|
|
105
|
+
interface SidebarCardDefinition<TConfig = unknown> {
|
|
106
|
+
title: string;
|
|
107
|
+
component: PluginComponent;
|
|
108
|
+
when?: PluginWhen<TConfig>;
|
|
109
|
+
}
|
|
110
|
+
/** A command contributed to the command palette / keybindings surface. */
|
|
111
|
+
interface CommandDefinition<TConfig = unknown> {
|
|
112
|
+
id: string;
|
|
113
|
+
title: string;
|
|
114
|
+
icon?: PluginIcon;
|
|
115
|
+
defaultBinding?: string;
|
|
116
|
+
hidden?: boolean;
|
|
117
|
+
run: (ctx: PluginContext<TConfig>, args?: unknown) => void | Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Timed input sent to the agent's terminal after launch and before an
|
|
121
|
+
* optional prompt prefill. Field names mirror the host's existing
|
|
122
|
+
* the old `~/.pragma/agents/<id>/config.json` shape (`startupInput`) exactly, so
|
|
123
|
+
* plugin-contributed agents carry over unchanged.
|
|
124
|
+
*/
|
|
125
|
+
interface AgentStartupInput {
|
|
126
|
+
delayMs: number;
|
|
127
|
+
data: string;
|
|
128
|
+
}
|
|
129
|
+
/** One selectable reasoning-effort level for a model. */
|
|
130
|
+
interface AgentReasoning {
|
|
131
|
+
id: string;
|
|
132
|
+
name: string;
|
|
133
|
+
}
|
|
134
|
+
/** One selectable model for an agent. */
|
|
135
|
+
interface AgentModelEntry {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
reasoning?: AgentReasoning[];
|
|
139
|
+
}
|
|
140
|
+
/** One selectable permission mode for an agent. */
|
|
141
|
+
interface AgentPermissionMode {
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
}
|
|
145
|
+
/** Builds the launch command-line arguments for a selected model/reasoning/permission mode. */
|
|
146
|
+
interface AgentArgsBuilder {
|
|
147
|
+
model: (modelId: string) => string[];
|
|
148
|
+
reasoning: (reasoningId: string) => string[];
|
|
149
|
+
modelReasoning?: (modelId: string, reasoningId: string) => string[];
|
|
150
|
+
permissionMode: (permissionModeId: string) => string[];
|
|
151
|
+
}
|
|
152
|
+
/** Optional agent capabilities that can be excluded from `pragma-cli agent verify`. */
|
|
153
|
+
type AgentFeature = SharedAgentFeature;
|
|
154
|
+
/**
|
|
155
|
+
* Declares an agent a plugin makes launchable from Pragma. Field names below
|
|
156
|
+
* `launch`/`models`/`permissionModes`/`args` are new, JS-only additions;
|
|
157
|
+
* `startupInput`/`prefillDelayMs`/`prefillMode`/`prefillSubmit`/
|
|
158
|
+
* `prefillSubmitDelayMs` carry over the existing agent-launcher config shape
|
|
159
|
+
* exactly (see `src-tauri/src/agents.rs`).
|
|
160
|
+
*/
|
|
161
|
+
interface AgentDefinition<TConfig = unknown> {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
icon: PluginIcon;
|
|
165
|
+
/** Browser URL, absolute filesystem path, or plugin-dir-relative asset path for the agent icon. */
|
|
166
|
+
iconPath?: string;
|
|
167
|
+
launch: {
|
|
168
|
+
command: string[];
|
|
169
|
+
};
|
|
170
|
+
models: AgentModelEntry[] | ((ctx: PluginContext<TConfig>) => Promise<AgentModelEntry[]>);
|
|
171
|
+
permissionModes: AgentPermissionMode[];
|
|
172
|
+
args: AgentArgsBuilder;
|
|
173
|
+
/** Capabilities this agent does not support; matching verification scenarios are skipped. */
|
|
174
|
+
excludeFeatures?: AgentFeature[];
|
|
175
|
+
startupInput?: AgentStartupInput[];
|
|
176
|
+
prefillDelayMs?: number;
|
|
177
|
+
prefillMode?: "bracketed" | "plain";
|
|
178
|
+
prefillSubmit?: string;
|
|
179
|
+
prefillSubmitDelayMs?: number;
|
|
180
|
+
}
|
|
181
|
+
/** Declares an agent contribution. */
|
|
182
|
+
declare function defineAgent<TConfig = unknown>(input: AgentDefinition<TConfig>): AgentDefinition<TConfig>;
|
|
183
|
+
import { AgentReportPayload } from "@pragma-sh/constants";
|
|
184
|
+
import { ZodType, ZodTypeAny } from "zod";
|
|
185
|
+
import { AgentMessage, PragmaClient as PragmaClient2 } from "@pragma-sh/sdk";
|
|
186
|
+
/** Declares a watcher a plugin attaches to one of its agents' sessions. */
|
|
187
|
+
interface WatcherDefinition<TConfig = unknown> {
|
|
188
|
+
/** The `defineAgent` id this watcher attaches to. */
|
|
189
|
+
agent: string;
|
|
190
|
+
/** Runs once per launched session; lives until the session exits. */
|
|
191
|
+
watch: (ctx: WatcherContext<TConfig>) => void | Promise<void>;
|
|
192
|
+
}
|
|
193
|
+
/** Host-side context passed to a running watcher instance. */
|
|
194
|
+
interface WatcherContext<TConfig = unknown> {
|
|
195
|
+
/** Typed gateway SDK. */
|
|
196
|
+
sdk: PragmaClient2;
|
|
197
|
+
/** Full agent id this watcher instance is bound to (plugin-qualified). */
|
|
198
|
+
agentId: string;
|
|
199
|
+
/** This plugin's validated config. */
|
|
200
|
+
config: TConfig;
|
|
201
|
+
/** Session this watcher is attached to. */
|
|
202
|
+
session: {
|
|
203
|
+
id: string;
|
|
204
|
+
tabId: string;
|
|
205
|
+
worktreeId: string;
|
|
206
|
+
};
|
|
207
|
+
/** Decoded terminal output chunks for this session. */
|
|
208
|
+
output: AsyncIterable<string>;
|
|
209
|
+
/** Writes bytes into the live terminal session. */
|
|
210
|
+
sendKeys: (data: string) => Promise<void>;
|
|
211
|
+
/** Reports a rich message for this watcher-owned agent. */
|
|
212
|
+
reportMessage: (msg: Omit<AgentMessage, "agent" | "tabId" | "worktreeId">) => Promise<void>;
|
|
213
|
+
/** Aborts when the session exits or the watcher is stopped. */
|
|
214
|
+
signal: AbortSignal;
|
|
215
|
+
}
|
|
216
|
+
/** One finite or unlimited usage category reported by a provider. */
|
|
217
|
+
interface UsageLimit {
|
|
218
|
+
id: string;
|
|
219
|
+
title: string;
|
|
220
|
+
used: number;
|
|
221
|
+
/** A null limit represents unlimited usage. */
|
|
222
|
+
limit: number | null;
|
|
223
|
+
/** Milliseconds until this category resets, measured from `observedAt`. */
|
|
224
|
+
resetsInMs?: number;
|
|
225
|
+
}
|
|
226
|
+
/** A successful provider snapshot. */
|
|
227
|
+
interface UsageLimitsReady {
|
|
228
|
+
status: "ready";
|
|
229
|
+
/** Unix time in milliseconds when the provider observed these values. */
|
|
230
|
+
observedAt: number;
|
|
231
|
+
/** Optional collapsed-row metric derived separately from the detailed limits. */
|
|
232
|
+
summary?: UsageLimit;
|
|
233
|
+
limits: UsageLimit[];
|
|
234
|
+
}
|
|
235
|
+
/** Why a provider cannot currently report usage limits. */
|
|
236
|
+
type UsageLimitsUnavailableReason = "not-configured" | "authentication-required" | "unsupported" | "error";
|
|
237
|
+
/** A provider state that requires user or platform action before loading. */
|
|
238
|
+
interface UsageLimitsUnavailable {
|
|
239
|
+
status: "unavailable";
|
|
240
|
+
reason: UsageLimitsUnavailableReason;
|
|
241
|
+
message: string;
|
|
242
|
+
}
|
|
243
|
+
/** Result returned by a usage-limit provider. Unexpected failures should throw. */
|
|
244
|
+
type UsageLimitsResult = UsageLimitsReady | UsageLimitsUnavailable;
|
|
245
|
+
/**
|
|
246
|
+
* Exit status a provider's shell wrapper uses to report that the agent CLI is
|
|
247
|
+
* not on PATH, distinguishing "not installed" from a genuine command failure.
|
|
248
|
+
*/
|
|
249
|
+
declare const CLI_MISSING_STATUS = 20;
|
|
250
|
+
/** Outcome of one provider CLI invocation. */
|
|
251
|
+
type ProviderCommandOutcome = {
|
|
252
|
+
kind: "missing";
|
|
253
|
+
} | {
|
|
254
|
+
kind: "failed";
|
|
255
|
+
stderr: string;
|
|
256
|
+
} | {
|
|
257
|
+
kind: "ok";
|
|
258
|
+
stdout: string;
|
|
259
|
+
};
|
|
260
|
+
/**
|
|
261
|
+
* Runs a single provider command in the active project and classifies its exit
|
|
262
|
+
* status. Callers map `missing`/`failed` onto their own messages, since the
|
|
263
|
+
* wording and the reasons worth special-casing differ per agent.
|
|
264
|
+
*/
|
|
265
|
+
declare function runProviderCommand<TConfig>(ctx: PluginContext<TConfig>, command: string, missingStatus?: number): Promise<ProviderCommandOutcome>;
|
|
266
|
+
/** A plugin-owned usage source rendered by Pragma's shared usage-limits UI. */
|
|
267
|
+
interface UsageLimitProviderDefinition<TConfig = unknown> {
|
|
268
|
+
id: string;
|
|
269
|
+
title: string;
|
|
270
|
+
/** Absolute URL for viewing this provider's usage in its dashboard. */
|
|
271
|
+
dashboardUrl: string;
|
|
272
|
+
icon?: PluginIcon;
|
|
273
|
+
/** Browser URL, absolute path, or plugin-directory-relative asset path. */
|
|
274
|
+
iconPath?: string;
|
|
275
|
+
/** Category rendered in the provider's collapsed summary row. */
|
|
276
|
+
primaryLimitId: string;
|
|
277
|
+
/** Requested refresh cadence. The host may enforce a larger minimum. */
|
|
278
|
+
refreshIntervalMs?: number;
|
|
279
|
+
load: (ctx: PluginContext<TConfig>) => Promise<UsageLimitsResult>;
|
|
280
|
+
}
|
|
281
|
+
/** Declares a provider for Pragma's shared usage-limits UI. */
|
|
282
|
+
declare function defineUsageLimitProvider<TConfig = unknown>(input: UsageLimitProviderDefinition<TConfig>): UsageLimitProviderDefinition<TConfig>;
|
|
283
|
+
/** Color schemes supported by Pragma themes. */
|
|
284
|
+
type ThemeMode = "light" | "dark";
|
|
285
|
+
/** Theme token overrides for one color scheme, keyed without the `--` prefix. */
|
|
286
|
+
type ThemeColors = Record<ThemeMode, Record<string, string>>;
|
|
287
|
+
/** A selectable theme contributed to Pragma's Theme settings. */
|
|
288
|
+
interface ThemeDefinition {
|
|
289
|
+
/** Stable id within this plugin. */
|
|
290
|
+
id: string;
|
|
291
|
+
/** Human-readable name shown in Theme settings. */
|
|
292
|
+
name: string;
|
|
293
|
+
/** Optional detail shown under the theme name. */
|
|
294
|
+
description?: string;
|
|
295
|
+
/** Light and dark Pragma theme-token overrides. */
|
|
296
|
+
colors: ThemeColors;
|
|
297
|
+
}
|
|
298
|
+
/** Infers a config schema's parsed output type, defaulting to `unknown` when no schema is given. */
|
|
299
|
+
type InferConfig<TConfigSchema extends ZodTypeAny> = TConfigSchema extends ZodType<infer Output> ? Output : unknown;
|
|
300
|
+
/** UI surfaces a plugin can contribute to. */
|
|
301
|
+
interface PluginUiContributions<TConfig = unknown> {
|
|
302
|
+
sidebarTabs?: SidebarTabDefinition<TConfig>[];
|
|
303
|
+
settingsPages?: SettingsPageDefinition<TConfig>[];
|
|
304
|
+
topper?: TopperItemDefinition<TConfig>[];
|
|
305
|
+
sidebarCards?: SidebarCardDefinition<TConfig>[];
|
|
306
|
+
webViews?: WebViewDefinition[];
|
|
307
|
+
}
|
|
308
|
+
/** Whether a plugin's declared values are merged with or replace host defaults. */
|
|
309
|
+
type PluginContributionStrategy = "merge" | "replace";
|
|
310
|
+
/** Default settings values a plugin contributes. */
|
|
311
|
+
interface PluginSettingsContributions {
|
|
312
|
+
strategy?: PluginContributionStrategy;
|
|
313
|
+
values: Record<string, unknown>;
|
|
314
|
+
}
|
|
315
|
+
/** Default keybindings a plugin contributes. */
|
|
316
|
+
interface PluginKeybindingsContributions {
|
|
317
|
+
strategy?: PluginContributionStrategy;
|
|
318
|
+
bindings: Record<string, string>;
|
|
319
|
+
}
|
|
320
|
+
/** Daemon-forwarded events a plugin can subscribe to declaratively. */
|
|
321
|
+
interface PluginEventHandlers<TConfig = unknown> {
|
|
322
|
+
"agent.report"?: (event: AgentReportPayload, ctx: PluginContext<TConfig>) => void;
|
|
323
|
+
deepLink?: (event: PluginDeepLinkEvent, ctx: PluginContext<TConfig>) => void;
|
|
324
|
+
}
|
|
325
|
+
/** The object shape passed to `definePlugin`. */
|
|
326
|
+
interface PluginDefinitionInput<TConfigSchema extends ZodTypeAny = ZodTypeAny> {
|
|
327
|
+
name: string;
|
|
328
|
+
description?: string;
|
|
329
|
+
icon?: PluginIcon;
|
|
330
|
+
config?: TConfigSchema;
|
|
331
|
+
ui?: PluginUiContributions<InferConfig<TConfigSchema>>;
|
|
332
|
+
agents?: AgentDefinition<InferConfig<TConfigSchema>>[];
|
|
333
|
+
watchers?: WatcherDefinition<InferConfig<TConfigSchema>>[];
|
|
334
|
+
commands?: CommandDefinition<InferConfig<TConfigSchema>>[];
|
|
335
|
+
settings?: PluginSettingsContributions;
|
|
336
|
+
keybindings?: PluginKeybindingsContributions;
|
|
337
|
+
events?: PluginEventHandlers<InferConfig<TConfigSchema>>;
|
|
338
|
+
usageLimits?: UsageLimitProviderDefinition<InferConfig<TConfigSchema>>[];
|
|
339
|
+
themes?: ThemeDefinition[];
|
|
340
|
+
css?: string;
|
|
341
|
+
/** Runs once when Pragma first discovers this plugin installation. */
|
|
342
|
+
onInstall?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
343
|
+
/** Runs once during every Pragma server boot. */
|
|
344
|
+
onPragmaLoad?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | Promise<void>;
|
|
345
|
+
activate?: (ctx: PluginContext<InferConfig<TConfigSchema>>) => void | (() => void);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A fully-declared plugin, as returned by `definePlugin`. `__apiVersion` is
|
|
349
|
+
* stamped automatically — plugin authors never set it themselves, and it
|
|
350
|
+
* lives under a deliberately internal-looking name so it doesn't show up as
|
|
351
|
+
* something to configure.
|
|
352
|
+
*/
|
|
353
|
+
interface PluginDefinition<TConfigSchema extends ZodTypeAny = ZodTypeAny> extends PluginDefinitionInput<TConfigSchema> {
|
|
354
|
+
/** @internal The `@pragma-sh/plugin` version this plugin was compiled against. */
|
|
355
|
+
readonly __apiVersion: string;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Declares a Pragma plugin. This is the single entry point a plugin's bundle
|
|
359
|
+
* must default-export. Stamps the compiled-against `@pragma-sh/plugin` version
|
|
360
|
+
* onto the result so the host can check compatibility before loading it.
|
|
361
|
+
*/
|
|
362
|
+
declare function definePlugin<TConfigSchema extends ZodTypeAny = ZodTypeAny>(input: PluginDefinitionInput<TConfigSchema>): PluginDefinition<TConfigSchema>;
|
|
363
|
+
export { runProviderCommand, defineUsageLimitProvider, definePlugin, defineAgent, UsageLimitsResult, UsageLimitProviderDefinition, UsageLimit, ProviderCommandOutcome, PluginDefinition, PluginContext, CLI_MISSING_STATUS, AgentModelEntry, AgentFeature, AgentDefinition };
|
package/dist/catalog.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLI_MISSING_STATUS,
|
|
3
|
+
defineAgent,
|
|
4
|
+
definePlugin,
|
|
5
|
+
defineUsageLimitProvider,
|
|
6
|
+
runProviderCommand
|
|
7
|
+
} from "./shared/chunk-yjtz35sp.js";
|
|
8
|
+
import"./shared/chunk-qjw1esw6.js";
|
|
9
|
+
export {
|
|
10
|
+
runProviderCommand,
|
|
11
|
+
defineUsageLimitProvider,
|
|
12
|
+
definePlugin,
|
|
13
|
+
defineAgent,
|
|
14
|
+
CLI_MISSING_STATUS
|
|
15
|
+
};
|
package/dist/icons.cjs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/icons.ts
|
|
40
|
+
var exports_icons = {};
|
|
41
|
+
__export(exports_icons, {
|
|
42
|
+
default: () => icons_default
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(exports_icons);
|
|
45
|
+
|
|
46
|
+
// src/bridge.ts
|
|
47
|
+
function getBridge() {
|
|
48
|
+
const bridge = globalThis.__PRAGMA__;
|
|
49
|
+
if (!bridge) {
|
|
50
|
+
throw new Error("@pragma-sh/plugin: globalThis.__PRAGMA__ is not installed. This module only " + "runs inside a Pragma host, which installs the bridge before loading any " + "plugin bundle. It cannot be imported standalone (e.g. from Node or a " + "non-Pragma bundler build).");
|
|
51
|
+
}
|
|
52
|
+
return bridge;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/icons.ts
|
|
56
|
+
var icons = getBridge().icons;
|
|
57
|
+
var icons_default = icons;
|
package/dist/icons.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentType as ComponentType2 } from "react";
|
|
2
|
+
/** A rendered icon component contributed by the host (`@pragma-sh/plugin/icons`). */
|
|
3
|
+
type PragmaIconsBridge = Record<string, ComponentType2<{
|
|
4
|
+
className?: string;
|
|
5
|
+
}>>;
|
|
6
|
+
/**
|
|
7
|
+
* Host-rendered lucide icon components. Phase 1 only exposes the live bridge
|
|
8
|
+
* object as a default export — Phase 2 adds named exports per icon (e.g.
|
|
9
|
+
* `import { FolderIcon } from "@pragma-sh/plugin/icons"`) once the icon set
|
|
10
|
+
* plugins draw from is finalized.
|
|
11
|
+
*/
|
|
12
|
+
declare const icons: PragmaIconsBridge;
|
|
13
|
+
export { icons as default };
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ComponentType as ComponentType2 } from "react";
|
|
2
|
+
/** A rendered icon component contributed by the host (`@pragma-sh/plugin/icons`). */
|
|
3
|
+
type PragmaIconsBridge = Record<string, ComponentType2<{
|
|
4
|
+
className?: string;
|
|
5
|
+
}>>;
|
|
6
|
+
/**
|
|
7
|
+
* Host-rendered lucide icon components. Phase 1 only exposes the live bridge
|
|
8
|
+
* object as a default export — Phase 2 adds named exports per icon (e.g.
|
|
9
|
+
* `import { FolderIcon } from "@pragma-sh/plugin/icons"`) once the icon set
|
|
10
|
+
* plugins draw from is finalized.
|
|
11
|
+
*/
|
|
12
|
+
declare const icons: PragmaIconsBridge;
|
|
13
|
+
export { icons as default };
|
package/dist/icons.js
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
8
|
+
var __toCommonJS = (from) => {
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
10
|
+
if (entry)
|
|
11
|
+
return entry;
|
|
12
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
__moduleCache.set(from, entry);
|
|
22
|
+
return entry;
|
|
23
|
+
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
29
|
+
var __export = (target, all) => {
|
|
30
|
+
for (var name in all)
|
|
31
|
+
__defProp(target, name, {
|
|
32
|
+
get: all[name],
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/index.ts
|
|
40
|
+
var exports_src = {};
|
|
41
|
+
__export(exports_src, {
|
|
42
|
+
z: () => z,
|
|
43
|
+
useWorktreeChanges: () => useWorktreeChanges,
|
|
44
|
+
useWebViewPayload: () => useWebViewPayload,
|
|
45
|
+
useTheme: () => useTheme,
|
|
46
|
+
useStoredState: () => useStoredState,
|
|
47
|
+
useSessions: () => useSessions,
|
|
48
|
+
useSdkQuery: () => useSdkQuery,
|
|
49
|
+
useSdk: () => useSdk,
|
|
50
|
+
useProject: () => useProject,
|
|
51
|
+
usePluginConfig: () => usePluginConfig,
|
|
52
|
+
useNotify: () => useNotify,
|
|
53
|
+
useFileContents: () => useFileContents,
|
|
54
|
+
useEvent: () => useEvent,
|
|
55
|
+
useDirEntries: () => useDirEntries,
|
|
56
|
+
useBranchStatus: () => useBranchStatus,
|
|
57
|
+
useAgentStatuses: () => useAgentStatuses,
|
|
58
|
+
useAgentMessages: () => useAgentMessages,
|
|
59
|
+
subscribeTheme: () => subscribeTheme,
|
|
60
|
+
subscribeEvent: () => subscribeEvent,
|
|
61
|
+
openWebView: () => openWebView,
|
|
62
|
+
listSessions: () => listSessions,
|
|
63
|
+
getTheme: () => getTheme,
|
|
64
|
+
getBridge: () => getBridge,
|
|
65
|
+
defineWebView: () => defineWebView,
|
|
66
|
+
defineWatcher: () => defineWatcher,
|
|
67
|
+
defineUsageLimitProvider: () => defineUsageLimitProvider,
|
|
68
|
+
defineTopperItem: () => defineTopperItem,
|
|
69
|
+
defineTheme: () => defineTheme,
|
|
70
|
+
defineSidebarTab: () => defineSidebarTab,
|
|
71
|
+
defineSidebarCard: () => defineSidebarCard,
|
|
72
|
+
defineSettingsPage: () => defineSettingsPage,
|
|
73
|
+
definePlugin: () => definePlugin,
|
|
74
|
+
defineCommand: () => defineCommand,
|
|
75
|
+
defineAgent: () => defineAgent,
|
|
76
|
+
PLUGIN_API_VERSION: () => PLUGIN_API_VERSION
|
|
77
|
+
});
|
|
78
|
+
module.exports = __toCommonJS(exports_src);
|
|
79
|
+
|
|
80
|
+
// src/agent.ts
|
|
81
|
+
function defineAgent(input) {
|
|
82
|
+
return input;
|
|
83
|
+
}
|
|
84
|
+
// src/bridge.ts
|
|
85
|
+
function getBridge() {
|
|
86
|
+
const bridge = globalThis.__PRAGMA__;
|
|
87
|
+
if (!bridge) {
|
|
88
|
+
throw new Error("@pragma-sh/plugin: globalThis.__PRAGMA__ is not installed. This module only " + "runs inside a Pragma host, which installs the bridge before loading any " + "plugin bundle. It cannot be imported standalone (e.g. from Node or a " + "non-Pragma bundler build).");
|
|
89
|
+
}
|
|
90
|
+
return bridge;
|
|
91
|
+
}
|
|
92
|
+
// src/contributions.ts
|
|
93
|
+
function defineSidebarTab(input) {
|
|
94
|
+
return input;
|
|
95
|
+
}
|
|
96
|
+
function defineSettingsPage(input) {
|
|
97
|
+
return input;
|
|
98
|
+
}
|
|
99
|
+
function openWebView(webView, options) {
|
|
100
|
+
return getBridge().actions.openWebView(webView, options);
|
|
101
|
+
}
|
|
102
|
+
function defineWebView(input) {
|
|
103
|
+
const definition = {
|
|
104
|
+
...input,
|
|
105
|
+
open: (options) => openWebView(definition, options)
|
|
106
|
+
};
|
|
107
|
+
return definition;
|
|
108
|
+
}
|
|
109
|
+
function defineTopperItem(input) {
|
|
110
|
+
return input;
|
|
111
|
+
}
|
|
112
|
+
function defineSidebarCard(input) {
|
|
113
|
+
return input;
|
|
114
|
+
}
|
|
115
|
+
function defineCommand(input) {
|
|
116
|
+
return input;
|
|
117
|
+
}
|
|
118
|
+
// src/generated/version.ts
|
|
119
|
+
var PLUGIN_API_VERSION = "0.1.0";
|
|
120
|
+
// src/hooks.ts
|
|
121
|
+
function usePluginConfig() {
|
|
122
|
+
return getBridge().hooks.usePluginConfig();
|
|
123
|
+
}
|
|
124
|
+
function useSdk() {
|
|
125
|
+
return getBridge().hooks.useSdk();
|
|
126
|
+
}
|
|
127
|
+
function useProject() {
|
|
128
|
+
return getBridge().hooks.useProject();
|
|
129
|
+
}
|
|
130
|
+
function useTheme() {
|
|
131
|
+
return getBridge().hooks.useTheme();
|
|
132
|
+
}
|
|
133
|
+
function useWebViewPayload() {
|
|
134
|
+
return getBridge().hooks.useWebViewPayload();
|
|
135
|
+
}
|
|
136
|
+
function useNotify() {
|
|
137
|
+
return getBridge().hooks.useNotify();
|
|
138
|
+
}
|
|
139
|
+
function useStoredState(key, initialValue) {
|
|
140
|
+
return getBridge().hooks.useStoredState(key, initialValue);
|
|
141
|
+
}
|
|
142
|
+
function useSdkQuery(queryFn, deps) {
|
|
143
|
+
return getBridge().hooks.useSdkQuery(queryFn, deps);
|
|
144
|
+
}
|
|
145
|
+
function useEvent(eventName, handler) {
|
|
146
|
+
getBridge().hooks.useEvent(eventName, handler);
|
|
147
|
+
}
|
|
148
|
+
function useWorktreeChanges(worktreeRoot) {
|
|
149
|
+
return getBridge().hooks.useWorktreeChanges(worktreeRoot);
|
|
150
|
+
}
|
|
151
|
+
function useBranchStatus(worktreeRoot) {
|
|
152
|
+
return getBridge().hooks.useBranchStatus(worktreeRoot);
|
|
153
|
+
}
|
|
154
|
+
function useDirEntries(root, path = ".") {
|
|
155
|
+
return getBridge().hooks.useDirEntries(root, path);
|
|
156
|
+
}
|
|
157
|
+
function useFileContents(root, path) {
|
|
158
|
+
return getBridge().hooks.useFileContents(root, path);
|
|
159
|
+
}
|
|
160
|
+
function useAgentStatuses(worktreeId) {
|
|
161
|
+
return getBridge().hooks.useAgentStatuses(worktreeId);
|
|
162
|
+
}
|
|
163
|
+
function useAgentMessages(worktreeId, tabId) {
|
|
164
|
+
return getBridge().hooks.useAgentMessages(worktreeId, tabId);
|
|
165
|
+
}
|
|
166
|
+
function useSessions() {
|
|
167
|
+
return getBridge().hooks.useSessions();
|
|
168
|
+
}
|
|
169
|
+
// src/plugin.ts
|
|
170
|
+
function definePlugin(input) {
|
|
171
|
+
return { ...input, __apiVersion: PLUGIN_API_VERSION };
|
|
172
|
+
}
|
|
173
|
+
// src/usage-limits.ts
|
|
174
|
+
var CLI_MISSING_STATUS = 20;
|
|
175
|
+
async function runProviderCommand(ctx, command, missingStatus = CLI_MISSING_STATUS) {
|
|
176
|
+
const [result] = await ctx.sdk.exec.run({
|
|
177
|
+
cwd: ctx.project?.path ?? "/tmp",
|
|
178
|
+
commands: [command]
|
|
179
|
+
});
|
|
180
|
+
if (result?.status === missingStatus)
|
|
181
|
+
return { kind: "missing" };
|
|
182
|
+
if (!result || result.status !== 0) {
|
|
183
|
+
return { kind: "failed", stderr: result?.stderr.trim() ?? "" };
|
|
184
|
+
}
|
|
185
|
+
return { kind: "ok", stdout: result.stdout };
|
|
186
|
+
}
|
|
187
|
+
function defineUsageLimitProvider(input) {
|
|
188
|
+
return input;
|
|
189
|
+
}
|
|
190
|
+
// src/theme.ts
|
|
191
|
+
function defineTheme(input) {
|
|
192
|
+
return input;
|
|
193
|
+
}
|
|
194
|
+
// src/runtime.ts
|
|
195
|
+
function getTheme() {
|
|
196
|
+
return getBridge().actions.theme.get();
|
|
197
|
+
}
|
|
198
|
+
function subscribeTheme(listener) {
|
|
199
|
+
const theme = getBridge().actions.theme;
|
|
200
|
+
return theme.subscribe(() => {
|
|
201
|
+
listener(theme.get());
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function subscribeEvent(eventName, handler) {
|
|
205
|
+
return getBridge().actions.events.subscribe(eventName, (payload) => {
|
|
206
|
+
handler(payload);
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function listSessions() {
|
|
210
|
+
return getBridge().actions.sessions.list();
|
|
211
|
+
}
|
|
212
|
+
// src/watcher.ts
|
|
213
|
+
function defineWatcher(input) {
|
|
214
|
+
return input;
|
|
215
|
+
}
|
|
216
|
+
// src/z.ts
|
|
217
|
+
var z = getBridge().zod;
|