Skip to content

Commit cff7368

Browse files
authored
adding more structured "skill.md" files instead of using aiprompts directory (#2885)
1 parent 1742499 commit cff7368

8 files changed

Lines changed: 2089 additions & 16 deletions

File tree

.kilocode/skills/add-config/SKILL.md

Lines changed: 471 additions & 0 deletions
Large diffs are not rendered by default.

.kilocode/skills/add-rpc/SKILL.md

Lines changed: 453 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
---
2+
name: context-menu
3+
description: Guide for creating and displaying context menus in Wave Terminal. Use when implementing right-click menus, adding context menu items, creating submenus, or handling menu interactions with checkboxes and separators.
4+
---
5+
6+
# Context Menu Quick Reference
7+
8+
This guide provides a quick overview of how to create and display a context menu using our system.
9+
10+
---
11+
12+
## ContextMenuItem Type
13+
14+
Define each menu item using the `ContextMenuItem` type:
15+
16+
```ts
17+
type ContextMenuItem = {
18+
label?: string;
19+
type?: "separator" | "normal" | "submenu" | "checkbox" | "radio";
20+
role?: string; // Electron role (optional)
21+
click?: () => void; // Callback for item selection (not needed if role is set)
22+
submenu?: ContextMenuItem[]; // For nested menus
23+
checked?: boolean; // For checkbox or radio items
24+
visible?: boolean;
25+
enabled?: boolean;
26+
sublabel?: string;
27+
};
28+
```
29+
30+
---
31+
32+
## Import and Show the Menu
33+
34+
Import the context menu module:
35+
36+
```ts
37+
import { ContextMenuModel } from "@/app/store/contextmenu";
38+
```
39+
40+
To display the context menu, call:
41+
42+
```ts
43+
ContextMenuModel.showContextMenu(menu, event);
44+
```
45+
46+
- **menu**: An array of `ContextMenuItem`.
47+
- **event**: The mouse event that triggered the context menu (typically from an onContextMenu handler).
48+
49+
---
50+
51+
## Basic Example
52+
53+
A simple context menu with a separator:
54+
55+
```ts
56+
const menu: ContextMenuItem[] = [
57+
{
58+
label: "New File",
59+
click: () => {
60+
/* create a new file */
61+
},
62+
},
63+
{
64+
label: "New Folder",
65+
click: () => {
66+
/* create a new folder */
67+
},
68+
},
69+
{ type: "separator" },
70+
{
71+
label: "Rename",
72+
click: () => {
73+
/* rename item */
74+
},
75+
},
76+
];
77+
78+
ContextMenuModel.showContextMenu(menu, e);
79+
```
80+
81+
---
82+
83+
## Example with Submenu and Checkboxes
84+
85+
Toggle settings using a submenu with checkbox items:
86+
87+
```ts
88+
const isClearOnStart = true; // Example setting
89+
90+
const menu: ContextMenuItem[] = [
91+
{
92+
label: "Clear Output On Restart",
93+
submenu: [
94+
{
95+
label: "On",
96+
type: "checkbox",
97+
checked: isClearOnStart,
98+
click: () => {
99+
// Set the config to enable clear on restart
100+
},
101+
},
102+
{
103+
label: "Off",
104+
type: "checkbox",
105+
checked: !isClearOnStart,
106+
click: () => {
107+
// Set the config to disable clear on restart
108+
},
109+
},
110+
],
111+
},
112+
];
113+
114+
ContextMenuModel.showContextMenu(menu, e);
115+
```
116+
117+
---
118+
119+
## Editing a Config File Example
120+
121+
Open a configuration file (e.g., `widgets.json`) in preview mode:
122+
123+
```ts
124+
{
125+
label: "Edit widgets.json",
126+
click: () => {
127+
fireAndForget(async () => {
128+
const path = `${getApi().getConfigDir()}/widgets.json`;
129+
const blockDef: BlockDef = {
130+
meta: { view: "preview", file: path },
131+
};
132+
await createBlock(blockDef, false, true);
133+
});
134+
},
135+
}
136+
```
137+
138+
---
139+
140+
## Summary
141+
142+
- **Menu Definition**: Use the `ContextMenuItem` type.
143+
- **Actions**: Use `click` for actions; use `submenu` for nested options.
144+
- **Separators**: Use `type: "separator"` to group items.
145+
- **Toggles**: Use `type: "checkbox"` or `"radio"` with the `checked` property.
146+
- **Displaying**: Use `ContextMenuModel.showContextMenu(menu, event)` to render the menu.
147+
148+
## Common Use Cases
149+
150+
### File/Folder Operations
151+
Context menus are commonly used for file operations like creating, renaming, and deleting files or folders.
152+
153+
### Settings Toggles
154+
Use checkbox menu items to toggle settings on and off, with the `checked` property reflecting the current state.
155+
156+
### Nested Options
157+
Use `submenu` to organize related options hierarchically, keeping the top-level menu clean and organized.
158+
159+
### Conditional Items
160+
Use the `visible` and `enabled` properties to dynamically show or disable menu items based on the current state.

0 commit comments

Comments
 (0)