taskwindow 0.1.1 → 0.1.2
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 +6 -7
- package/package.json +1 -1
- package/src/agents.js +60 -0
- package/src/index.js +27 -11
package/README.md
CHANGED
|
@@ -55,17 +55,16 @@ Or just keep `npx taskwindow` running in a terminal — both work.
|
|
|
55
55
|
|
|
56
56
|
(Manual token paste also works — `~/.taskwindow/token`.)
|
|
57
57
|
|
|
58
|
-
### 4. Connect your coding agent
|
|
59
|
-
|
|
60
|
-
The daemon prints the ready-made command at startup. For Claude Code:
|
|
58
|
+
### 4. Connect your coding agent (one agent at a time, only when you ask)
|
|
61
59
|
|
|
62
60
|
```bash
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
taskwindow install --claude # Claude Code
|
|
62
|
+
taskwindow install --cursor # Cursor
|
|
65
63
|
```
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
`http://127.0.0.1:9377/mcp` with header
|
|
65
|
+
Nothing is registered for agents you don't name. For anything else, the
|
|
66
|
+
config is an HTTP MCP server at `http://127.0.0.1:9377/mcp` with header
|
|
67
|
+
`Authorization: Bearer <token>` (the token is in `~/.taskwindow/token`).
|
|
69
68
|
|
|
70
69
|
### 5. Try it
|
|
71
70
|
|
package/package.json
CHANGED
package/src/agents.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional per-agent MCP registration, always explicit:
|
|
3
|
+
* taskwindow install --claude → Claude Code
|
|
4
|
+
* taskwindow install --cursor → Cursor
|
|
5
|
+
* Nothing is registered unless the matching flag is given.
|
|
6
|
+
*/
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join, dirname } from "node:path";
|
|
9
|
+
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
10
|
+
import { execFileSync } from "node:child_process";
|
|
11
|
+
|
|
12
|
+
export function registerClaude({ port, token }) {
|
|
13
|
+
try {
|
|
14
|
+
// Replace an older registration, if any.
|
|
15
|
+
execFileSync("claude", ["mcp", "remove", "taskwindow"], { stdio: "ignore" });
|
|
16
|
+
} catch {}
|
|
17
|
+
execFileSync(
|
|
18
|
+
"claude",
|
|
19
|
+
[
|
|
20
|
+
"mcp", "add", "taskwindow",
|
|
21
|
+
"--transport", "http",
|
|
22
|
+
`http://127.0.0.1:${port}/mcp`,
|
|
23
|
+
"--header", `Authorization: Bearer ${token}`,
|
|
24
|
+
],
|
|
25
|
+
{ stdio: "inherit" }
|
|
26
|
+
);
|
|
27
|
+
console.log("[taskwindow] registered in Claude Code — verify with: claude mcp list");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function registerCursor({ port, token }) {
|
|
31
|
+
const path = join(homedir(), ".cursor", "mcp.json");
|
|
32
|
+
let cfg = {};
|
|
33
|
+
try {
|
|
34
|
+
cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
35
|
+
} catch {}
|
|
36
|
+
cfg.mcpServers = cfg.mcpServers || {};
|
|
37
|
+
cfg.mcpServers.taskwindow = {
|
|
38
|
+
url: `http://127.0.0.1:${port}/mcp`,
|
|
39
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
40
|
+
};
|
|
41
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
42
|
+
writeFileSync(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
43
|
+
console.log(`[taskwindow] registered in Cursor (${path})`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function unregisterAgents({ port }) {
|
|
47
|
+
try {
|
|
48
|
+
execFileSync("claude", ["mcp", "remove", "taskwindow"], { stdio: "ignore" });
|
|
49
|
+
console.log("[taskwindow] removed from Claude Code");
|
|
50
|
+
} catch {}
|
|
51
|
+
try {
|
|
52
|
+
const path = join(homedir(), ".cursor", "mcp.json");
|
|
53
|
+
const cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
54
|
+
if (cfg.mcpServers?.taskwindow) {
|
|
55
|
+
delete cfg.mcpServers.taskwindow;
|
|
56
|
+
writeFileSync(path, JSON.stringify(cfg, null, 2) + "\n");
|
|
57
|
+
console.log("[taskwindow] removed from Cursor");
|
|
58
|
+
}
|
|
59
|
+
} catch {}
|
|
60
|
+
}
|
package/src/index.js
CHANGED
|
@@ -6,29 +6,45 @@ import { loadConfig } from "./config.js";
|
|
|
6
6
|
import { Bridge } from "./bridge.js";
|
|
7
7
|
import { createMcpRequestHandler } from "./mcp-http.js";
|
|
8
8
|
import { installService, uninstallService } from "./service.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import { registerClaude, registerCursor, unregisterAgents } from "./agents.js";
|
|
10
|
+
|
|
11
|
+
// `taskwindow install` manages the login service and — only with an explicit
|
|
12
|
+
// per-agent flag — registers the MCP server in that agent.
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
const verb = args[0];
|
|
15
|
+
const flags = args.slice(1);
|
|
16
|
+
|
|
17
|
+
if (verb === "install") {
|
|
18
|
+
const config = loadConfig();
|
|
19
|
+
if (!flags.includes("--no-service")) {
|
|
20
|
+
installService(fileURLToPath(new URL("./index.js", import.meta.url)));
|
|
21
|
+
}
|
|
22
|
+
if (flags.includes("--claude")) registerClaude(config);
|
|
23
|
+
if (flags.includes("--cursor")) registerCursor(config);
|
|
24
|
+
if (flags.includes("--claude") || flags.includes("--cursor")) {
|
|
25
|
+
console.log(`[taskwindow] pairing code (if the extension asks): ${pairCode ?? "restart the daemon to see it"}`);
|
|
26
|
+
}
|
|
13
27
|
process.exit(0);
|
|
14
28
|
}
|
|
15
|
-
if (
|
|
16
|
-
|
|
29
|
+
if (verb === "uninstall") {
|
|
30
|
+
if (!flags.includes("--keep-agents")) unregisterAgents({ port: 9377 });
|
|
31
|
+
if (!flags.includes("--no-service")) uninstallService();
|
|
17
32
|
process.exit(0);
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
const config = loadConfig();
|
|
21
36
|
const bridge = new Bridge({ token: config.token });
|
|
37
|
+
|
|
38
|
+
const PAIR_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // no 0/O/1/I
|
|
39
|
+
const pairCode = Array.from(randomBytes(6))
|
|
40
|
+
.map((b) => PAIR_ALPHABET[b % PAIR_ALPHABET.length])
|
|
41
|
+
.join("");
|
|
22
42
|
const handleMcp = createMcpRequestHandler({ bridge });
|
|
23
43
|
|
|
24
44
|
// One-time pairing: the daemon prints a short code at startup; the extension
|
|
25
45
|
// exchanges it for the real token via POST /pair (loopback-only). This defends
|
|
26
46
|
// the pairing endpoint against other local user accounts; a same-user process
|
|
27
47
|
// could read the token file directly, so the code adds no obstacle there.
|
|
28
|
-
const PAIR_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // no 0/O/1/I
|
|
29
|
-
const pairCode = Array.from(randomBytes(6))
|
|
30
|
-
.map((b) => PAIR_ALPHABET[b % PAIR_ALPHABET.length])
|
|
31
|
-
.join("");
|
|
32
48
|
const pairFailures = []; // timestamps of failed attempts, rolling window
|
|
33
49
|
const PAIR_WINDOW_MS = 60_000;
|
|
34
50
|
const PAIR_MAX_FAILURES = 5;
|
|
@@ -152,7 +168,7 @@ server.listen(config.port, "127.0.0.1", () => {
|
|
|
152
168
|
console.log(`[taskwindow] MCP endpoint: http://127.0.0.1:${config.port}/mcp`);
|
|
153
169
|
console.log(`[taskwindow] pairing code: ${pairCode} — enter it in the TaskWindow extension options to connect (valid while this daemon runs)`);
|
|
154
170
|
console.log(`[taskwindow] your MCP client config: endpoint http://127.0.0.1:${config.port}/mcp, header "Authorization: Bearer ${config.token}"`);
|
|
155
|
-
console.log(`[taskwindow]
|
|
171
|
+
console.log(`[taskwindow] register an agent with: taskwindow install --claude (or --cursor)`);
|
|
156
172
|
console.log(`[taskwindow] waiting for the TaskWindow extension to connect on ws://127.0.0.1:${config.port}/ws`);
|
|
157
173
|
});
|
|
158
174
|
|