claude-term-tabs 2.1.0 → 2.1.1

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
@@ -136,9 +136,10 @@ and modification time. Delete it any time.
136
136
  ## Development
137
137
 
138
138
  ```bash
139
- npm ci # installs the commit hooks (husky + commitlint)
140
- npm run check # type-check
139
+ npm ci # installs the commit hooks (husky + commitlint)
140
+ npm run check # type-check
141
141
  npm test
142
+ npm run test:package # packs, installs and runs the npm package
142
143
  ```
143
144
 
144
145
  No runtime dependencies; Node runs the TypeScript directly. [CONTRIBUTING.md](CONTRIBUTING.md) has the commit and
package/dist/cli.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { closeSync, openSync, readSync } from 'node:fs';
2
+ import { accessSync, closeSync, constants, openSync, readSync, statSync } from 'node:fs';
3
+ import { join } from 'node:path';
3
4
  import { isatty } from 'node:tty';
4
5
  import { parseFlags, SEARCH_FLAGS } from "./args.js";
5
6
  import { DigestCache } from "./cache.js";
@@ -244,6 +245,7 @@ export function realDeps(exec = realExec, installed = false) {
244
245
  sleep: ms => new Promise(resolve => setTimeout(resolve, ms)),
245
246
  self: [process.execPath, process.argv[1]],
246
247
  completionProgram: completionProgram(process.argv[1], installed),
248
+ completionWarning: program => completionWarning(program, process.env.PATH ?? '', isProgram),
247
249
  shell: process.env.SHELL
248
250
  };
249
251
  return deps;
@@ -256,6 +258,29 @@ export function realDeps(exec = realExec, installed = false) {
256
258
  export function completionProgram(argv1, installed) {
257
259
  return installed ? 'claude-term-tabs' : argv1;
258
260
  }
261
+ /**
262
+ * Why a completion script calling `program` won't work, if it won't. A clone's script calls its own path; an installed
263
+ * package's calls claude-term-tabs from PATH. npx (its cache) and a project's node_modules/.bin are on PATH only for
264
+ * this run, so they don't count: without a lasting copy, every Tab press would fail with "command not found".
265
+ */
266
+ export function completionWarning(program, path, isProgram) {
267
+ if (program.includes('/'))
268
+ return undefined;
269
+ const lasting = path.split(':').filter(d => d !== '' && !d.includes('/_npx/') && !/\/node_modules\/\.bin\/?$/.test(d));
270
+ if (lasting.some(d => isProgram(join(d, program))))
271
+ return undefined;
272
+ return "claude-term-tabs: it isn't on your PATH outside this run, so Tab completion won't work until you run: npm install --global claude-term-tabs";
273
+ }
274
+ /** True for an executable file. */
275
+ function isProgram(p) {
276
+ try {
277
+ accessSync(p, constants.X_OK);
278
+ return statSync(p).isFile();
279
+ }
280
+ catch {
281
+ return false;
282
+ }
283
+ }
259
284
  /** Entry point used by bin/claude-term-tabs, which says whether it runs the installed package. */
260
285
  export async function main(argv, { installed = false } = {}) {
261
286
  const deps = realDeps(realExec, installed);
package/dist/commands.js CHANGED
@@ -102,6 +102,9 @@ function completion(argv, deps) {
102
102
  throw new Error(`unknown shell "${shell}"${where} (supported: ${SHELLS.join(', ')}); run ${SHELLS.map(s => `ctt completion ${s}`).join(' or ')}`);
103
103
  }
104
104
  deps.stdout(completionScript(shell, deps.completionProgram));
105
+ const warning = deps.completionWarning(deps.completionProgram);
106
+ if (warning !== undefined)
107
+ deps.stderr(warning);
105
108
  return EXIT_OK;
106
109
  }
107
110
  function focus(argv, deps) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-term-tabs",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Find a running Claude Code session by what you remember, and jump to its terminal tab",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,8 @@
38
38
  "check": "tsc",
39
39
  "prepare": "husky",
40
40
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
41
- "prepack": "npm run build"
41
+ "prepack": "npm run build",
42
+ "test:package": "CTT_NO_REAL_EXEC=1 node --test 'tests/**/*.pack.ts'"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@commitlint/cli": "21.2.4",