taskwindow 0.1.9 → 0.1.11
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 -3
- package/package.json +1 -1
- package/src/index.js +109 -36
- package/src/service.js +31 -4
package/README.md
CHANGED
|
@@ -32,6 +32,9 @@ restart — no terminal needed) and prints:
|
|
|
32
32
|
Keep the pairing code for step 3. (Prefer running it by hand? `npx taskwindow`
|
|
33
33
|
in a terminal works too — it just won't survive a restart.)
|
|
34
34
|
|
|
35
|
+
The installer also asks which coding agents should use TaskWindow. Choose one
|
|
36
|
+
or more, or choose **None** to set them up later in step 4.
|
|
37
|
+
|
|
35
38
|
### 2. Install the Chrome extension
|
|
36
39
|
|
|
37
40
|
You already have the CLI — add the extension:
|
|
@@ -42,9 +45,9 @@ taskwindow install --extension
|
|
|
42
45
|
|
|
43
46
|
That downloads the latest release, unpacks it, opens Chrome at
|
|
44
47
|
`chrome://extensions`, and prints the last 3 clicks (Developer mode →
|
|
45
|
-
Load unpacked → select the
|
|
46
|
-
those clicks — no tool can do them
|
|
47
|
-
install + auto-updates) is planned.
|
|
48
|
+
Load unpacked → select the visible `TaskWindow Extension` folder in your home
|
|
49
|
+
directory). Chrome's own policy requires those clicks — no tool can do them
|
|
50
|
+
for you. A Web Store listing (one-click install + auto-updates) is planned.
|
|
48
51
|
|
|
49
52
|
### 3. Pair the extension with the daemon
|
|
50
53
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { createRequire } from "node:module";
|
|
|
10
10
|
|
|
11
11
|
const { version: VERSION } = createRequire(import.meta.url)("../package.json");
|
|
12
12
|
import { registerClaude, registerCursor, registerOpenCode, unregisterAgents } from "./agents.js";
|
|
13
|
-
import {
|
|
13
|
+
import { clearLine, cursorTo, emitKeypressEvents, moveCursor } from "node:readline";
|
|
14
14
|
|
|
15
15
|
// One-time pairing: the daemon prints a short code at startup; the extension
|
|
16
16
|
// exchanges it for the real token via POST /pair (loopback-only). This defends
|
|
@@ -21,37 +21,104 @@ const pairCode = Array.from(randomBytes(6))
|
|
|
21
21
|
.map((b) => PAIR_ALPHABET[b % PAIR_ALPHABET.length])
|
|
22
22
|
.join("");
|
|
23
23
|
|
|
24
|
-
// `taskwindow install` manages the login service and
|
|
25
|
-
//
|
|
24
|
+
// `taskwindow install` manages the login service and offers to register the
|
|
25
|
+
// MCP server with one or more coding agents. Component-only installs do not
|
|
26
|
+
// reopen the interactive picker.
|
|
26
27
|
const args = process.argv.slice(2);
|
|
27
28
|
const verb = args[0];
|
|
28
29
|
const flags = args.slice(1);
|
|
29
30
|
|
|
30
31
|
const AGENT_CHOICES = [
|
|
31
|
-
["
|
|
32
|
-
["
|
|
33
|
-
["
|
|
32
|
+
["Claude Code", registerClaude],
|
|
33
|
+
["Cursor", registerCursor],
|
|
34
|
+
["OpenCode", registerOpenCode],
|
|
34
35
|
];
|
|
35
36
|
|
|
37
|
+
function selectCodingAgents() {
|
|
38
|
+
const choices = [...AGENT_CHOICES.map(([label]) => label), "None (set up later)"];
|
|
39
|
+
const noneIndex = choices.length - 1;
|
|
40
|
+
const selected = new Set([noneIndex]);
|
|
41
|
+
let focused = 0;
|
|
42
|
+
let rendered = false;
|
|
43
|
+
|
|
44
|
+
emitKeypressEvents(process.stdin);
|
|
45
|
+
const wasRaw = process.stdin.isRaw;
|
|
46
|
+
const wasPaused = process.stdin.isPaused();
|
|
47
|
+
process.stdin.setRawMode(true);
|
|
48
|
+
process.stdin.resume();
|
|
49
|
+
|
|
50
|
+
const render = () => {
|
|
51
|
+
if (rendered) moveCursor(process.stdout, 0, -choices.length);
|
|
52
|
+
for (const [index, label] of choices.entries()) {
|
|
53
|
+
cursorTo(process.stdout, 0);
|
|
54
|
+
clearLine(process.stdout, 0);
|
|
55
|
+
const pointer = index === focused ? ">" : " ";
|
|
56
|
+
const checkbox = selected.has(index) ? "[x]" : "[ ]";
|
|
57
|
+
process.stdout.write(`${pointer} ${checkbox} ${label}\n`);
|
|
58
|
+
}
|
|
59
|
+
rendered = true;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
const finish = () => {
|
|
64
|
+
process.stdin.off("keypress", onKeypress);
|
|
65
|
+
process.stdin.setRawMode(wasRaw);
|
|
66
|
+
if (wasPaused) process.stdin.pause();
|
|
67
|
+
resolve([...selected].filter((index) => index !== noneIndex));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const onKeypress = (_character, key) => {
|
|
71
|
+
if (key?.ctrl && key.name === "c") {
|
|
72
|
+
process.stdin.setRawMode(wasRaw);
|
|
73
|
+
process.stdout.write("\n");
|
|
74
|
+
process.exit(130);
|
|
75
|
+
}
|
|
76
|
+
if (key?.name === "up") focused = (focused - 1 + choices.length) % choices.length;
|
|
77
|
+
else if (key?.name === "down") focused = (focused + 1) % choices.length;
|
|
78
|
+
else if (key?.name === "space") {
|
|
79
|
+
if (focused === noneIndex) {
|
|
80
|
+
selected.clear();
|
|
81
|
+
selected.add(noneIndex);
|
|
82
|
+
} else {
|
|
83
|
+
selected.delete(noneIndex);
|
|
84
|
+
if (selected.has(focused)) selected.delete(focused);
|
|
85
|
+
else selected.add(focused);
|
|
86
|
+
if (selected.size === 0) selected.add(noneIndex);
|
|
87
|
+
}
|
|
88
|
+
} else if (key?.name === "return" || key?.name === "enter") {
|
|
89
|
+
finish();
|
|
90
|
+
return;
|
|
91
|
+
} else {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
render();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
process.stdin.on("keypress", onKeypress);
|
|
98
|
+
render();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
36
102
|
async function pickAndRegisterAgents(config) {
|
|
37
103
|
if (!process.stdin.isTTY) {
|
|
38
104
|
console.log("[taskwindow] non-interactive session — register agents with: taskwindow install --claude|--cursor|--opencode");
|
|
39
105
|
return;
|
|
40
106
|
}
|
|
41
107
|
console.log("Which coding agents should use TaskWindow?");
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
108
|
+
console.log("Use ↑/↓ to move, space to select, and enter to confirm.");
|
|
109
|
+
const picks = await selectCodingAgents();
|
|
110
|
+
if (picks.length === 0) {
|
|
111
|
+
console.log("[taskwindow] skipped coding-agent setup — add one later with taskwindow install --claude|--cursor|--opencode");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
46
114
|
const registered = [];
|
|
47
|
-
for (const
|
|
48
|
-
const
|
|
49
|
-
if (!choice) continue;
|
|
115
|
+
for (const index of picks) {
|
|
116
|
+
const [label, register] = AGENT_CHOICES[index];
|
|
50
117
|
try {
|
|
51
|
-
await
|
|
52
|
-
registered.push(
|
|
118
|
+
await register(config);
|
|
119
|
+
registered.push(label);
|
|
53
120
|
} catch (err) {
|
|
54
|
-
console.error(`[taskwindow] ${
|
|
121
|
+
console.error(`[taskwindow] ${label} registration failed:`, err.message);
|
|
55
122
|
}
|
|
56
123
|
}
|
|
57
124
|
console.log(
|
|
@@ -61,28 +128,34 @@ async function pickAndRegisterAgents(config) {
|
|
|
61
128
|
);
|
|
62
129
|
}
|
|
63
130
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
131
|
+
try {
|
|
132
|
+
if (verb === "install") {
|
|
133
|
+
const config = loadConfig();
|
|
134
|
+
if (!flags.includes("--no-service")) {
|
|
135
|
+
installService(fileURLToPath(new URL("./index.js", import.meta.url)));
|
|
136
|
+
}
|
|
137
|
+
const extFlag = flags.indexOf("--extension");
|
|
138
|
+
if (extFlag !== -1) {
|
|
139
|
+
installExtension(flags[extFlag + 1] && !flags[extFlag + 1].startsWith("--") ? flags[extFlag + 1] : null);
|
|
140
|
+
}
|
|
141
|
+
if (flags.includes("--claude") || flags.includes("--cursor") || flags.includes("--opencode")) {
|
|
142
|
+
if (flags.includes("--claude")) registerClaude(config);
|
|
143
|
+
if (flags.includes("--cursor")) registerCursor(config);
|
|
144
|
+
if (flags.includes("--opencode")) registerOpenCode(config);
|
|
145
|
+
} else if (extFlag === -1) {
|
|
146
|
+
await pickAndRegisterAgents(config);
|
|
147
|
+
}
|
|
148
|
+
process.exit(0);
|
|
72
149
|
}
|
|
73
|
-
if (
|
|
74
|
-
if (flags.includes("--
|
|
75
|
-
if (flags.includes("--
|
|
76
|
-
|
|
77
|
-
} else {
|
|
78
|
-
await pickAndRegisterAgents(config);
|
|
150
|
+
if (verb === "uninstall") {
|
|
151
|
+
if (!flags.includes("--keep-agents")) unregisterAgents({ port: 9377 });
|
|
152
|
+
if (!flags.includes("--no-service")) uninstallService();
|
|
153
|
+
process.exit(0);
|
|
79
154
|
}
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if
|
|
83
|
-
|
|
84
|
-
if (!flags.includes("--no-service")) uninstallService();
|
|
85
|
-
process.exit(0);
|
|
155
|
+
} catch (err) {
|
|
156
|
+
console.error(`[taskwindow] ${verb || "install"} failed: ${err.message}`);
|
|
157
|
+
console.error(`[taskwindow] if the problem persists: taskwindow uninstall, then taskwindow install`);
|
|
158
|
+
process.exit(1);
|
|
86
159
|
}
|
|
87
160
|
|
|
88
161
|
const config = loadConfig();
|
package/src/service.js
CHANGED
|
@@ -20,6 +20,8 @@ export function installService(daemonEntryPath, port) {
|
|
|
20
20
|
mkdirSync(join(homedir(), ".taskwindow"), { recursive: true });
|
|
21
21
|
|
|
22
22
|
if (system === "darwin") {
|
|
23
|
+
const uid = process.getuid?.() ?? 501;
|
|
24
|
+
const labelTarget = `gui/${uid}/${LABEL}`;
|
|
23
25
|
const plistPath = join(homedir(), "Library", "LaunchAgents", `${LABEL}.plist`);
|
|
24
26
|
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
25
27
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
@@ -39,11 +41,33 @@ export function installService(daemonEntryPath, port) {
|
|
|
39
41
|
</plist>
|
|
40
42
|
`;
|
|
41
43
|
writeFileSync(plistPath, plist);
|
|
42
|
-
|
|
44
|
+
|
|
45
|
+
// Unload any previously loaded instance. launchd is asynchronous about
|
|
46
|
+
// bootout: bootstrap immediately after it fails with EIO, so wait until
|
|
47
|
+
// the label is really gone (up to 5s).
|
|
43
48
|
try {
|
|
44
|
-
execSync(`launchctl bootout
|
|
49
|
+
execSync(`launchctl bootout ${labelTarget} 2>/dev/null`);
|
|
45
50
|
} catch {}
|
|
46
|
-
|
|
51
|
+
const unloaded = () => {
|
|
52
|
+
try {
|
|
53
|
+
execSync(`launchctl print ${labelTarget}`, { stdio: "pipe" });
|
|
54
|
+
return false;
|
|
55
|
+
} catch {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const deadline = Date.now() + 5000;
|
|
60
|
+
while (!unloaded() && Date.now() < deadline) {
|
|
61
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, Date.now() + 300);
|
|
62
|
+
}
|
|
63
|
+
if (!unloaded()) {
|
|
64
|
+
throw new Error(`couldn't unload the previous service — run: launchctl bootout ${labelTarget}`);
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
execSync(`launchctl bootstrap gui/${uid} "${plistPath}"`, { stdio: "pipe" });
|
|
68
|
+
} catch (err) {
|
|
69
|
+
throw new Error(`launchctl bootstrap failed (${err.status ?? "?"}) — try: launchctl bootout ${labelTarget}, then re-run`);
|
|
70
|
+
}
|
|
47
71
|
console.log(`[taskwindow] login service installed (${plistPath})`);
|
|
48
72
|
console.log(`[taskwindow] daemon starts at login, restarts on crash, logs to ${logPath}`);
|
|
49
73
|
return;
|
|
@@ -82,7 +106,10 @@ WantedBy=default.target
|
|
|
82
106
|
* command does everything else.
|
|
83
107
|
*/
|
|
84
108
|
export function installExtension(zipPath) {
|
|
85
|
-
|
|
109
|
+
// This folder must remain visible in macOS's file picker: Chrome asks the
|
|
110
|
+
// user to select it after clicking "Load unpacked", and Finder hides paths
|
|
111
|
+
// whose names begin with a period by default.
|
|
112
|
+
const extDir = join(homedir(), "TaskWindow Extension");
|
|
86
113
|
const open = (u) => {
|
|
87
114
|
try {
|
|
88
115
|
execSync(`open -a "Google Chrome" "${u}"`);
|