Skip to content

Commit c2d630d

Browse files
authored
Merge pull request #1 from dmasior/v0.4
Add AI integration, plugin system, and migrate to ES modules
2 parents b2e86dc + ea60b70 commit c2d630d

32 files changed

+2172
-1214
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ jobs:
1818
uses: actions/checkout@v3
1919

2020
- name: Set up Node.js
21-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v6
2222
with:
23-
node-version: 22
23+
node-version: 24
2424

25-
- name: Install dependencies
26-
run: npm install
25+
- name: Clean install dependencies
26+
run: npm ci
2727

2828
- name: Build application
2929
run: npm run make -- --arch x64,arm64

PLUGINS.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Plugins
2+
3+
DMTool loads plugins from `~/.dmtool/plugins/`. Each plugin is an ES module (`.js` or `.mjs`) that exports a default object with a name and a list of actions.
4+
5+
## Plugin structure
6+
7+
```js
8+
export default {
9+
name: "My Plugin",
10+
actions: [
11+
{
12+
label: "Uppercase",
13+
fn: (clipboardText) => clipboardText.toUpperCase(),
14+
},
15+
{
16+
label: "Nested",
17+
submenu: [
18+
{
19+
label: "Reverse",
20+
fn: (clipboardText) => clipboardText.split("").reverse().join(""),
21+
},
22+
],
23+
},
24+
],
25+
};
26+
```
27+
28+
### Action fields
29+
30+
| Field | Type | Description |
31+
|-------|------|-------------|
32+
| `label` | `string` | Menu item label |
33+
| `fn` | `(clipboardText: string) => string \| Promise<string>` | Receives current clipboard text, returned string is written back to clipboard |
34+
| `submenu` | `Action[]` | Nested actions (cannot have `fn` at the same level) |
35+
36+
## Environment variables
37+
38+
Place a `.env` file in `~/.dmtool/` to provide environment variables to plugins. Standard `KEY=VALUE` format, supports `#` comments and quoted values.
39+
40+
```
41+
# ~/.dmtool/.env
42+
API_URL=https://api.example.com
43+
API_KEY=abc123
44+
```
45+
46+
Access in plugins via `process.env.API_URL`, `process.env.API_KEY`, etc.
47+
48+
## Example: fetch-based plugin
49+
50+
```js
51+
export default {
52+
name: "Translate",
53+
actions: [
54+
{
55+
label: "To Spanish",
56+
fn: async (text) => {
57+
const { API_URL, API_KEY } = process.env;
58+
const res = await fetch(`${API_URL}/translate?to=es&key=${API_KEY}&text=${encodeURIComponent(text)}`);
59+
const data = await res.json();
60+
return data.translation;
61+
},
62+
},
63+
],
64+
};
65+
```
66+
67+
## Notes
68+
69+
- Plugins are loaded once at startup. Restart DMTool after adding or modifying plugins.
70+
- If a plugin fails to load, an error is logged into `~/.dmtool/dmtool.log` and other plugins are unaffected.
71+
- Async `fn` functions are supported.

README.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
# DMTool
22

3-
Tool for developers. Perform operations on your clipboard data with ease.
3+
A menu bar utility that transforms your clipboard - encode, format, hash, and more.
44

5-
![dropdown presentation](./assets/dropdown_presentation.png)
5+
![dropdown presentation](./assets/dropdown.png)
66

77
## Features
88

9-
- Encode and decode: Base64, Hex, URL, HTML
10-
- JSON utility functions
11-
- Beautify and minify
12-
- Escape and unescape
13-
- Validate
14-
- Trim
15-
- Convert case
16-
- Uppercase, lowercase
17-
- Capitalize words, sentences
18-
- CamelCase, snake_case, kebab-case
19-
- Line
20-
- Count, sort, trim, reverse
21-
- Remove empty
22-
- Remove duplicates
23-
- UUID
24-
- Generate V1, V4, V6, V7
25-
- Validate
26-
- Convert between V1 and V6
27-
- Hash
28-
- MD5, SHA1,
29-
- SHA256, SHA384, SHA512,
30-
- SHA3-256, SHA3-384, SHA3-512,
31-
- BLAKE2b
9+
- **AI** — Query GitHub Copilot models with your clipboard as context
10+
- **Encoding** — Base64, URL, HTML entities (encode/decode)
11+
- **JSON** — Validate, beautify, minify, escape/unescape
12+
- **Lines** — Sort, trim
13+
- **UUID** — Detect version, generate V1/V4/V6/V7
14+
- **Hash** — MD5, SHA1
15+
- **Plugins** — Extend with custom JS plugins (see [PLUGINS.md](PLUGINS.md))
16+
3217
## Usage
3318

34-
1. Copy the data you want to perform an operation on
35-
2. Select the operation from the dropdown
36-
3. Paste the result
19+
1. Copy text to your clipboard
20+
2. Click the DMTool icon in the menu bar
21+
3. Select an operation
22+
4. The result is automatically copied — just paste
23+
24+
## Plugins
25+
26+
DMTool supports user-defined plugins loaded from `~/.dmtool/plugins/`. Plugins are ES modules that add custom actions to the tray menu. Environment variables can be provided via `~/.dmtool/.env`.
27+
28+
See [PLUGINS.md](PLUGINS.md) for the full plugin API and examples.
3729

3830
## Download
3931

assets/dropdown.png

91.5 KB
Loading

assets/dropdown_presentation.png

-105 KB
Binary file not shown.

assets/icons/tray/mac-icon.png

-485 Bytes
Binary file not shown.
7.43 KB
Loading
7.73 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)