turno-cli 0.5.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # turno-cli
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - cd53ee9: - `turno --help | head` and `turno-browser --help | head` end quietly instead of printing an
8
+ EPIPE stack trace when the reader stops early.
9
+ - Bash completion works on the bash 3.2 macOS ships: each word reaches turno on its own, and
10
+ the script loads with `eval "$(turno completion bash)"`, since bash 3.2 cannot source `<(...)`.
11
+ - `turno mcp daemon run` stops by itself when its home folder is removed (a throwaway HOME
12
+ someone deleted), instead of running on with nothing left to serve.
13
+ - Updated dependencies [cd53ee9]
14
+ - Updated dependencies [cd53ee9]
15
+ - turno-core@0.3.0
16
+
3
17
  ## 0.5.0
4
18
 
5
19
  ### Minor Changes
@@ -1,41 +1,7 @@
1
+ import { completionScripts } from "turno-core/cli";
1
2
  import { parseFlags } from "../args.js";
2
3
  import { fail } from "../io.js";
3
- const ZSH = `#compdef turno
4
- # turno completion for zsh. Load it with: source <(turno completion zsh)
5
- _turno() {
6
- local -a out
7
- out=("\${(@f)$(turno __complete -- "\${(@)words[2,CURRENT]}" 2>/dev/null)}")
8
- if [[ "\${out[1]}" == ":dir" ]]; then _files -/; return; fi
9
- (( \${#out} )) && [[ -n "\${out[1]}" ]] && compadd -- "\${out[@]}"
10
- }
11
- compdef _turno turno
12
- `;
13
- const BASH = `# turno completion for bash. Load it with: source <(turno completion bash)
14
- _turno() {
15
- local IFS=$'\\n'
16
- local out=($(turno __complete -- "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
17
- if [[ "\${out[0]}" == ":dir" ]]; then
18
- COMPREPLY=($(compgen -d -- "\${COMP_WORDS[COMP_CWORD]}"))
19
- return
20
- fi
21
- COMPREPLY=("\${out[@]}")
22
- }
23
- complete -o default -F _turno turno
24
- `;
25
- const FISH = `# turno completion for fish. Load it with: turno completion fish | source
26
- function __turno_complete
27
- set -l words (commandline -opc) (commandline -ct)
28
- set -e words[1]
29
- set -l out (turno __complete -- $words 2>/dev/null)
30
- if test "$out[1]" = ":dir"
31
- __fish_complete_directories (commandline -ct)
32
- return
33
- end
34
- printf '%s\\n' $out
35
- end
36
- complete -c turno -f -a '(__turno_complete)'
37
- `;
38
- export const SCRIPTS = { zsh: ZSH, bash: BASH, fish: FISH };
4
+ export const SCRIPTS = completionScripts("turno");
39
5
  export const command = {
40
6
  summary: "shell completion for commands, profiles, identities and config keys",
41
7
  usage: [
@@ -43,7 +9,7 @@ export const command = {
43
9
  "",
44
10
  "Prints the completion script. To load it in every shell:",
45
11
  " zsh echo 'source <(turno completion zsh)' >> ~/.zshrc",
46
- " bash echo 'source <(turno completion bash)' >> ~/.bashrc",
12
+ " bash echo 'eval \"$(turno completion bash)\"' >> ~/.bashrc",
47
13
  " fish turno completion fish > ~/.config/fish/completions/turno.fish",
48
14
  "",
49
15
  "Examples:",
@@ -192,19 +192,27 @@ async function runDaemon(args, io) {
192
192
  let waiting = false;
193
193
  for (;;) {
194
194
  try {
195
+ let homeGone;
195
196
  const d = await startDaemon({
196
197
  env: io.env,
197
198
  logToStdout: Boolean(process.stdout.isTTY) && !service,
198
199
  ...(port !== undefined ? { port } : {}),
200
+ onHomeGone: () => homeGone?.(),
199
201
  });
200
202
  io.err(`mcpd listening on 127.0.0.1:${d.port}`);
201
203
  const unguard = installCrashGuards(d.log, () => d.stop());
202
204
  await new Promise((resolve) => {
203
205
  const stop = () => {
206
+ process.off("SIGINT", stop);
207
+ process.off("SIGTERM", stop);
204
208
  void d.stop().then(resolve, resolve);
205
209
  };
206
210
  process.once("SIGINT", stop);
207
211
  process.once("SIGTERM", stop);
212
+ homeGone = () => {
213
+ io.err("turno: mcpd stopped: its home folder was removed");
214
+ stop();
215
+ };
208
216
  });
209
217
  unguard();
210
218
  return 0;
@@ -479,6 +479,18 @@ export async function startDaemon(opts = {}) {
479
479
  void sampler.sample(manager.list().map((i) => ({ descKey: i.descKey, pid: i.upstream.pid })));
480
480
  }, 15_000);
481
481
  timer.unref();
482
+ let homeTimer;
483
+ const onHomeGone = opts.onHomeGone;
484
+ if (onHomeGone) {
485
+ homeTimer = setInterval(() => {
486
+ if (existsSync(p.home))
487
+ return;
488
+ clearInterval(homeTimer);
489
+ log(`the home folder ${p.home} was removed; stopping`);
490
+ onHomeGone();
491
+ }, opts.homeCheckMs ?? 15_000);
492
+ homeTimer.unref();
493
+ }
482
494
  // /status shows the pressure from the start instead of after the first reap.
483
495
  void manager.readPressure().catch(() => { });
484
496
  let stopped = false;
@@ -492,6 +504,7 @@ export async function startDaemon(opts = {}) {
492
504
  return;
493
505
  stopped = true;
494
506
  clearInterval(timer);
507
+ clearInterval(homeTimer);
495
508
  clearTimeout(debounce);
496
509
  clearTimeout(configDebounce);
497
510
  watcher?.close();
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "turno-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "turno-cli",
9
- "version": "0.5.0",
9
+ "version": "0.5.1",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "1.32.2",
13
13
  "smol-toml": "1.9.1",
14
- "turno-core": "0.2.0"
14
+ "turno-core": "0.3.0"
15
15
  },
16
16
  "bin": {
17
17
  "turno": "dist/cli/main.js"
@@ -1014,8 +1014,8 @@
1014
1014
  }
1015
1015
  },
1016
1016
  "node_modules/turno-core": {
1017
- "version": "0.2.0",
1018
- "resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.2.0.tgz",
1017
+ "version": "0.3.0",
1018
+ "resolved": "https://registry.npmjs.org/turno-core/-/turno-core-0.3.0.tgz",
1019
1019
  "license": "Apache-2.0",
1020
1020
  "engines": {
1021
1021
  "node": ">=22.11"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turno-cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Switch accounts in your coding agents and keep the conversation, the MCP sign-ins and the browser session.",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -47,11 +47,11 @@
47
47
  "dependencies": {
48
48
  "@modelcontextprotocol/sdk": "1.32.2",
49
49
  "smol-toml": "1.9.1",
50
- "turno-core": "0.2.0"
50
+ "turno-core": "0.3.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "^26.6.6",
54
- "turno-browser": "0.5.0",
54
+ "turno-browser": "0.6.0",
55
55
  "turno-fonts": "0.1.2",
56
56
  "typescript": "^7.0.2",
57
57
  "vitest": "^5.1.0"