@quark.clip/quark 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adarsh Agrahari
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # 🌌 Quark
2
+
3
+ **The AI-Native, Cross-Platform Clipboard Micro-Daemon.**
4
+
5
+ Ā© 2026 Adarsh Agrahari. All Rights Reserved.
6
+
7
+ Quark is a headless, zero-configuration background service that orbits your operating system's clipboard. It silently fixes your copy-paste nightmares, syncs your clipboard across devices seamlessly, and exposes your clipboard directly to local AI models via the Model Context Protocol (MCP).
8
+
9
+ ---
10
+
11
+ ## šŸ›‘ The Problem
12
+
13
+ The operating system clipboard is fundamentally broken and stuck in the past:
14
+ - **Dumb Text:** You copy text from a PDF, and the line breaks shatter.
15
+ - **Privacy Leaks:** You copy a link, and tracking tags (`?utm_source=...`) follow you.
16
+ - **Lost Formatting:** You copy a table or Markdown, and the formatting vanishes when pasted into an email.
17
+ - **Isolation:** You switch to your laptop, and your clipboard is empty.
18
+ - **Blind AI:** Your local AI agents (Claude, Cursor) have no native access to what you just copied.
19
+
20
+ ## šŸ’” The Solution
21
+
22
+ **Enter Quark.** A silent, zero-configuration daemon that lives in your background. It requires no interface. It simply fixes what is broken.
23
+ - **Heals** broken PDF text automatically.
24
+ - **Strips** tracking parameters from URLs.
25
+ - **Transforms** raw Excel data, Markdown, and LaTeX into clean, rich HTML.
26
+ - **Syncs** across your Mac, Windows, and Linux machines instantly via P2P.
27
+ - **Exposes** your clipboard to local AI models via MCP.
28
+
29
+ ---
30
+
31
+ ## šŸš€ Quick Start
32
+
33
+ No `.exe` files. No `.dmg` files. Just pure, cross-platform JavaScript.
34
+
35
+ ```bash
36
+ # Run instantly without installing (Temporary Session)
37
+ npx quark-daemon start
38
+
39
+ # OR install globally as a background OS service
40
+ npm install -g quark-daemon
41
+ quark install
42
+ ```
43
+
44
+ ## šŸ—ļø Architecture
45
+
46
+ Quark is built entirely in Node.js to ensure 100% cross-platform compatibility without the need for native C++ compilation.
47
+
48
+ ```mermaid
49
+ graph TD
50
+ subgraph OS [Operating System]
51
+ Clip[OS Clipboard]
52
+ end
53
+
54
+ subgraph Quark [Quark Daemon]
55
+ Poll[Polling Engine]
56
+ Trans[Smart Transformers]
57
+ P2P[P2P Mesh Network]
58
+ API[Local HTTP API]
59
+ end
60
+
61
+ subgraph Network [Local Wi-Fi]
62
+ mDNS[mDNS Discovery]
63
+ WS[WebSocket Sync]
64
+ end
65
+
66
+ subgraph AI [AI Agents]
67
+ MCP[MCP Stdio Server]
68
+ Claude[Claude Desktop / Cursor]
69
+ end
70
+
71
+ Clip <-->|Read/Write| Poll
72
+ Poll -->|Raw Text/HTML| Trans
73
+ Trans -->|Cleaned/Formatted| Poll
74
+ Poll <-->|Broadcast/Receive| P2P
75
+ P2P <--> mDNS
76
+ P2P <--> WS
77
+ API <--> Clip
78
+ MCP <-->|HTTP GET/POST| API
79
+ Claude <-->|Stdio| MCP
80
+ ```
81
+
82
+ ### Technical Deep Dive
83
+ - **Clipboard Engine:** Uses native OS commands (`pbcopy`/`pbpaste` for macOS, `xclip` for Linux, `powershell` and `System.Windows.Forms` for Windows) to read and write both `text/plain` and `text/html` streams simultaneously.
84
+ - **Zero-Config Mesh Network:** Uses mDNS (Bonjour/ZeroConf) to broadcast its presence (`quark-clip`). When peers discover each other, they establish direct WebSocket connections. No central server is used.
85
+ - **Transformation Pipeline:** A synchronous/asynchronous pipeline that detects content types (Markdown, LaTeX, URLs, TSV) and applies regex heuristics, `marked` parsing, and smart typographic quoting based on language character frequency.
86
+
87
+ ---
88
+
89
+ ## šŸ¤– Model Context Protocol (MCP)
90
+
91
+ Quark acts as a bridge between your OS clipboard and local AI models using the [Model Context Protocol](https://modelcontextprotocol.io/).
92
+
93
+ When you run `quark mcp`, it starts a standard MCP server over `stdio`. This server communicates with the background Quark daemon via a local HTTP API (port `14314`).
94
+
95
+ ### Exposed Tools
96
+ 1. \`get_clipboard\`: Reads the user's current operating system clipboard.
97
+ 2. \`set_clipboard\`: Writes text directly to the user's operating system clipboard.
98
+
99
+ ### Claude Desktop Integration
100
+ To give Claude Desktop access to your clipboard, add Quark to your `claude_desktop_config.json`:
101
+
102
+ ```json
103
+ {
104
+ "mcpServers": {
105
+ "quark": {
106
+ "command": "npx",
107
+ "args": ["quark-daemon", "mcp"]
108
+ }
109
+ }
110
+ }
111
+ ```
112
+ *Note: Ensure the Quark daemon is running in the background (`quark start` or `quark install`) for the MCP server to function.*
113
+
114
+ ---
115
+
116
+ ## šŸ¤ Contributing
117
+
118
+ Please read `CONTRIBUTING.md` for details on our code of conduct, and the process for submitting pull requests to us.
119
+
120
+ ## šŸ“„ License
121
+
122
+ This project is licensed under the MIT License - see the `LICENSE` file for details.
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+ const { spawn } = require('child_process');
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const { installService, uninstallService } = require('../src/installer');
6
+
7
+ const command = process.argv[2] || 'help';
8
+ const daemonPath = path.join(__dirname, '../src/daemon.js');
9
+ const mcpPath = path.join(__dirname, '../src/mcp.js');
10
+ const pidFile = path.join(__dirname, '../quark.pid');
11
+ const logFile = path.join(__dirname, '../quark.log');
12
+
13
+ switch (command) {
14
+ case 'start':
15
+ console.log(`
16
+ o-------o
17
+ | \\ / |
18
+ | o |
19
+ | / \\ |
20
+ o-------o
21
+ `);
22
+ console.log('šŸš€ Starting Quark Daemon (Temporary Session)...');
23
+ if (fs.existsSync(pidFile)) {
24
+ console.log('āš ļø Quark is already running. Run `quark stop` first.');
25
+ process.exit(1);
26
+ }
27
+ const out = fs.openSync(logFile, 'a');
28
+ const err = fs.openSync(logFile, 'a');
29
+ const child = spawn('node', [daemonPath], {
30
+ detached: true,
31
+ stdio: ['ignore', out, err]
32
+ });
33
+ fs.writeFileSync(pidFile, child.pid.toString());
34
+ child.unref();
35
+ console.log('✨ Quark is now orbiting your clipboard in the background.');
36
+ console.log('šŸ’” Tip: Run `quark install` to make it start automatically on boot.');
37
+ break;
38
+
39
+ case 'stop':
40
+ if (fs.existsSync(pidFile)) {
41
+ const pid = fs.readFileSync(pidFile, 'utf8');
42
+ try {
43
+ process.kill(parseInt(pid, 10));
44
+ console.log('šŸ›‘ Quark Daemon stopped.');
45
+ } catch (e) {
46
+ console.log('āš ļø Quark process not found. Cleaning up pid file.');
47
+ }
48
+ fs.unlinkSync(pidFile);
49
+ } else {
50
+ console.log('Quark is not running via manual start.');
51
+ }
52
+ break;
53
+
54
+ case 'install':
55
+ installService();
56
+ break;
57
+
58
+ case 'uninstall':
59
+ uninstallService();
60
+ break;
61
+
62
+ case 'status':
63
+ const isRunning = fs.existsSync(pidFile);
64
+ console.log(`\n🌌 Quark Status`);
65
+ console.log(`----------------`);
66
+ console.log(`Manual Session: ${isRunning ? '🟢 Running' : 'šŸ”“ Stopped'}`);
67
+
68
+ // Check OS Service Status
69
+ const os = require('os');
70
+ const platform = os.platform();
71
+ let serviceRunning = false;
72
+ try {
73
+ if (platform === 'darwin') {
74
+ const plistPath = path.join(os.homedir(), 'Library', 'LaunchAgents', 'com.quark.daemon.plist');
75
+ if (fs.existsSync(plistPath)) {
76
+ const out = require('child_process').execSync('launchctl list | grep com.quark.daemon', { encoding: 'utf8' });
77
+ serviceRunning = out.includes('com.quark.daemon');
78
+ }
79
+ } else if (platform === 'linux') {
80
+ const servicePath = path.join(os.homedir(), '.config', 'systemd', 'user', 'quark.service');
81
+ if (fs.existsSync(servicePath)) {
82
+ const out = require('child_process').execSync('systemctl --user is-active quark.service', { encoding: 'utf8' });
83
+ serviceRunning = out.trim() === 'active';
84
+ }
85
+ } else if (platform === 'win32') {
86
+ const vbsPath = path.join(process.env.APPDATA, 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup', 'quark.vbs');
87
+ if (fs.existsSync(vbsPath)) {
88
+ const out = require('child_process').execSync('wmic process where "CommandLine like \'%daemon.js%\'" get ProcessId', { encoding: 'utf8' });
89
+ serviceRunning = out.includes('ProcessId') && out.trim().split('\n').length > 1;
90
+ }
91
+ }
92
+ } catch (e) {
93
+ // Ignore errors from execSync if service is not running
94
+ }
95
+
96
+ console.log(`OS Service: ${serviceRunning ? '🟢 Installed & Running' : 'šŸ”“ Not Installed / Stopped'}`);
97
+ console.log(`\nLog file: ${logFile}`);
98
+ if (!serviceRunning) {
99
+ console.log(`\nšŸ’” Tip: Run 'quark install' to configure auto-start on boot.`);
100
+ }
101
+ break;
102
+
103
+ case 'mcp':
104
+ // Starts the MCP Stdio server (used by LLMs like Claude Desktop)
105
+ require(mcpPath);
106
+ break;
107
+
108
+ default:
109
+ console.log(`
110
+ 🌌 Quark CLI
111
+
112
+ Usage:
113
+ quark start Start the daemon in the background (current session)
114
+ quark stop Stop the manually started daemon
115
+ quark install Install Quark as a native OS background service (Auto-start on boot)
116
+ quark uninstall Remove the native OS background service
117
+ quark status Check daemon status
118
+ quark mcp Start the MCP Server (used by LLMs via stdio)
119
+ `);
120
+ }