@openvcs/sdk 0.2.18-edge.20260420.21 → 0.2.18-edge.20260422.25

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.
@@ -5,6 +5,7 @@ type MenubarMenuOptions = {
5
5
  before?: string;
6
6
  after?: string;
7
7
  };
8
+ type MenuSurface = 'menubar' | 'settings';
8
9
  /** Runs a registered action handler by id. */
9
10
  export declare function runRegisteredAction(actionId: string, ...args: unknown[]): Promise<unknown>;
10
11
  export interface MenuHandle {
@@ -17,10 +18,16 @@ export interface MenuHandle {
17
18
  }
18
19
  /** Returns a menu by id, or null when it does not exist. */
19
20
  export declare function getMenu(menuId: string): MenuHandle | null;
20
- /** Returns a menu by id, creating it if needed. */
21
- export declare function getOrCreateMenu(menuId: string, label: string): MenuHandle | null;
22
- /** Creates a menu at a specific position. */
23
- export declare function createMenu(menuId: string, label: string, options?: MenubarMenuOptions): MenuHandle | null;
21
+ /** Returns a menu by id, creating it if needed.
22
+ * @param menuId - Menu identifier
23
+ * @param label - User-visible label
24
+ * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
25
+ */
26
+ export declare function getOrCreateMenu(menuId: string, label: string, options?: MenubarMenuOptions & {
27
+ surface?: MenuSurface;
28
+ }): MenuHandle | null;
29
+ /** Creates a menu at a specific position (alias for getOrCreateMenu). */
30
+ export declare const createMenu: typeof getOrCreateMenu;
24
31
  /** Adds one item to a menu. */
25
32
  export declare function addMenuItem(menuId: string, item: MenubarItem): void;
26
33
  /** Adds one separator to a menu. */
@@ -2,10 +2,10 @@
2
2
  // Copyright © 2025-2026 OpenVCS Contributors
3
3
  // SPDX-License-Identifier: GPL-3.0-or-later
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.createMenu = void 0;
5
6
  exports.runRegisteredAction = runRegisteredAction;
6
7
  exports.getMenu = getMenu;
7
8
  exports.getOrCreateMenu = getOrCreateMenu;
8
- exports.createMenu = createMenu;
9
9
  exports.addMenuItem = addMenuItem;
10
10
  exports.addMenuSeparator = addMenuSeparator;
11
11
  exports.removeMenu = removeMenu;
@@ -66,16 +66,19 @@ function placeMenuId(menuId, options) {
66
66
  menuOrder.push(id);
67
67
  }
68
68
  /** Ensures a menu record exists for one id. */
69
- function ensureStoredMenu(menuId, label, options) {
69
+ function ensureStoredMenu(menuId, label, options, surface = 'menubar') {
70
70
  const id = normalizeMenuId(menuId);
71
71
  const safeLabel = String(label || '').trim() || id;
72
72
  let menu = menus.get(id);
73
73
  if (!menu) {
74
- menu = { id, label: safeLabel, items: [] };
74
+ menu = { id, label: safeLabel, surface, items: [] };
75
75
  menus.set(id, menu);
76
76
  }
77
77
  else {
78
78
  menu.label = safeLabel;
79
+ // Preserve surface if already set, otherwise use provided.
80
+ if (!menu.surface)
81
+ menu.surface = surface;
79
82
  }
80
83
  placeMenuId(id, options);
81
84
  return menu;
@@ -148,6 +151,7 @@ function serializeMenus() {
148
151
  id: menu.id,
149
152
  label: menu.label,
150
153
  order: index + 1,
154
+ surface: menu.surface ?? 'menubar',
151
155
  elements: menu.items
152
156
  .map((item) => serializeMenuItem(item))
153
157
  .filter((item) => Boolean(item)),
@@ -225,16 +229,19 @@ function getMenu(menuId) {
225
229
  return null;
226
230
  return createMenuHandle(stored.id);
227
231
  }
228
- /** Returns a menu by id, creating it if needed. */
229
- function getOrCreateMenu(menuId, label) {
230
- const stored = ensureStoredMenu(menuId, label);
231
- return createMenuHandle(stored.id);
232
- }
233
- /** Creates a menu at a specific position. */
234
- function createMenu(menuId, label, options) {
235
- const stored = ensureStoredMenu(menuId, label, options);
232
+ /** Returns a menu by id, creating it if needed.
233
+ * @param menuId - Menu identifier
234
+ * @param label - User-visible label
235
+ * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
236
+ */
237
+ function getOrCreateMenu(menuId, label, options) {
238
+ const surface = options?.surface ?? 'menubar';
239
+ const { surface: _, ...restOptions } = options ?? {};
240
+ const stored = ensureStoredMenu(menuId, label, restOptions, surface);
236
241
  return createMenuHandle(stored.id);
237
242
  }
243
+ /** Creates a menu at a specific position (alias for getOrCreateMenu). */
244
+ exports.createMenu = getOrCreateMenu;
238
245
  /** Adds one item to a menu. */
239
246
  function addMenuItem(menuId, item) {
240
247
  createMenuHandle(menuId).addItem(item);
@@ -77,6 +77,8 @@ export declare abstract class VcsDelegateBase<TDeps, TContext = PluginRuntimeCon
77
77
  writeMergeResult(_params: VcsTypes.VcsWriteMergeResultParams, _context: TContext): VcsHandlerResult<null>;
78
78
  /** Handles `vcs.stage_patch`. */
79
79
  stagePatch(_params: VcsTypes.VcsStagePatchParams, _context: TContext): VcsHandlerResult<null>;
80
+ /** Handles `vcs.stage_paths`. */
81
+ stagePaths(_params: VcsTypes.VcsStagePathsParams, _context: TContext): VcsHandlerResult<null>;
80
82
  /** Handles `vcs.discard_paths`. */
81
83
  discardPaths(_params: VcsTypes.VcsDiscardPathsParams, _context: TContext): VcsHandlerResult<null>;
82
84
  /** Handles `vcs.apply_reverse_patch`. */
@@ -157,6 +157,10 @@ class VcsDelegateBase {
157
157
  stagePatch(_params, _context) {
158
158
  return this.unimplemented('stagePatch');
159
159
  }
160
+ /** Handles `vcs.stage_paths`. */
161
+ stagePaths(_params, _context) {
162
+ return this.unimplemented('stagePaths');
163
+ }
160
164
  /** Handles `vcs.discard_paths`. */
161
165
  discardPaths(_params, _context) {
162
166
  return this.unimplemented('discardPaths');
@@ -30,6 +30,7 @@ export type VcsDelegateBindings<TContext> = {
30
30
  checkoutConflictSide: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.checkout_conflict_side']>;
31
31
  writeMergeResult: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.write_merge_result']>;
32
32
  stagePatch: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stage_patch']>;
33
+ stagePaths: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stage_paths']>;
33
34
  discardPaths: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.discard_paths']>;
34
35
  applyReversePatch: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.apply_reverse_patch']>;
35
36
  deleteBranch: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.delete_branch']>;
@@ -85,6 +86,7 @@ export declare const VCS_DELEGATE_METHOD_MAPPINGS: {
85
86
  readonly checkoutConflictSide: "vcs.checkout_conflict_side";
86
87
  readonly writeMergeResult: "vcs.write_merge_result";
87
88
  readonly stagePatch: "vcs.stage_patch";
89
+ readonly stagePaths: "vcs.stage_paths";
88
90
  readonly discardPaths: "vcs.discard_paths";
89
91
  readonly applyReversePatch: "vcs.apply_reverse_patch";
90
92
  readonly deleteBranch: "vcs.delete_branch";
@@ -33,6 +33,7 @@ exports.VCS_DELEGATE_METHOD_MAPPINGS = {
33
33
  checkoutConflictSide: 'vcs.checkout_conflict_side',
34
34
  writeMergeResult: 'vcs.write_merge_result',
35
35
  stagePatch: 'vcs.stage_patch',
36
+ stagePaths: 'vcs.stage_paths',
36
37
  discardPaths: 'vcs.discard_paths',
37
38
  applyReversePatch: 'vcs.apply_reverse_patch',
38
39
  deleteBranch: 'vcs.delete_branch',
@@ -15,8 +15,41 @@ export interface PluginInitializeResult {
15
15
  }
16
16
  /** Describes one optional override returned by a custom initialize handler. */
17
17
  export type PluginInitializeOverride = Partial<PluginInitializeResult>;
18
+ /** Describes the UI surface targeted by one plugin menu definition. */
19
+ export type PluginMenuSurface = 'menubar' | 'settings';
20
+ /** Describes one static text element contributed to a plugin menu. */
21
+ export interface PluginMenuTextElement {
22
+ /** Stores the serialized element kind. */
23
+ type: 'text';
24
+ /** Stores the stable plugin-local element id. */
25
+ id: string;
26
+ /** Stores the rendered text content. */
27
+ content: string;
28
+ }
29
+ /** Describes one button element contributed to a plugin menu. */
30
+ export interface PluginMenuButtonElement {
31
+ /** Stores the serialized element kind. */
32
+ type: 'button';
33
+ /** Stores the stable action id dispatched back to the plugin. */
34
+ id: string;
35
+ /** Stores the user-visible button label. */
36
+ label: string;
37
+ }
38
+ /** Describes one renderable plugin menu element. */
39
+ export type PluginMenuElement = PluginMenuTextElement | PluginMenuButtonElement;
18
40
  /** Describes one plugin-contributed menu definition. */
19
- export type PluginMenuDefinition = Record<string, unknown>;
41
+ export interface PluginMenuDefinition {
42
+ /** Stores the stable plugin-local menu id. */
43
+ id: string;
44
+ /** Stores the user-visible menu label. */
45
+ label: string;
46
+ /** Stores the display ordering hint assigned by the runtime. */
47
+ order: number;
48
+ /** Stores the target UI surface for the menu. */
49
+ surface: PluginMenuSurface;
50
+ /** Stores the renderable elements contributed under the menu. */
51
+ elements: PluginMenuElement[];
52
+ }
20
53
  /** Describes one plugin settings value payload. */
21
54
  export type PluginSettingsValue = Record<string, unknown>;
22
55
  /** Describes the params shape for plugin action handling. */
@@ -261,6 +261,11 @@ export interface VcsStagePatchParams extends VcsSessionParams {
261
261
  /** Stores the textual patch content. */
262
262
  patch: string;
263
263
  }
264
+ /** Describes params for staging repository-relative paths into the index. */
265
+ export interface VcsStagePathsParams extends VcsSessionParams {
266
+ /** Stores the paths to stage. */
267
+ paths?: string[];
268
+ }
264
269
  /** Describes params for discarding path changes. */
265
270
  export interface VcsDiscardPathsParams extends VcsSessionParams {
266
271
  /** Stores the paths to discard. */
@@ -424,6 +429,8 @@ export interface VcsDelegates<TContext = unknown> {
424
429
  'vcs.write_merge_result'?: RpcMethodHandler<VcsWriteMergeResultParams, null, TContext>;
425
430
  /** Handles `vcs.stage_patch`. */
426
431
  'vcs.stage_patch'?: RpcMethodHandler<VcsStagePatchParams, null, TContext>;
432
+ /** Handles `vcs.stage_paths`. */
433
+ 'vcs.stage_paths'?: RpcMethodHandler<VcsStagePathsParams, null, TContext>;
427
434
  /** Handles `vcs.discard_paths`. */
428
435
  'vcs.discard_paths'?: RpcMethodHandler<VcsDiscardPathsParams, null, TContext>;
429
436
  /** Handles `vcs.apply_reverse_patch`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openvcs/sdk",
3
- "version": "0.2.18-edge.20260420.21",
3
+ "version": "0.2.18-edge.20260422.25",
4
4
  "description": "OpenVCS SDK CLI for plugin scaffolding and runtime asset builds",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "homepage": "https://openvcs.app/",
@@ -12,6 +12,7 @@ import type { PluginRuntimeContext } from './contracts.js';
12
12
 
13
13
  type MenubarMenuOptions = { before?: string; after?: string };
14
14
  type MenuEntryKind = 'button' | 'text' | 'separator';
15
+ type MenuSurface = 'menubar' | 'settings';
15
16
 
16
17
  type OpenVCSGlobal = typeof globalThis & {
17
18
  OpenVCS?: {
@@ -34,6 +35,8 @@ interface StoredMenuState {
34
35
  id: string;
35
36
  label: string;
36
37
  hidden?: boolean;
38
+ /** Surface target for rendering (defaults to menubar for back-compat). */
39
+ surface?: 'menubar' | 'settings';
37
40
  items: StoredMenuItem[];
38
41
  }
39
42
 
@@ -48,6 +51,7 @@ interface SerializedMenuDefinition {
48
51
  id: string;
49
52
  label: string;
50
53
  order: number;
54
+ surface: 'menubar' | 'settings';
51
55
  elements: SerializedMenuItem[];
52
56
  }
53
57
 
@@ -116,16 +120,19 @@ function ensureStoredMenu(
116
120
  menuId: string,
117
121
  label: string,
118
122
  options?: MenubarMenuOptions,
123
+ surface: MenuSurface = 'menubar',
119
124
  ): StoredMenuState {
120
125
  const id = normalizeMenuId(menuId);
121
126
  const safeLabel = String(label || '').trim() || id;
122
127
  let menu = menus.get(id);
123
128
 
124
129
  if (!menu) {
125
- menu = { id, label: safeLabel, items: [] };
130
+ menu = { id, label: safeLabel, surface, items: [] };
126
131
  menus.set(id, menu);
127
132
  } else {
128
133
  menu.label = safeLabel;
134
+ // Preserve surface if already set, otherwise use provided.
135
+ if (!menu.surface) menu.surface = surface;
129
136
  }
130
137
 
131
138
  placeMenuId(id, options);
@@ -207,6 +214,7 @@ function serializeMenus(): SerializedMenuDefinition[] {
207
214
  id: menu.id,
208
215
  label: menu.label,
209
216
  order: index + 1,
217
+ surface: menu.surface ?? 'menubar',
210
218
  elements: menu.items
211
219
  .map((item) => serializeMenuItem(item))
212
220
  .filter((item): item is SerializedMenuItem => Boolean(item)),
@@ -292,17 +300,24 @@ export function getMenu(menuId: string): MenuHandle | null {
292
300
  return createMenuHandle(stored.id);
293
301
  }
294
302
 
295
- /** Returns a menu by id, creating it if needed. */
296
- export function getOrCreateMenu(menuId: string, label: string): MenuHandle | null {
297
- const stored = ensureStoredMenu(menuId, label);
303
+ /** Returns a menu by id, creating it if needed.
304
+ * @param menuId - Menu identifier
305
+ * @param label - User-visible label
306
+ * @param options - Optional surface target ('menubar' or 'settings'), defaults to 'menubar'
307
+ */
308
+ export function getOrCreateMenu(
309
+ menuId: string,
310
+ label: string,
311
+ options?: MenubarMenuOptions & { surface?: MenuSurface },
312
+ ): MenuHandle | null {
313
+ const surface = options?.surface ?? 'menubar';
314
+ const { surface: _, ...restOptions } = options ?? {};
315
+ const stored = ensureStoredMenu(menuId, label, restOptions, surface);
298
316
  return createMenuHandle(stored.id);
299
317
  }
300
318
 
301
- /** Creates a menu at a specific position. */
302
- export function createMenu(menuId: string, label: string, options?: MenubarMenuOptions): MenuHandle | null {
303
- const stored = ensureStoredMenu(menuId, label, options);
304
- return createMenuHandle(stored.id);
305
- }
319
+ /** Creates a menu at a specific position (alias for getOrCreateMenu). */
320
+ export const createMenu = getOrCreateMenu;
306
321
 
307
322
  /** Adds one item to a menu. */
308
323
  export function addMenuItem(menuId: string, item: MenubarItem): void {
@@ -303,6 +303,14 @@ export abstract class VcsDelegateBase<
303
303
  return this.unimplemented('stagePatch');
304
304
  }
305
305
 
306
+ /** Handles `vcs.stage_paths`. */
307
+ stagePaths(
308
+ _params: VcsTypes.VcsStagePathsParams,
309
+ _context: TContext,
310
+ ): VcsHandlerResult<null> {
311
+ return this.unimplemented('stagePaths');
312
+ }
313
+
306
314
  /** Handles `vcs.discard_paths`. */
307
315
  discardPaths(
308
316
  _params: VcsTypes.VcsDiscardPathsParams,
@@ -53,6 +53,7 @@ export type VcsDelegateBindings<TContext> = {
53
53
  VcsTypes.VcsDelegates<TContext>['vcs.write_merge_result']
54
54
  >;
55
55
  stagePatch: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stage_patch']>;
56
+ stagePaths: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.stage_paths']>;
56
57
  discardPaths: NonNullable<VcsTypes.VcsDelegates<TContext>['vcs.discard_paths']>;
57
58
  applyReversePatch: NonNullable<
58
59
  VcsTypes.VcsDelegates<TContext>['vcs.apply_reverse_patch']
@@ -122,6 +123,7 @@ export const VCS_DELEGATE_METHOD_MAPPINGS = {
122
123
  checkoutConflictSide: 'vcs.checkout_conflict_side',
123
124
  writeMergeResult: 'vcs.write_merge_result',
124
125
  stagePatch: 'vcs.stage_patch',
126
+ stagePaths: 'vcs.stage_paths',
125
127
  discardPaths: 'vcs.discard_paths',
126
128
  applyReversePatch: 'vcs.apply_reverse_patch',
127
129
  deleteBranch: 'vcs.delete_branch',
@@ -22,8 +22,45 @@ export interface PluginInitializeResult {
22
22
  /** Describes one optional override returned by a custom initialize handler. */
23
23
  export type PluginInitializeOverride = Partial<PluginInitializeResult>;
24
24
 
25
+ /** Describes the UI surface targeted by one plugin menu definition. */
26
+ export type PluginMenuSurface = 'menubar' | 'settings';
27
+
28
+ /** Describes one static text element contributed to a plugin menu. */
29
+ export interface PluginMenuTextElement {
30
+ /** Stores the serialized element kind. */
31
+ type: 'text';
32
+ /** Stores the stable plugin-local element id. */
33
+ id: string;
34
+ /** Stores the rendered text content. */
35
+ content: string;
36
+ }
37
+
38
+ /** Describes one button element contributed to a plugin menu. */
39
+ export interface PluginMenuButtonElement {
40
+ /** Stores the serialized element kind. */
41
+ type: 'button';
42
+ /** Stores the stable action id dispatched back to the plugin. */
43
+ id: string;
44
+ /** Stores the user-visible button label. */
45
+ label: string;
46
+ }
47
+
48
+ /** Describes one renderable plugin menu element. */
49
+ export type PluginMenuElement = PluginMenuTextElement | PluginMenuButtonElement;
50
+
25
51
  /** Describes one plugin-contributed menu definition. */
26
- export type PluginMenuDefinition = Record<string, unknown>;
52
+ export interface PluginMenuDefinition {
53
+ /** Stores the stable plugin-local menu id. */
54
+ id: string;
55
+ /** Stores the user-visible menu label. */
56
+ label: string;
57
+ /** Stores the display ordering hint assigned by the runtime. */
58
+ order: number;
59
+ /** Stores the target UI surface for the menu. */
60
+ surface: PluginMenuSurface;
61
+ /** Stores the renderable elements contributed under the menu. */
62
+ elements: PluginMenuElement[];
63
+ }
27
64
 
28
65
  /** Describes one plugin settings value payload. */
29
66
  export type PluginSettingsValue = Record<string, unknown>;
@@ -298,6 +298,12 @@ export interface VcsStagePatchParams extends VcsSessionParams {
298
298
  patch: string;
299
299
  }
300
300
 
301
+ /** Describes params for staging repository-relative paths into the index. */
302
+ export interface VcsStagePathsParams extends VcsSessionParams {
303
+ /** Stores the paths to stage. */
304
+ paths?: string[];
305
+ }
306
+
301
307
  /** Describes params for discarding path changes. */
302
308
  export interface VcsDiscardPathsParams extends VcsSessionParams {
303
309
  /** Stores the paths to discard. */
@@ -518,6 +524,8 @@ export interface VcsDelegates<TContext = unknown> {
518
524
  >;
519
525
  /** Handles `vcs.stage_patch`. */
520
526
  'vcs.stage_patch'?: RpcMethodHandler<VcsStagePatchParams, null, TContext>;
527
+ /** Handles `vcs.stage_paths`. */
528
+ 'vcs.stage_paths'?: RpcMethodHandler<VcsStagePathsParams, null, TContext>;
521
529
  /** Handles `vcs.discard_paths`. */
522
530
  'vcs.discard_paths'?: RpcMethodHandler<VcsDiscardPathsParams, null, TContext>;
523
531
  /** Handles `vcs.apply_reverse_patch`. */