turno-cli 0.1.1 → 0.3.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.
- package/CHANGELOG.md +432 -0
- package/README.md +228 -73
- package/dist/accounts/audit.js +154 -12
- package/dist/accounts/builtin.js +100 -25
- package/dist/accounts/delegate.js +199 -35
- package/dist/accounts/policy.js +79 -0
- package/dist/accounts/registry.js +39 -21
- package/dist/agents/adapter.js +29 -0
- package/dist/agents/claude.js +246 -0
- package/dist/agents/codex.js +186 -0
- package/dist/agents/copilot.js +56 -0
- package/dist/agents/cursor.js +58 -0
- package/dist/agents/index.js +26 -86
- package/dist/agents/snippets.js +43 -13
- package/dist/cli/args.js +38 -6
- package/dist/cli/commands/accounts.js +119 -52
- package/dist/cli/commands/auto.js +121 -33
- package/dist/cli/commands/browser-identity.js +514 -0
- package/dist/cli/commands/browser-session.js +102 -0
- package/dist/cli/commands/browser-vault.js +193 -0
- package/dist/cli/commands/browser.js +319 -138
- package/dist/cli/commands/complete.js +14 -3
- package/dist/cli/commands/completion.js +8 -2
- package/dist/cli/commands/config.js +186 -24
- package/dist/cli/commands/demo.js +321 -0
- package/dist/cli/commands/doctor.js +525 -123
- package/dist/cli/commands/handoff.js +33 -22
- package/dist/cli/commands/identity.js +192 -54
- package/dist/cli/commands/init.js +648 -0
- package/dist/cli/commands/limit.js +84 -16
- package/dist/cli/commands/mcp-call.js +240 -0
- package/dist/cli/commands/mcp-oauth.js +221 -0
- package/dist/cli/commands/mcp-observe.js +539 -0
- package/dist/cli/commands/mcp-share.js +201 -0
- package/dist/cli/commands/mcp.js +816 -187
- package/dist/cli/commands/mcpd.js +388 -76
- package/dist/cli/commands/migrate.js +6 -4
- package/dist/cli/commands/open.js +115 -27
- package/dist/cli/commands/profile.js +396 -78
- package/dist/cli/commands/resolve.js +14 -3
- package/dist/cli/commands/run.js +36 -6
- package/dist/cli/commands/secret.js +80 -76
- package/dist/cli/commands/session.js +17 -6
- package/dist/cli/commands/sessions.js +48 -12
- package/dist/cli/commands/setup.js +214 -164
- package/dist/cli/commands/status.js +227 -44
- package/dist/cli/commands/statusline.js +311 -114
- package/dist/cli/commands/ui.js +78 -68
- package/dist/cli/commands/undo.js +193 -18
- package/dist/cli/commands/uninstall.js +481 -0
- package/dist/cli/commands/upgrade.js +172 -79
- package/dist/cli/commands/usage.js +125 -51
- package/dist/cli/commands/version.js +21 -7
- package/dist/cli/commands/which.js +9 -24
- package/dist/cli/compile-cache.js +32 -0
- package/dist/cli/diagnostics.js +184 -0
- package/dist/cli/exit.js +65 -0
- package/dist/cli/group.js +24 -12
- package/dist/cli/help.js +62 -0
- package/dist/cli/highlight.js +236 -0
- package/dist/cli/hints.js +30 -0
- package/dist/cli/io.js +186 -1
- package/dist/cli/launch.js +52 -39
- package/dist/cli/launchers.js +161 -95
- package/dist/cli/main.js +201 -31
- package/dist/cli/optional.js +144 -0
- package/dist/cli/output.js +123 -0
- package/dist/cli/picker.js +459 -0
- package/dist/cli/registry.js +61 -6
- package/dist/cli/safe.js +87 -0
- package/dist/cli/secret-input.js +63 -0
- package/dist/cli/security.js +561 -0
- package/dist/cli/style.js +311 -0
- package/dist/cli/topics.js +142 -0
- package/dist/core/config.js +181 -23
- package/dist/core/exhausted.js +6 -8
- package/dist/core/fsutil.js +39 -0
- package/dist/core/journal.js +294 -16
- package/dist/core/manifest.js +153 -6
- package/dist/core/paths.js +14 -13
- package/dist/core/profiles.js +160 -10
- package/dist/core/resolve.js +139 -23
- package/dist/core/secrets.js +68 -23
- package/dist/core/sessions.js +13 -20
- package/dist/core/state-file.js +107 -0
- package/dist/core/update.js +31 -18
- package/dist/core/version.js +57 -10
- package/dist/demo/server.js +42 -0
- package/dist/mcpd/cache.js +23 -10
- package/dist/mcpd/calllog.js +254 -0
- package/dist/mcpd/client-names.js +46 -0
- package/dist/mcpd/connectors.js +188 -18
- package/dist/mcpd/daemon.js +472 -115
- package/dist/mcpd/folder-sets.js +42 -0
- package/dist/mcpd/gateway.js +473 -51
- package/dist/mcpd/health.js +313 -0
- package/dist/mcpd/importer.js +453 -36
- package/dist/mcpd/instances.js +453 -65
- package/dist/mcpd/jsonrpc.js +11 -1
- package/dist/mcpd/launchd.js +65 -48
- package/dist/mcpd/middleware.js +144 -0
- package/dist/mcpd/modern.js +686 -0
- package/dist/mcpd/oauth.js +845 -0
- package/dist/mcpd/peerpid.js +134 -6
- package/dist/mcpd/pressure.js +88 -0
- package/dist/mcpd/rss.js +166 -0
- package/dist/mcpd/service.js +191 -0
- package/dist/mcpd/share.js +217 -0
- package/dist/mcpd/state.js +183 -0
- package/dist/mcpd/sync.js +72 -87
- package/dist/mcpd/systemd.js +83 -0
- package/dist/mcpd/tokens.js +85 -0
- package/dist/mcpd/upstream.js +163 -46
- package/dist/statusline/cost.js +167 -44
- package/dist/statusline/input.js +78 -0
- package/dist/statusline/render.js +9 -3
- package/dist/ui/fonts.js +8 -3
- package/dist/ui/settings.js +33 -16
- package/npm-shrinkwrap.json +1102 -0
- package/package.json +10 -9
- package/dist/cli/commands/available.js +0 -18
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of turno's own screens: semantic colors, status icons, section headers, key/value
|
|
3
|
+
* rows, tables sized to the terminal, usage bars, a spinner and timings. Every command draws with
|
|
4
|
+
* this so the CLI reads as one tool. Without colors (a pipe, NO_COLOR) the same layout comes out
|
|
5
|
+
* as plain text with ASCII icons, stable for scripts and tests.
|
|
6
|
+
*
|
|
7
|
+
* Keep this file free of heavy imports: `turno --help`, `turno status` and the status line load it.
|
|
8
|
+
*/
|
|
9
|
+
import { NAMED_COLORS, PILL_DEFAULTS } from "../statusline/render.js";
|
|
10
|
+
import { colors } from "./io.js";
|
|
11
|
+
const cp = (n) => String.fromCodePoint(n);
|
|
12
|
+
export const ICONS = {
|
|
13
|
+
nerd: {
|
|
14
|
+
ok: cp(0xf00c),
|
|
15
|
+
warn: cp(0xf071),
|
|
16
|
+
err: cp(0xf00d),
|
|
17
|
+
info: cp(0xf05a),
|
|
18
|
+
add: "+",
|
|
19
|
+
remove: "-",
|
|
20
|
+
on: cp(0xf111),
|
|
21
|
+
off: cp(0xf10c),
|
|
22
|
+
arrow: cp(0xf061),
|
|
23
|
+
next: cp(0xf0a9),
|
|
24
|
+
skip: cp(0xf05e),
|
|
25
|
+
},
|
|
26
|
+
unicode: {
|
|
27
|
+
ok: "✓",
|
|
28
|
+
warn: "!",
|
|
29
|
+
err: "✗",
|
|
30
|
+
info: "•",
|
|
31
|
+
add: "+",
|
|
32
|
+
remove: "-",
|
|
33
|
+
on: "●",
|
|
34
|
+
off: "○",
|
|
35
|
+
arrow: "→",
|
|
36
|
+
next: "➜",
|
|
37
|
+
skip: "–",
|
|
38
|
+
},
|
|
39
|
+
ascii: {
|
|
40
|
+
ok: "ok",
|
|
41
|
+
warn: "!",
|
|
42
|
+
err: "x",
|
|
43
|
+
info: "-",
|
|
44
|
+
add: "+",
|
|
45
|
+
remove: "-",
|
|
46
|
+
on: "",
|
|
47
|
+
off: "",
|
|
48
|
+
arrow: "->",
|
|
49
|
+
next: "",
|
|
50
|
+
skip: "-",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
/** SGR codes of the semantic colors: the terminal's own palette, so dark and light themes both work. */
|
|
54
|
+
const CODES = { ok: "32", warn: "33", err: "31", accent: "36", muted: "2", faint: "90", bold: "1" };
|
|
55
|
+
/**
|
|
56
|
+
* The 256-color code of a profile: its `color` in config.toml, or one of the defaults by its
|
|
57
|
+
* place in the config. The one rule for every profile pill: the status line (`pillColor` in
|
|
58
|
+
* statusline.ts) calls this too, and the color tables are the status line's (render.ts).
|
|
59
|
+
*/
|
|
60
|
+
export function profileColor(profiles, name) {
|
|
61
|
+
const c = profiles[name]?.color;
|
|
62
|
+
if (typeof c === "number")
|
|
63
|
+
return c;
|
|
64
|
+
if (typeof c === "string") {
|
|
65
|
+
if (/^\d+$/.test(c))
|
|
66
|
+
return Number(c);
|
|
67
|
+
const named = NAMED_COLORS[c.toLowerCase()];
|
|
68
|
+
if (named !== undefined)
|
|
69
|
+
return named;
|
|
70
|
+
}
|
|
71
|
+
const names = Object.keys(profiles);
|
|
72
|
+
const idx = names.includes(name) ? names.indexOf(name) : [...name].reduce((a, ch) => a + ch.charCodeAt(0), 0);
|
|
73
|
+
return PILL_DEFAULTS[idx % PILL_DEFAULTS.length];
|
|
74
|
+
}
|
|
75
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: matching ANSI escapes is the point
|
|
76
|
+
const ANSI = /\x1b\[[0-9;]*m/g;
|
|
77
|
+
/** Text without its ANSI color codes. */
|
|
78
|
+
export function stripAnsi(text) {
|
|
79
|
+
return text.replace(ANSI, "");
|
|
80
|
+
}
|
|
81
|
+
/** Columns a string takes on screen (ANSI codes take none). */
|
|
82
|
+
export function visibleWidth(text) {
|
|
83
|
+
return [...stripAnsi(text)].length;
|
|
84
|
+
}
|
|
85
|
+
/** Pad to `width` visible columns. */
|
|
86
|
+
export function padEnd(text, width) {
|
|
87
|
+
return text + " ".repeat(Math.max(0, width - visibleWidth(text)));
|
|
88
|
+
}
|
|
89
|
+
function padStart(text, width) {
|
|
90
|
+
return " ".repeat(Math.max(0, width - visibleWidth(text))) + text;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Columns of the terminal: COLUMNS, then the real terminal, then 80 (a pipe, a test). Never
|
|
94
|
+
* below 40, so layouts keep a sane minimum.
|
|
95
|
+
*/
|
|
96
|
+
export function termWidth(io) {
|
|
97
|
+
const env = Number(io.env.COLUMNS);
|
|
98
|
+
if (Number.isInteger(env) && env > 0)
|
|
99
|
+
return Math.max(40, env);
|
|
100
|
+
const real = io.isTty ? process.stdout.columns : undefined;
|
|
101
|
+
return real && real > 0 ? Math.max(40, real) : 80;
|
|
102
|
+
}
|
|
103
|
+
/** "420ms", "1.2s", "1m05s". */
|
|
104
|
+
export function duration(ms) {
|
|
105
|
+
if (ms < 1000)
|
|
106
|
+
return `${Math.max(0, Math.round(ms))}ms`;
|
|
107
|
+
if (ms < 60_000)
|
|
108
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
109
|
+
const s = Math.round(ms / 1000);
|
|
110
|
+
return `${Math.floor(s / 60)}m${String(s % 60).padStart(2, "0")}s`;
|
|
111
|
+
}
|
|
112
|
+
/** Level of a usage percentage: below 60 fine, below 85 a warning, then a problem. */
|
|
113
|
+
export function level(pct) {
|
|
114
|
+
return pct < 60 ? "ok" : pct < 85 ? "warn" : "err";
|
|
115
|
+
}
|
|
116
|
+
/** Cut a word that may hold ANSI codes into pieces of at most `width` visible columns. */
|
|
117
|
+
function chop(word, width) {
|
|
118
|
+
const pieces = [];
|
|
119
|
+
let piece = "";
|
|
120
|
+
let w = 0;
|
|
121
|
+
// ANSI codes take no columns and stay with the character after them.
|
|
122
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: matching ANSI escapes is the point
|
|
123
|
+
for (const m of word.matchAll(/\x1b\[[0-9;]*m|[^\x1b]/gu)) {
|
|
124
|
+
const t = m[0];
|
|
125
|
+
if (t.startsWith("\x1b")) {
|
|
126
|
+
piece += t;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
if (w === width) {
|
|
130
|
+
pieces.push(piece);
|
|
131
|
+
piece = "";
|
|
132
|
+
w = 0;
|
|
133
|
+
}
|
|
134
|
+
piece += t;
|
|
135
|
+
w++;
|
|
136
|
+
}
|
|
137
|
+
if (piece)
|
|
138
|
+
pieces.push(piece);
|
|
139
|
+
return pieces;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Break text that may hold ANSI codes into lines of at most `width` visible columns, at spaces.
|
|
143
|
+
* A word longer than the width (a long path) is cut at the width. Colors carry over: a terminal
|
|
144
|
+
* keeps the active SGR across a line break.
|
|
145
|
+
*/
|
|
146
|
+
export function wrapAnsi(text, width) {
|
|
147
|
+
if (visibleWidth(text) <= width)
|
|
148
|
+
return [text];
|
|
149
|
+
const words = text.split(" ").flatMap((word) => (visibleWidth(word) > width ? chop(word, width) : [word]));
|
|
150
|
+
const [first = "", ...rest] = words;
|
|
151
|
+
const lines = [];
|
|
152
|
+
let line = first;
|
|
153
|
+
let w = visibleWidth(first);
|
|
154
|
+
for (const word of rest) {
|
|
155
|
+
const ww = visibleWidth(word);
|
|
156
|
+
// Break before a word that does not fit; spaces inside a line (alignment) stay as they are.
|
|
157
|
+
if (w > 0 && ww > 0 && w + 1 + ww > width) {
|
|
158
|
+
lines.push(line);
|
|
159
|
+
line = word;
|
|
160
|
+
w = ww;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
line += ` ${word}`;
|
|
164
|
+
w += 1 + ww;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
lines.push(line);
|
|
168
|
+
return lines;
|
|
169
|
+
}
|
|
170
|
+
/** Columns a wrapping last table column keeps before other columns are dropped for it. */
|
|
171
|
+
const LAST_MIN = 24;
|
|
172
|
+
export function style(io, opts = {}) {
|
|
173
|
+
const color = colors(io);
|
|
174
|
+
const icons = !color ? "ascii" : opts.nerd ? "nerd" : "unicode";
|
|
175
|
+
const width = termWidth(io);
|
|
176
|
+
const sgr = (code) => (s) => (color && s ? `\x1b[${code}m${s}\x1b[0m` : s);
|
|
177
|
+
const ok = sgr(CODES.ok);
|
|
178
|
+
const warn = sgr(CODES.warn);
|
|
179
|
+
const err = sgr(CODES.err);
|
|
180
|
+
const accent = sgr(CODES.accent);
|
|
181
|
+
const muted = sgr(CODES.muted);
|
|
182
|
+
const faint = sgr(CODES.faint);
|
|
183
|
+
const bold = sgr(CODES.bold);
|
|
184
|
+
const ICON_COLOR = {
|
|
185
|
+
ok,
|
|
186
|
+
warn,
|
|
187
|
+
err,
|
|
188
|
+
info: accent,
|
|
189
|
+
add: ok,
|
|
190
|
+
remove: err,
|
|
191
|
+
on: ok,
|
|
192
|
+
off: faint,
|
|
193
|
+
arrow: faint,
|
|
194
|
+
next: accent,
|
|
195
|
+
skip: faint,
|
|
196
|
+
};
|
|
197
|
+
const icon = (name) => (ICON_COLOR[name] ?? ((s) => s))(ICONS[icons][name]);
|
|
198
|
+
const iconWidth = Math.max(...["ok", "warn", "err", "skip", "info"].map((n) => visibleWidth(ICONS[icons][n])));
|
|
199
|
+
const wrapLine = (prefix, text) => {
|
|
200
|
+
if (!color)
|
|
201
|
+
return `${prefix}${text}`;
|
|
202
|
+
const hang = visibleWidth(prefix);
|
|
203
|
+
const body = wrapAnsi(text, Math.max(20, width - hang));
|
|
204
|
+
return [`${prefix}${body[0]}`, ...body.slice(1).map((l) => `${" ".repeat(hang)}${l}`)].join("\n");
|
|
205
|
+
};
|
|
206
|
+
const tableRows = (rows, o = {}) => {
|
|
207
|
+
const indent = o.indent ?? 2;
|
|
208
|
+
const gap = o.gap ?? 2;
|
|
209
|
+
const cols = o.columns ?? [];
|
|
210
|
+
const n = Math.max(0, ...rows.map((r) => r.length));
|
|
211
|
+
let keep = Array.from({ length: n }, (_, i) => i);
|
|
212
|
+
const widthOf = (i) => Math.max(0, ...rows.map((r) => visibleWidth(r[i] ?? "")));
|
|
213
|
+
// The last column wraps under itself, so it only needs LAST_MIN columns to fit.
|
|
214
|
+
const total = (ks) => indent +
|
|
215
|
+
ks.reduce((a, i, k) => a + (k === ks.length - 1 ? Math.min(widthOf(i), LAST_MIN) : widthOf(i)), 0) +
|
|
216
|
+
gap * Math.max(0, ks.length - 1);
|
|
217
|
+
// Only a terminal drops columns: a pipe keeps everything for whoever reads it.
|
|
218
|
+
while (color && total(keep) > width) {
|
|
219
|
+
const droppable = keep.filter((i) => cols[i]?.drop !== undefined).sort((a, b) => cols[b].drop - cols[a].drop);
|
|
220
|
+
if (!droppable.length)
|
|
221
|
+
break;
|
|
222
|
+
keep = keep.filter((i) => i !== droppable[0]);
|
|
223
|
+
}
|
|
224
|
+
const widths = new Map(keep.map((i) => [i, widthOf(i)]));
|
|
225
|
+
return rows.map((r) => {
|
|
226
|
+
const cells = keep.map((i, k) => {
|
|
227
|
+
const cell = r[i] ?? "";
|
|
228
|
+
const w = widths.get(i);
|
|
229
|
+
if (cols[i]?.align === "right")
|
|
230
|
+
return padStart(cell, w);
|
|
231
|
+
return k === keep.length - 1 ? cell : padEnd(cell, w);
|
|
232
|
+
});
|
|
233
|
+
const head = " ".repeat(indent) +
|
|
234
|
+
cells
|
|
235
|
+
.slice(0, -1)
|
|
236
|
+
.map((c) => `${c}${" ".repeat(gap)}`)
|
|
237
|
+
.join("");
|
|
238
|
+
return wrapLine(head, cells.at(-1) ?? "")
|
|
239
|
+
.split("\n")
|
|
240
|
+
.map((l) => l.trimEnd());
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
const table = (rows, o) => tableRows(rows, o).flat();
|
|
244
|
+
return {
|
|
245
|
+
color,
|
|
246
|
+
icons,
|
|
247
|
+
width,
|
|
248
|
+
bold,
|
|
249
|
+
muted,
|
|
250
|
+
accent,
|
|
251
|
+
ok,
|
|
252
|
+
warn,
|
|
253
|
+
err,
|
|
254
|
+
icon,
|
|
255
|
+
lead: (name, text) => (ICONS[icons][name] ? `${icon(name)} ${text}` : text),
|
|
256
|
+
profile: (name, c) => color && c !== undefined ? `\x1b[48;5;${c};1;38;5;255m ${name} \x1b[0m` : color ? bold(name) : name,
|
|
257
|
+
header: (title) => {
|
|
258
|
+
if (!color)
|
|
259
|
+
return title;
|
|
260
|
+
const rule = Math.max(0, Math.min(width, 80) - visibleWidth(title) - 1);
|
|
261
|
+
return `${bold(title)} ${faint("─".repeat(rule))}`;
|
|
262
|
+
},
|
|
263
|
+
kv: (key, value, keyWidth, indent = 2) => wrapLine(`${" ".repeat(indent)}${muted(padEnd(key, keyWidth))} `, value).trimEnd(),
|
|
264
|
+
table,
|
|
265
|
+
tableRows,
|
|
266
|
+
wrap: wrapLine,
|
|
267
|
+
note: (state, text, indent = 2) => wrapLine(`${" ".repeat(indent)}${padEnd(icon(state), iconWidth)} `, text),
|
|
268
|
+
bar: (pct, cells = 10) => {
|
|
269
|
+
const p = Math.min(Math.max(pct, 0), 100);
|
|
270
|
+
const filled = Math.round((p * cells) / 100);
|
|
271
|
+
const paint = { ok, warn, err }[level(p)];
|
|
272
|
+
// A heavy rule on a terminal (colored, the rest faint); blocks in plain text, where only shape tells.
|
|
273
|
+
const [on, off] = color ? ["━", "━"] : ["█", "░"];
|
|
274
|
+
return `${paint(on.repeat(filled))}${faint(off.repeat(cells - filled))} ${paint(`${p.toFixed(0)}%`.padStart(4))}`;
|
|
275
|
+
},
|
|
276
|
+
check: (state, text) => `${padEnd(icon(state), iconWidth)} ${text}`,
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
const FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
280
|
+
/**
|
|
281
|
+
* A spinner with the elapsed time on stderr, for steps that wait (the gateway starting). Only on
|
|
282
|
+
* a terminal with colors: anywhere else it draws nothing, and the caller prints the result line.
|
|
283
|
+
*/
|
|
284
|
+
export function spinner(io, text, opts = {}) {
|
|
285
|
+
const now = opts.now ?? Date.now;
|
|
286
|
+
const start = now();
|
|
287
|
+
const tty = opts.tty ?? Boolean(process.stderr.isTTY);
|
|
288
|
+
const write = opts.write ?? ((s) => process.stderr.write(s));
|
|
289
|
+
if (!tty || !colors(io))
|
|
290
|
+
return { update: () => { }, stop: () => now() - start };
|
|
291
|
+
let current = text;
|
|
292
|
+
let frame = 0;
|
|
293
|
+
const draw = () => {
|
|
294
|
+
const secs = ((now() - start) / 1000).toFixed(1);
|
|
295
|
+
write(`\r\x1b[K\x1b[36m${FRAMES[frame++ % FRAMES.length]}\x1b[0m ${current} \x1b[2m${secs}s\x1b[0m`);
|
|
296
|
+
};
|
|
297
|
+
draw();
|
|
298
|
+
const timer = setInterval(draw, 80);
|
|
299
|
+
timer.unref?.();
|
|
300
|
+
return {
|
|
301
|
+
update: (t) => {
|
|
302
|
+
current = t;
|
|
303
|
+
},
|
|
304
|
+
stop: () => {
|
|
305
|
+
clearInterval(timer);
|
|
306
|
+
write("\r\x1b[K");
|
|
307
|
+
return now() - start;
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `turno help <topic>`: environment, exit-codes and json (like gh's help topics). Static text
|
|
3
|
+
* only, so a topic loads no command module.
|
|
4
|
+
*/
|
|
5
|
+
import { EXIT_ROWS } from "./exit.js";
|
|
6
|
+
import { columns, examplesBlock } from "./io.js";
|
|
7
|
+
/** Variables turno reads, by section: name and what it does. */
|
|
8
|
+
const ENVIRONMENT = [
|
|
9
|
+
{
|
|
10
|
+
title: "Where turno keeps things",
|
|
11
|
+
rows: [
|
|
12
|
+
["TURNO_CONFIG_DIR", "config.toml and mcp.toml (default: $XDG_CONFIG_HOME/turno, else ~/.config/turno)"],
|
|
13
|
+
[
|
|
14
|
+
"TURNO_STATE_DIR",
|
|
15
|
+
"state, logs, caches and backups (default: $XDG_STATE_HOME/turno, else ~/.local/state/turno)",
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"TURNO_DATA_DIR",
|
|
19
|
+
"installed servers and browser identities (default: $XDG_DATA_HOME/turno, else ~/.local/share/turno)",
|
|
20
|
+
],
|
|
21
|
+
["TURNO_BIN", "where the launchers go (default: ~/.local/bin)"],
|
|
22
|
+
["TURNO_HUB", "Claude Code's shared folder (default: ~/.claude)"],
|
|
23
|
+
["TURNO_HUB_CONFIG", "Claude Code's shared .claude.json (default: ~/.claude.json)"],
|
|
24
|
+
["TURNO_FONT_DIR", "where turno ui installs the status line font"],
|
|
25
|
+
["TURNO_APPS_DIR", "where turno looks for terminal apps on macOS (default: /Applications)"],
|
|
26
|
+
["TURNO_CHROME_APP", "Google Chrome on macOS, for turno open (default: /Applications/Google Chrome.app)"],
|
|
27
|
+
["TURNO_CHROME_BIN", "the Chrome program on Linux, for turno open"],
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "How turno behaves",
|
|
32
|
+
rows: [
|
|
33
|
+
[
|
|
34
|
+
"TURNO_NO_INPUT",
|
|
35
|
+
"1: never ask, exit 2 and name the flag instead (same as --no-input); 0: ask even inside an agent session",
|
|
36
|
+
],
|
|
37
|
+
["TURNO_COLOR", "always, never or auto (same as --color); see the order below"],
|
|
38
|
+
["TURNO_ALLOW_PLAIN", "1: turno auto runs the plain agent when config.toml does not parse"],
|
|
39
|
+
[
|
|
40
|
+
"TURNO_SAFE",
|
|
41
|
+
"1: turno run, turno <profile> and turno auto open the agent in safe mode, without the gateway and the status line (same as --no-gateway)",
|
|
42
|
+
],
|
|
43
|
+
["TURNO_NO_UPDATE_CHECK", "1: no daily update check and no notice"],
|
|
44
|
+
["TURNO_NO_UPDATE_NOTIFIER", "1: same as TURNO_NO_UPDATE_CHECK (the name gh uses)"],
|
|
45
|
+
["TURNO_REGISTRY", "npm registry for update checks (default: npm_config_registry, else registry.npmjs.org)"],
|
|
46
|
+
["TURNO_BROWSER_IDLE", "turno-browser closes Chrome after this long without a tool call (default: 15m)"],
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: "Set by turno for the agents it starts (read them, do not set them)",
|
|
51
|
+
rows: [
|
|
52
|
+
["TURNO_PROFILE", "the profile a launcher opened"],
|
|
53
|
+
["TURNO_AGENT", "that profile's agent (codex, copilot, cursor)"],
|
|
54
|
+
["TURNO_SESSION_PID", "the agent's process id, sent to the gateway"],
|
|
55
|
+
["TURNO_SESSION_CWD_B64", "the agent's folder (base64url), sent to the gateway"],
|
|
56
|
+
["TURNO_MCPD_TOKEN", "the profile's gateway token, for agents that read headers from the environment"],
|
|
57
|
+
["TURNO_MCPD_SERVICE", "set by the mcpd service file (LaunchAgent or systemd unit)"],
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: "Standard variables turno honors",
|
|
62
|
+
rows: [
|
|
63
|
+
["NO_COLOR", "set and not empty: no colors (no-color.org)"],
|
|
64
|
+
["FORCE_COLOR", "0 or false: no colors; anything else: colors, also in a pipe"],
|
|
65
|
+
["CLICOLOR_FORCE", "set and not 0: colors, also in a pipe"],
|
|
66
|
+
["CLICOLOR", "0: no colors"],
|
|
67
|
+
["TERM", "dumb: no colors"],
|
|
68
|
+
["COLUMNS", "the width to lay out for (default: the terminal's, else 80)"],
|
|
69
|
+
["DO_NOT_TRACK", "1: no update check (turno sends nothing else anywhere)"],
|
|
70
|
+
["CI", "set: no update check"],
|
|
71
|
+
["NO_UPDATE_NOTIFIER", "1: no update check"],
|
|
72
|
+
[
|
|
73
|
+
"XDG_CONFIG_HOME, XDG_STATE_HOME, XDG_DATA_HOME, XDG_CACHE_HOME",
|
|
74
|
+
"base folders, when the TURNO_* ones are not set",
|
|
75
|
+
],
|
|
76
|
+
["VISUAL, EDITOR", "the editor of turno config edit"],
|
|
77
|
+
[
|
|
78
|
+
"NODE_COMPILE_CACHE, NODE_DISABLE_COMPILE_CACHE",
|
|
79
|
+
"Node's compile cache (turno keeps it in $XDG_CACHE_HOME/turno)",
|
|
80
|
+
],
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
function environment() {
|
|
85
|
+
const out = ["Environment variables turno reads.", ""];
|
|
86
|
+
for (const s of ENVIRONMENT)
|
|
87
|
+
out.push(`${s.title}:`, columns(s.rows, 2, 26), "");
|
|
88
|
+
out.push("Colors: the first that applies wins: --color, TURNO_COLOR, NO_COLOR, FORCE_COLOR,", "CLICOLOR_FORCE, then CLICOLOR=0 or TERM=dumb, then whether output is a terminal.", "--json output is colored only on a terminal.", "", examplesBlock([
|
|
89
|
+
"NO_COLOR=1 turno status",
|
|
90
|
+
"TURNO_NO_INPUT=1 turno profile remove work # fails fast instead of asking",
|
|
91
|
+
"TURNO_CONFIG_DIR=/tmp/t turno doctor",
|
|
92
|
+
"TURNO_SAFE=1 turno work # without the gateway, to tell whether a problem is turno's",
|
|
93
|
+
]));
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
function exitCodes() {
|
|
97
|
+
return [
|
|
98
|
+
"Exit codes. Scripts, hooks and status lines can rely on these.",
|
|
99
|
+
"",
|
|
100
|
+
columns(EXIT_ROWS.map(([code, name, what]) => [`${code} ${name}`, what]), 2, 18),
|
|
101
|
+
"",
|
|
102
|
+
"With --json, an error is one JSON line on stderr with the same code:",
|
|
103
|
+
' {"schemaVersion":1,"error":{"code":"no_profile","exitCode":3,"message":"..."}}',
|
|
104
|
+
"",
|
|
105
|
+
examplesBlock([
|
|
106
|
+
"turno profile which --check || turno profile assign . work",
|
|
107
|
+
"turno mcp daemon status >/dev/null; [ $? -eq 5 ] && turno mcp daemon start",
|
|
108
|
+
]),
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
function json() {
|
|
112
|
+
return [
|
|
113
|
+
"JSON output. Read commands take --json:",
|
|
114
|
+
"",
|
|
115
|
+
columns([
|
|
116
|
+
["--json", "every field, as one indented document"],
|
|
117
|
+
["--json=fields", "the field names, one per line, and nothing else"],
|
|
118
|
+
["--json=a,b", "only those fields; an unknown one is a usage error (exit 2) that lists the known ones"],
|
|
119
|
+
[
|
|
120
|
+
"--watch --json",
|
|
121
|
+
"one compact JSON record per line (NDJSON) until Ctrl-C (turno limit show, turno mcp top); turno mcp log --follow --json too",
|
|
122
|
+
],
|
|
123
|
+
], 2, 16),
|
|
124
|
+
"",
|
|
125
|
+
"Every object carries schemaVersion, and so does each element of a list. A version",
|
|
126
|
+
"goes up only when a field is removed or renamed or changes meaning (the changelog",
|
|
127
|
+
"says so); new fields keep it. Errors under --json are JSON on stderr (turno help",
|
|
128
|
+
"exit-codes). turno config get prints a config value as it is in config.toml.",
|
|
129
|
+
"",
|
|
130
|
+
examplesBlock([
|
|
131
|
+
"turno status --json=fields",
|
|
132
|
+
"turno profile list --json=name,email",
|
|
133
|
+
"turno limit show --watch --json | jq -c '.fiveHour'",
|
|
134
|
+
]),
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
export const TOPICS = {
|
|
138
|
+
environment: { summary: "every environment variable turno reads", text: environment },
|
|
139
|
+
"exit-codes": { summary: "what each exit code means", text: exitCodes },
|
|
140
|
+
json: { summary: "the --json contract: fields, schemaVersion, NDJSON, errors", text: json },
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=topics.js.map
|