turno-cli 0.1.0 → 0.2.0

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.
Files changed (105) hide show
  1. package/CHANGELOG.md +293 -0
  2. package/README.md +143 -75
  3. package/dist/accounts/audit.js +137 -7
  4. package/dist/accounts/builtin.js +68 -21
  5. package/dist/accounts/delegate.js +176 -35
  6. package/dist/accounts/policy.js +77 -0
  7. package/dist/accounts/registry.js +37 -21
  8. package/dist/agents/adapter.js +7 -0
  9. package/dist/agents/claude.js +195 -0
  10. package/dist/agents/codex.js +98 -0
  11. package/dist/agents/copilot.js +39 -0
  12. package/dist/agents/cursor.js +41 -0
  13. package/dist/agents/index.js +26 -86
  14. package/dist/agents/snippets.js +7 -4
  15. package/dist/cli/args.js +19 -4
  16. package/dist/cli/commands/accounts.js +96 -51
  17. package/dist/cli/commands/auto.js +82 -32
  18. package/dist/cli/commands/browser.js +216 -135
  19. package/dist/cli/commands/complete.js +2 -1
  20. package/dist/cli/commands/completion.js +4 -2
  21. package/dist/cli/commands/config.js +103 -18
  22. package/dist/cli/commands/demo.js +292 -0
  23. package/dist/cli/commands/doctor.js +387 -119
  24. package/dist/cli/commands/handoff.js +33 -22
  25. package/dist/cli/commands/identity.js +101 -50
  26. package/dist/cli/commands/init.js +616 -0
  27. package/dist/cli/commands/limit.js +25 -13
  28. package/dist/cli/commands/mcp-oauth.js +194 -0
  29. package/dist/cli/commands/mcp-observe.js +434 -0
  30. package/dist/cli/commands/mcp.js +653 -185
  31. package/dist/cli/commands/mcpd.js +323 -75
  32. package/dist/cli/commands/migrate.js +6 -4
  33. package/dist/cli/commands/open.js +92 -27
  34. package/dist/cli/commands/profile.js +205 -69
  35. package/dist/cli/commands/resolve.js +6 -2
  36. package/dist/cli/commands/run.js +15 -5
  37. package/dist/cli/commands/secret.js +61 -42
  38. package/dist/cli/commands/session.js +2 -2
  39. package/dist/cli/commands/sessions.js +42 -12
  40. package/dist/cli/commands/setup.js +136 -158
  41. package/dist/cli/commands/status.js +172 -41
  42. package/dist/cli/commands/statusline.js +305 -113
  43. package/dist/cli/commands/ui.js +64 -66
  44. package/dist/cli/commands/undo.js +161 -18
  45. package/dist/cli/commands/uninstall.js +462 -0
  46. package/dist/cli/commands/upgrade.js +75 -19
  47. package/dist/cli/commands/usage.js +117 -44
  48. package/dist/cli/commands/version.js +7 -5
  49. package/dist/cli/commands/which.js +7 -24
  50. package/dist/cli/compile-cache.js +32 -0
  51. package/dist/cli/group.js +10 -10
  52. package/dist/cli/help.js +57 -0
  53. package/dist/cli/highlight.js +236 -0
  54. package/dist/cli/io.js +170 -1
  55. package/dist/cli/launch.js +21 -37
  56. package/dist/cli/launchers.js +145 -94
  57. package/dist/cli/main.js +163 -27
  58. package/dist/cli/picker.js +447 -0
  59. package/dist/cli/registry.js +42 -5
  60. package/dist/cli/security.js +539 -0
  61. package/dist/cli/style.js +281 -0
  62. package/dist/core/config.js +145 -23
  63. package/dist/core/exhausted.js +6 -8
  64. package/dist/core/fsutil.js +47 -0
  65. package/dist/core/journal.js +281 -11
  66. package/dist/core/manifest.js +126 -6
  67. package/dist/core/paths.js +114 -7
  68. package/dist/core/profiles.js +139 -9
  69. package/dist/core/resolve.js +129 -23
  70. package/dist/core/secrets.js +215 -20
  71. package/dist/core/sessions.js +13 -20
  72. package/dist/core/update.js +18 -8
  73. package/dist/core/version.js +6 -0
  74. package/dist/demo/server.js +34 -0
  75. package/dist/mcpd/cache.js +18 -4
  76. package/dist/mcpd/calllog.js +253 -0
  77. package/dist/mcpd/client-names.js +51 -0
  78. package/dist/mcpd/connectors.js +148 -17
  79. package/dist/mcpd/daemon.js +452 -116
  80. package/dist/mcpd/folder-sets.js +39 -0
  81. package/dist/mcpd/gateway.js +441 -47
  82. package/dist/mcpd/health.js +269 -0
  83. package/dist/mcpd/importer.js +356 -36
  84. package/dist/mcpd/instances.js +425 -65
  85. package/dist/mcpd/jsonrpc.js +8 -0
  86. package/dist/mcpd/launchd.js +65 -48
  87. package/dist/mcpd/modern.js +648 -0
  88. package/dist/mcpd/oauth.js +791 -0
  89. package/dist/mcpd/peerpid.js +122 -6
  90. package/dist/mcpd/pressure.js +85 -0
  91. package/dist/mcpd/rss.js +151 -0
  92. package/dist/mcpd/service.js +167 -0
  93. package/dist/mcpd/state.js +183 -0
  94. package/dist/mcpd/sync.js +55 -80
  95. package/dist/mcpd/systemd.js +80 -0
  96. package/dist/mcpd/tokens.js +89 -0
  97. package/dist/mcpd/upstream.js +154 -44
  98. package/dist/statusline/cost.js +154 -44
  99. package/dist/statusline/input.js +66 -0
  100. package/dist/statusline/render.js +9 -3
  101. package/dist/ui/fonts.js +8 -3
  102. package/dist/ui/settings.js +27 -15
  103. package/npm-shrinkwrap.json +1093 -0
  104. package/package.json +9 -9
  105. package/dist/cli/commands/available.js +0 -18
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Two-row status line for Claude Code. Pure rendering: everything it shows comes in through
3
3
  * RenderInput, which `collect()` in ../cli/commands/statusline.ts fills from disk and git.
