tabctl 0.5.0 → 0.5.3

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
@@ -1,16 +1,66 @@
1
1
  # tabctl
2
2
 
3
- `tabctl` is a command-line tool that gives you terminal control over your browser tabs. List, search, group, move, close, deduplicate, inspect, and report on tabs without leaving your terminal — across Chrome and Edge.
3
+ Every open tab is a thread you forgot to pull. Tabctl finds them all.
4
4
 
5
- It works through a lightweight local stack: the CLI talks to a native messaging host, which proxies requests to a browser extension. A policy file can protect pinned tabs or specific groups from automated actions, and every mutation is undoable.
5
+ A command-line instrument for browser tab orchestration list, search, group, archive, close, undo wired into Edge or Chrome through a native messaging bridge. Built for humans who hoard tabs and the AI agents who clean up after them.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g tabctl
11
+ tabctl setup --browser chrome
12
+ # Load the extension: chrome://extensions → Developer mode → Load unpacked → paste: ~/.local/state/tabctl/extension/
13
+ tabctl ping
14
+ ```
15
+
16
+ If it pings back, the wire is live. You're connected.
17
+
18
+ ## Agent Skill
19
+
20
+ Give your coding agent eyes into the browser. One command and it learns the protocol.
21
+
22
+ ```bash
23
+ tabctl skill
24
+ # or: npx skills add https://github.com/ekroon/tabctl --skill tabctl -a opencode -a github-copilot -a claude-code
25
+ ```
26
+
27
+ ## Safety
28
+
29
+ Nothing leaves your machine. No cloud. No telemetry. Just a socket between your terminal and your browser, quiet as rain on neon.
30
+
31
+ Every mutation is undoable — `tabctl undo` rewinds closes, archives, and group changes like they never happened. A configurable policy layer shields pinned tabs and protected domains from accidental destruction. You pull the trigger; tabctl keeps the safety on until you mean it.
32
+
33
+ ## What You Can Say
34
+
35
+ When tabctl is installed as a skill, your agent sees what you see. Just talk to it.
36
+
37
+ > *"Which of my tabs can I close?"*
38
+ > The agent scans for duplicates, stale pages, and tabs you haven't touched in days — then offers to clean house.
39
+
40
+ > *"Are any of my open tabs relevant to my note on Project Helios?"*
41
+ > When connected to Obsidian, your agent cross-references every open tab against your notes and surfaces the ones that matter.
42
+
43
+ > *"I just finished researching service mesh architectures. Organize what I found."*
44
+ > Groups your tabs by theme, extracts key URLs, and drops a summary into your notes — before you forget what you were looking at.
45
+
46
+ > *"Where's that AWS pricing page I had open somewhere?"*
47
+ > The agent searches your open tabs and groups by title and URL — and brings it back into focus.
48
+
49
+ > *"Pull every error message from my open Sentry tabs into a markdown table."*
50
+ > The agent reads each tab, extracts what you need, and formats it — no copy-paste, no context switching.
51
+
52
+ > *"Group everything by project. You know which ones."*
53
+ > Your agent infers context from URLs, titles, and your workspace — then sorts ninety tabs into five groups with names that actually make sense.
54
+
55
+ ---
56
+
57
+ `tabctl` works through a lightweight local stack: the CLI talks to a native messaging host, which proxies requests to a browser extension. The host only runs while the browser is open and the extension is connected.
6
58
 
7
59
  This repo contains:
8
60
  - Chrome/Edge extension (tab/group inspection + actions)
9
61
  - Native messaging host (Node)
10
62
  - CLI (`tabctl`) for on-demand workflows
11
63
 
12
- The host only runs while the browser is open and the extension is connected.
13
-
14
64
  ## Quick Start
15
65
 
16
66
  ### 1. Build and install
@@ -78,7 +78,7 @@ function resolveNodePath(options) {
78
78
  function resolveHostPath(dataDir) {
79
79
  // Sync host bundle to stable path so wrapper survives npm upgrades
80
80
  try {
81
- const result = (0, extension_sync_1.syncHost)(dataDir);
81
+ const result = (0, extension_sync_1.syncHost)(dataDir, { force: true });
82
82
  return result.hostPath;
83
83
  }
84
84
  catch (err) {
@@ -181,7 +181,7 @@ function runSetup(options, prettyOutput) {
181
181
  const hostPath = resolveHostPath(config.baseDataDir);
182
182
  let extensionSync;
183
183
  try {
184
- extensionSync = (0, extension_sync_1.syncExtension)(config.baseDataDir);
184
+ extensionSync = (0, extension_sync_1.syncExtension)(config.baseDataDir, { force: true });
185
185
  }
186
186
  catch {
187
187
  extensionSync = null;
@@ -275,9 +275,20 @@ function runSetup(options, prettyOutput) {
275
275
  "",
276
276
  ].join("\n"));
277
277
  }
278
+ const extensionsUrl = browser === "edge" ? "edge://extensions" : "chrome://extensions";
279
+ const browserName = browser === "edge" ? "Edge" : "Chrome";
280
+ const extensionDir = extensionSync?.extensionDir || null;
281
+ const loadSteps = extensionDir
282
+ ? [
283
+ `Load the extension: ${extensionsUrl} → Developer mode → Load unpacked`,
284
+ ` Path: ${extensionDir}`,
285
+ process.platform === "darwin" ? " Tip: press Cmd+Shift+G in the file dialog to paste the path" : null,
286
+ ].filter(Boolean).join("\n")
287
+ : `Load the extension: ${extensionsUrl} → Developer mode → Load unpacked`;
278
288
  process.stderr.write([
289
+ loadSteps,
279
290
  `Verify connection: tabctl --profile ${profileName} ping`,
280
- `If ping fails, ensure the ${browser === "edge" ? "Edge" : "Chrome"} extension is active.`,
291
+ `If ping fails, ensure the ${browserName} extension is active.`,
281
292
  "",
282
293
  ].join("\n"));
283
294
  }
@@ -65,34 +65,42 @@ function setupStdoutErrorHandling() {
65
65
  }
66
66
  function emitVersionWarnings(response, fallbackAction) {
67
67
  const hostVersion = typeof response.version === "string" ? response.version : null;
68
- // CLI host version mismatch: auto-upgrade (sync files + trigger reload)
69
- if (hostVersion && hostVersion !== version_1.VERSION) {
70
- try {
71
- const config = (0, config_1.resolveConfig)();
72
- const hostResult = (0, extension_sync_1.syncHost)(config.baseDataDir);
73
- const extResult = (0, extension_sync_1.syncExtension)(config.baseDataDir);
74
- const anySynced = hostResult.synced || extResult.synced;
75
- // Send reload if we synced new files OR if the running host is stale
76
- if (anySynced) {
77
- process.stderr.write(`[tabctl] upgraded: ${hostVersion} ${version_1.BASE_VERSION}. Reloading extension...\n`);
78
- }
79
- else {
80
- process.stderr.write(`[tabctl] host is stale (${hostVersion}), reloading extension...\n`);
81
- }
82
- (0, client_1.sendFireAndForget)({ id: (0, client_2.createRequestId)(), action: "reload", params: {} });
83
- // Check and fix wrapper Node path for the active profile
68
+ const data = response.data;
69
+ const hostBaseVersion = data && typeof data.hostBaseVersion === "string" ? data.hostBaseVersion : null;
70
+ const isDevCli = version_1.DEV_BUILD;
71
+ // CLI host BASE_VERSION mismatch: auto-upgrade (sync files + trigger reload).
72
+ // Dev builds never sync — they use whatever host is already installed.
73
+ const effectiveHostBase = hostBaseVersion ?? hostVersion;
74
+ if (effectiveHostBase && effectiveHostBase !== version_1.BASE_VERSION && !isDevCli) {
75
+ // Downgrade: host is newer than CLI warn but don't sync/reload
76
+ if ((0, extension_sync_1.compareBaseVersions)(version_1.BASE_VERSION, effectiveHostBase) < 0) {
77
+ process.stderr.write(`[tabctl] cli (${version_1.BASE_VERSION}) is older than host (${effectiveHostBase}). Consider upgrading: npm install -g tabctl\n`);
78
+ }
79
+ else {
84
80
  try {
85
- repairActiveWrapper(config.baseDataDir);
81
+ const config = (0, config_1.resolveConfig)();
82
+ const hostResult = (0, extension_sync_1.syncHost)(config.baseDataDir);
83
+ const extResult = (0, extension_sync_1.syncExtension)(config.baseDataDir);
84
+ const anySynced = hostResult.synced || extResult.synced;
85
+ if (anySynced) {
86
+ process.stderr.write(`[tabctl] upgraded: ${effectiveHostBase} → ${version_1.BASE_VERSION}. Reloading extension...\n`);
87
+ }
88
+ else {
89
+ process.stderr.write(`[tabctl] host is stale (${effectiveHostBase}), reloading extension...\n`);
90
+ }
91
+ (0, client_1.sendFireAndForget)({ id: (0, client_2.createRequestId)(), action: "reload", params: {} });
92
+ try {
93
+ repairActiveWrapper(config.baseDataDir);
94
+ }
95
+ catch {
96
+ // Wrapper repair is best-effort
97
+ }
86
98
  }
87
99
  catch {
88
- // Wrapper repair is best-effort
100
+ process.stderr.write(`[tabctl] version mismatch: cli ${version_1.BASE_VERSION}, host ${effectiveHostBase}. Run: tabctl setup\n`);
89
101
  }
90
102
  }
91
- catch {
92
- process.stderr.write(`[tabctl] version mismatch: cli ${version_1.VERSION}, host ${hostVersion}. Run: tabctl setup\n`);
93
- }
94
103
  }
95
- const data = response.data;
96
104
  const extensionVersion = data && typeof data.extensionVersion === "string" ? data.extensionVersion : null;
97
105
  const extensionComponent = data && typeof data.extensionComponent === "string" ? data.extensionComponent : null;
98
106
  if (extensionVersion && hostVersion && extensionVersion !== hostVersion) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Tab Control",
4
- "version": "0.5.0",
4
+ "version": "0.5.3",
5
5
  "description": "Archive and manage browser tabs with CLI support",
6
6
  "permissions": [
7
7
  "tabs",
@@ -19,5 +19,5 @@
19
19
  "background": {
20
20
  "service_worker": "background.js"
21
21
  },
22
- "version_name": "0.5.0"
22
+ "version_name": "0.5.3"
23
23
  }
@@ -128,11 +128,12 @@ var require_version = __commonJS({
128
128
  "dist/shared/version.js"(exports2) {
129
129
  "use strict";
130
130
  Object.defineProperty(exports2, "__esModule", { value: true });
131
- exports2.DIRTY = exports2.GIT_SHA = exports2.VERSION = exports2.BASE_VERSION = void 0;
132
- exports2.BASE_VERSION = "0.5.0";
133
- exports2.VERSION = "0.5.0";
134
- exports2.GIT_SHA = null;
131
+ exports2.DEV_BUILD = exports2.DIRTY = exports2.GIT_SHA = exports2.VERSION = exports2.BASE_VERSION = void 0;
132
+ exports2.BASE_VERSION = "0.5.3";
133
+ exports2.VERSION = "0.5.3";
134
+ exports2.GIT_SHA = "7d279446";
135
135
  exports2.DIRTY = false;
136
+ exports2.DEV_BUILD = false;
136
137
  }
137
138
  });
138
139
 
@@ -11,6 +11,8 @@ exports.resolveInstalledExtensionDir = resolveInstalledExtensionDir;
11
11
  exports.resolveInstalledHostPath = resolveInstalledHostPath;
12
12
  exports.readExtensionVersion = readExtensionVersion;
13
13
  exports.readHostVersion = readHostVersion;
14
+ exports.compareBaseVersions = compareBaseVersions;
15
+ exports.isDevBuild = isDevBuild;
14
16
  exports.syncExtension = syncExtension;
15
17
  exports.syncHost = syncHost;
16
18
  exports.checkExtensionSync = checkExtensionSync;
@@ -18,6 +20,7 @@ const node_path_1 = __importDefault(require("node:path"));
18
20
  const node_fs_1 = __importDefault(require("node:fs"));
19
21
  const node_crypto_1 = __importDefault(require("node:crypto"));
20
22
  const config_1 = require("./config");
23
+ const version_1 = require("./version");
21
24
  exports.EXTENSION_DIR_NAME = "extension";
22
25
  exports.HOST_BUNDLE_NAME = "host.bundle.js";
23
26
  /**
@@ -72,11 +75,44 @@ function readHostVersion(hostPath) {
72
75
  return null;
73
76
  }
74
77
  }
75
- function syncExtension(dataDir) {
78
+ /**
79
+ * Compare two semver versions by their base (major.minor.patch) components.
80
+ * Strips any prerelease/build metadata before comparing.
81
+ * Returns -1 if a < b, 0 if equal, 1 if a > b.
82
+ */
83
+ function compareBaseVersions(a, b) {
84
+ const strip = (v) => v.replace(/[-+].*$/, "");
85
+ const pa = strip(a).split(".").map(Number);
86
+ const pb = strip(b).split(".").map(Number);
87
+ for (let i = 0; i < 3; i++) {
88
+ const va = pa[i] ?? 0;
89
+ const vb = pb[i] ?? 0;
90
+ if (va < vb)
91
+ return -1;
92
+ if (va > vb)
93
+ return 1;
94
+ }
95
+ return 0;
96
+ }
97
+ /** Returns true when the current CLI is a dev build. */
98
+ function isDevBuild() {
99
+ return version_1.DEV_BUILD;
100
+ }
101
+ function syncExtension(dataDir, options) {
76
102
  const bundledDir = resolveBundledExtensionDir();
77
103
  const installedDir = resolveInstalledExtensionDir(dataDir);
78
104
  const bundledVersion = readExtensionVersion(bundledDir);
79
105
  const installedVersion = readExtensionVersion(installedDir);
106
+ if (!options?.force) {
107
+ // Dev builds never overwrite installed files
108
+ if (isDevBuild()) {
109
+ return { synced: false, bundledVersion, installedVersion, extensionDir: installedDir };
110
+ }
111
+ // Downgrade protection: don't replace a newer installed version
112
+ if (bundledVersion && installedVersion && compareBaseVersions(bundledVersion, installedVersion) < 0) {
113
+ return { synced: false, bundledVersion, installedVersion, extensionDir: installedDir };
114
+ }
115
+ }
80
116
  const needsCopy = !node_fs_1.default.existsSync(installedDir) || bundledVersion !== installedVersion;
81
117
  if (needsCopy) {
82
118
  node_fs_1.default.mkdirSync(installedDir, { recursive: true });
@@ -89,11 +125,21 @@ function syncExtension(dataDir) {
89
125
  extensionDir: installedDir,
90
126
  };
91
127
  }
92
- function syncHost(dataDir) {
128
+ function syncHost(dataDir, options) {
93
129
  const bundledPath = resolveBundledHostPath();
94
130
  const installedPath = resolveInstalledHostPath(dataDir);
95
131
  const bundledVersion = readHostVersion(bundledPath);
96
132
  const installedVersion = readHostVersion(installedPath);
133
+ if (!options?.force) {
134
+ // Dev builds never overwrite installed files
135
+ if (isDevBuild()) {
136
+ return { synced: false, bundledVersion, installedVersion, hostPath: installedPath };
137
+ }
138
+ // Downgrade protection: don't replace a newer installed version
139
+ if (bundledVersion && installedVersion && compareBaseVersions(bundledVersion, installedVersion) < 0) {
140
+ return { synced: false, bundledVersion, installedVersion, hostPath: installedPath };
141
+ }
142
+ }
97
143
  const needsCopy = !node_fs_1.default.existsSync(installedPath) || bundledVersion !== installedVersion;
98
144
  if (needsCopy) {
99
145
  node_fs_1.default.mkdirSync(node_path_1.default.dirname(installedPath), { recursive: true });
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DIRTY = exports.GIT_SHA = exports.VERSION = exports.BASE_VERSION = void 0;
4
- exports.BASE_VERSION = "0.5.0";
5
- exports.VERSION = "0.5.0";
6
- exports.GIT_SHA = null;
3
+ exports.DEV_BUILD = exports.DIRTY = exports.GIT_SHA = exports.VERSION = exports.BASE_VERSION = void 0;
4
+ exports.BASE_VERSION = "0.5.3";
5
+ exports.VERSION = "0.5.3";
6
+ exports.GIT_SHA = "7d279446";
7
7
  exports.DIRTY = false;
8
+ exports.DEV_BUILD = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tabctl",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "description": "CLI tool to manage and analyze browser tabs",
5
5
  "license": "MIT",
6
6
  "repository": {