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 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 printed folder). Chrome's own policy requires
46
- those clicks — no tool can do them for you. A Web Store listing (one-click
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taskwindow",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "TaskWindow local daemon: bridges the TaskWindow Chrome extension to any MCP client over Streamable HTTP",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
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 { createInterface } from "node:readline";
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 — only with an explicit
25
- // per-agent flag — registers the MCP server in that agent.
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
- ["1", "Claude Code", registerClaude],
32
- ["2", "Cursor", registerCursor],
33
- ["3", "OpenCode", registerOpenCode],
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
- for (const [num, label] of AGENT_CHOICES) console.log(` ${num}. ${label}`);
43
- const rl = createInterface({ input: process.stdin, output: process.stdout });
44
- const answer = await new Promise((resolve) => rl.question("Enter numbers separated by commas (empty to skip): ", resolve));
45
- rl.close();
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 pick of answer.split(",").map((x) => x.trim()).filter(Boolean)) {
48
- const choice = AGENT_CHOICES.find(([num]) => num === pick);
49
- if (!choice) continue;
115
+ for (const index of picks) {
116
+ const [label, register] = AGENT_CHOICES[index];
50
117
  try {
51
- await choice[2](config);
52
- registered.push(choice[1]);
118
+ await register(config);
119
+ registered.push(label);
53
120
  } catch (err) {
54
- console.error(`[taskwindow] ${choice[1]} registration failed:`, err.message);
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
- if (verb === "install") {
65
- const config = loadConfig();
66
- if (!flags.includes("--no-service")) {
67
- installService(fileURLToPath(new URL("./index.js", import.meta.url)));
68
- }
69
- const extFlag = flags.indexOf("--extension");
70
- if (extFlag !== -1) {
71
- installExtension(flags[extFlag + 1] && !flags[extFlag + 1].startsWith("--") ? flags[extFlag + 1] : null);
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 (flags.includes("--claude") || flags.includes("--cursor") || flags.includes("--opencode")) {
74
- if (flags.includes("--claude")) registerClaude(config);
75
- if (flags.includes("--cursor")) registerCursor(config);
76
- if (flags.includes("--opencode")) registerOpenCode(config);
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
- process.exit(0);
81
- }
82
- if (verb === "uninstall") {
83
- if (!flags.includes("--keep-agents")) unregisterAgents({ port: 9377 });
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
- const uid = process.getuid?.() ?? 501;
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 gui/${uid}/${LABEL} 2>/dev/null`, { shell: "/bin/bash" });
49
+ execSync(`launchctl bootout ${labelTarget} 2>/dev/null`);
45
50
  } catch {}
46
- execSync(`launchctl bootstrap gui/${uid} "${plistPath}"`);
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
- const extDir = join(homedir(), ".taskwindow", "extension");
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}"`);