4
+ * It expects data already checked by `sanitize()` in ./input.ts: every field has its type.
4
5
  *
5
6
  * 1. account: profile and plan, 5 h and weekly usage of THAT account, context, cache,
6
7
  * turns left, and a warning when a fallback or the wrong account is in use
@@ -66,7 +67,7 @@ export const NERD = {
66
67
  left: cp(0xe0b6),
67
68
  right: cp(0xe0b4),
68
69
  };
69
- export const UNICODE = {
70
+ const UNICODE = {
70
71
  acct: "◉",
71
72
  h5: "⧗",
72
73
  d7: "▦",
@@ -89,7 +90,7 @@ export const UNICODE = {
89
90
  left: "",
90
91
  right: "",
91
92
  };
92
- export function fg(n, text, bold = false) {
93
+ function fg(n, text, bold = false) {
93
94
  return text ? `\x1b[${bold ? "1;" : ""}38;5;${n}m${text}\x1b[0m` : "";
94
95
  }
95
96
  export function tokens(n) {
@@ -221,9 +222,14 @@ export function render(i) {
221
222
  seg += fg(MUTED, ` (sub $${Math.round(i.cost.sub).toLocaleString("en-US")})`);
222
223
  row2.push(seg);
223
224
  }
224
- else if (c.total_cost_usd !== undefined && c.total_cost_usd !== null) {
225
+ else if (i.costUnknown) {
226
+ row2.push(ic("cost", COST) + fg(COST, "$?", true));
227
+ }
228
+ else if (typeof c.total_cost_usd === "number" && Number.isFinite(c.total_cost_usd)) {
225
229
  row2.push(ic("cost", COST) + fg(COST, `$${c.total_cost_usd.toFixed(2)}`) + fg(MUTED, "…"));
226
230
  }
231
+ if (i.gatewayDown)
232
+ row2.push(ic("ban", BAD) + fg(BAD, "mcpd down"));
227
233
  return `${row1.join(div)}\n${row2.join(div)}\n`;
228
234
  }
229
235
  /** Turns left in the 5 h window, from how much the percentage rose over this session's last turns. */
package/dist/ui/fonts.js CHANGED
@@ -4,7 +4,10 @@ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "
4
4
  import { join } from "node:path";
5
5
  import { findOnPath } from "../cli/launch.js";
6
6
  const NF = "https://raw.githubusercontent.com/ryanoasis/nerd-fonts/v3.4.0/patched-fonts/Meslo/S/";
7
- /** Same values as turno-fonts, for an install without that optional package. */
7
+ /**
8
+ * Same values as turno-fonts. turno-cli does not depend on that package (ADR 0019), so a normal
9
+ * install downloads these files and checks each one against its pinned SHA-256.
10
+ */
8
11
  export const FALLBACK = {
9
12
  family: "MesloLGS Nerd Font",
10
13
  version: "3.4.0",
@@ -98,9 +101,11 @@ export async function installFonts(source, opts) {
98
101
  }
99
102
  const wrote = results.some((r) => r.action === "copied" || r.action === "downloaded");
100
103
  if (wrote && !opts.dryRun && (opts.platform ?? process.platform) === "linux") {
101
- const fc = findOnPath("fc-cache", opts.env ?? process.env);
104
+ const env = opts.env ?? process.env;
105
+ const fc = findOnPath("fc-cache", env);
106
+ // The same env as the rest of the install: fontconfig writes its cache under HOME or XDG_CACHE_HOME.
102
107
  if (fc)
103
- execFileSync(fc, ["-f", opts.dir], { stdio: "ignore" });
108
+ execFileSync(fc, ["-f", opts.dir], { stdio: "ignore", env });
104
109
  }
105
110
  return results;
106
111
  }
@@ -1,18 +1,12 @@
1
- import { existsSync, readFileSync, realpathSync } from "node:fs";
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { parseJsonObject, realOr } from "../core/fsutil.js";
3
+ import { tildify } from "../core/paths.js";
2
4
  /** Refresh every 30 s so reset countdowns and the clock-driven parts stay current. */
3
- export const REFRESH_SECONDS = 30;
4
- function real(p) {
5
- try {
6
- return realpathSync(p);
7
- }
8
- catch {
9
- return p;
10
- }
11
- }
5
+ const REFRESH_SECONDS = 30;
12
6
  export function readSettings(file) {
13
7
  if (!existsSync(file))
14
8
  return {};
15
- return JSON.parse(readFileSync(file, "utf8"));
9
+ return parseJsonObject(readFileSync(file, "utf8"), file);
16
10
  }
17
11
  export function currentStatusLine(file) {
18
12
  try {
@@ -23,12 +17,30 @@ export function currentStatusLine(file) {
23
17
  return undefined;
24
18
  }
25
19
  }
26
- /** Whether a status line command runs turno's. */
20
+ /** Whether a status line command runs turno's, with a bare or quoted path (`"/x/turno" statusline`). */
27
21
  export function isTurnoStatusLine(s) {
28
- return Boolean(s && /(^|[\s/])turno statusline(\s|$)/.test(s.command));
22
+ return Boolean(s && /(^|[\s/"'])turno["']?\s+statusline(\s|$)/.test(s.command));
23
+ }
24
+ /**
25
+ * A status line command as one row of doctor or the status screen shows it: "turno statusline"
26
+ * for turno's own, "none" without one, and any other command without quotes, with paths under
27
+ * HOME as ~ and cut to `max` characters.
28
+ */
29
+ export function statusLineLabel(s, env, max = 60) {
30
+ if (!s)
31
+ return "none";
32
+ if (isTurnoStatusLine(s))
33
+ return "turno statusline";
34
+ const text = s.command
35
+ .replace(/["']/g, "")
36
+ .split(/\s+/)
37
+ .filter(Boolean)
38
+ .map((w) => tildify(w, env))
39
+ .join(" ");
40
+ return text.length > max ? `${text.slice(0, max - 3)}...` : text;
29
41
  }
30
42
  /** The entry to write: our command, keeping any other keys the user set (padding, ...). */
31
- export function wantedStatusLine(command, existing) {
43
+ function wantedStatusLine(command, existing) {
32
44
  return { ...(existing ?? {}), type: "command", command, refreshInterval: existing?.refreshInterval ?? REFRESH_SECONDS };
33
45
  }
34
46
  export function setStatusLine(file, command, journal) {
@@ -36,7 +48,7 @@ export function setStatusLine(file, command, journal) {
36
48
  const before = settings.statusLine;
37
49
  const after = wantedStatusLine(command, before);
38
50
  const changed = JSON.stringify(before) !== JSON.stringify(after);
39
- const result = { file: real(file), changed, after, ...(before ? { before } : {}) };
51
+ const result = { file: realOr(file), changed, after, ...(before ? { before } : {}) };
40
52
  if (changed)
41
53
  journal.write(file, `${JSON.stringify({ ...settings, statusLine: after }, null, 2)}\n`);
42
54
  return result;