turno-cli 0.2.0 → 0.4.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 +266 -0
- package/README.md +134 -42
- package/dist/accounts/audit.js +27 -15
- package/dist/accounts/builtin.js +35 -7
- package/dist/accounts/delegate.js +30 -7
- package/dist/accounts/policy.js +4 -2
- package/dist/accounts/registry.js +3 -1
- package/dist/agents/adapter.js +22 -0
- package/dist/agents/claude.js +54 -3
- package/dist/agents/codex.js +94 -6
- package/dist/agents/copilot.js +19 -2
- package/dist/agents/cursor.js +19 -2
- package/dist/agents/index.js +1 -1
- package/dist/agents/snippets.js +37 -10
- package/dist/cli/args.js +32 -15
- package/dist/cli/commands/accounts.js +29 -7
- package/dist/cli/commands/auto.js +50 -12
- package/dist/cli/commands/browser-do-session.js +170 -0
- package/dist/cli/commands/browser-do.js +740 -0
- package/dist/cli/commands/browser-flows.js +300 -0
- package/dist/cli/commands/browser-identity.js +952 -0
- package/dist/cli/commands/browser-live.js +118 -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 +303 -62
- package/dist/cli/commands/complete.js +13 -3
- package/dist/cli/commands/completion.js +4 -0
- package/dist/cli/commands/config.js +90 -13
- package/dist/cli/commands/demo.js +36 -7
- package/dist/cli/commands/doctor.js +170 -36
- package/dist/cli/commands/identity.js +101 -12
- package/dist/cli/commands/init.js +42 -10
- package/dist/cli/commands/limit.js +65 -9
- package/dist/cli/commands/mcp-call.js +240 -0
- package/dist/cli/commands/mcp-oauth.js +33 -6
- package/dist/cli/commands/mcp-observe.js +128 -23
- package/dist/cli/commands/mcp-share.js +201 -0
- package/dist/cli/commands/mcp.js +203 -42
- package/dist/cli/commands/mcpd.js +76 -12
- package/dist/cli/commands/open.js +26 -3
- package/dist/cli/commands/profile.js +212 -30
- package/dist/cli/commands/resolve.js +8 -1
- package/dist/cli/commands/run.js +24 -4
- package/dist/cli/commands/secret.js +23 -38
- package/dist/cli/commands/session.js +16 -5
- package/dist/cli/commands/sessions.js +7 -1
- package/dist/cli/commands/setup.js +83 -11
- package/dist/cli/commands/status.js +67 -15
- package/dist/cli/commands/statusline.js +7 -2
- package/dist/cli/commands/ui.js +17 -5
- package/dist/cli/commands/undo.js +39 -7
- package/dist/cli/commands/uninstall.js +24 -5
- package/dist/cli/commands/upgrade.js +113 -76
- package/dist/cli/commands/usage.js +11 -10
- package/dist/cli/commands/version.js +20 -8
- package/dist/cli/commands/which.js +5 -3
- package/dist/cli/diagnostics.js +184 -0
- package/dist/cli/exit.js +65 -0
- package/dist/cli/group.js +20 -8
- package/dist/cli/help.js +6 -1
- package/dist/cli/hints.js +30 -0
- package/dist/cli/io.js +24 -8
- package/dist/cli/launch.js +31 -2
- package/dist/cli/launchers.js +25 -10
- package/dist/cli/main.js +52 -18
- package/dist/cli/optional.js +144 -0
- package/dist/cli/output.js +123 -0
- package/dist/cli/picker.js +17 -5
- package/dist/cli/registry.js +20 -2
- package/dist/cli/safe.js +87 -0
- package/dist/cli/secret-input.js +63 -0
- package/dist/cli/security.js +31 -9
- package/dist/cli/style.js +35 -5
- package/dist/cli/topics.js +155 -0
- package/dist/core/config.js +39 -3
- package/dist/core/fsutil.js +2 -10
- package/dist/core/journal.js +19 -11
- package/dist/core/manifest.js +28 -1
- package/dist/core/paths.js +6 -112
- package/dist/core/profiles.js +28 -8
- package/dist/core/resolve.js +13 -3
- package/dist/core/secrets.js +4 -154
- package/dist/core/state-file.js +107 -0
- package/dist/core/update.js +14 -11
- package/dist/core/version.js +57 -10
- package/dist/demo/server.js +10 -2
- package/dist/mcpd/cache.js +6 -7
- package/dist/mcpd/calllog.js +10 -9
- package/dist/mcpd/client-names.js +8 -13
- package/dist/mcpd/connectors.js +42 -3
- package/dist/mcpd/daemon.js +29 -8
- package/dist/mcpd/folder-sets.js +5 -2
- package/dist/mcpd/gateway.js +57 -29
- package/dist/mcpd/health.js +70 -26
- package/dist/mcpd/importer.js +106 -9
- package/dist/mcpd/instances.js +70 -32
- package/dist/mcpd/jsonrpc.js +3 -1
- package/dist/mcpd/middleware.js +156 -0
- package/dist/mcpd/modern.js +57 -19
- package/dist/mcpd/oauth.js +71 -17
- package/dist/mcpd/peerpid.js +63 -17
- package/dist/mcpd/pressure.js +4 -1
- package/dist/mcpd/rss.js +34 -19
- package/dist/mcpd/service.js +28 -4
- package/dist/mcpd/share.js +217 -0
- package/dist/mcpd/state.js +16 -16
- package/dist/mcpd/sync.js +22 -12
- package/dist/mcpd/systemd.js +4 -1
- package/dist/mcpd/tokens.js +4 -8
- package/dist/mcpd/upstream.js +12 -5
- package/dist/statusline/cost.js +17 -4
- package/dist/statusline/input.js +15 -3
- package/dist/ui/fonts.js +1 -1
- package/dist/ui/settings.js +6 -1
- package/npm-shrinkwrap.json +12 -3
- package/package.json +7 -6
|
@@ -3,18 +3,25 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { parse } from "smol-toml";
|
|
4
4
|
import { loadRegistry } from "../../accounts/registry.js";
|
|
5
5
|
import { editConfig, migrationPending, readConfigText } from "../../core/config-edit.js";
|
|
6
|
-
import { IDLE_UNDER_PRESSURE_PROBLEM, loadConfig, parseIdleUnderPressure, requestBodyProblem } from "../../core/config.js";
|
|
6
|
+
import { IDLE_UNDER_PRESSURE_PROBLEM, loadConfig, parseIdleUnderPressure, requestBodyProblem, } from "../../core/config.js";
|
|
7
7
|
import { DEFAULT_AGENT, adapter, isAgentId } from "../../agents/index.js";
|
|
8
8
|
import { agentOf, configProblems, listProfiles } from "../../core/profiles.js";
|
|
9
9
|
import { Journal } from "../../core/journal.js";
|
|
10
10
|
import { loadManifest } from "../../core/manifest.js";
|
|
11
11
|
import { paths, tildify } from "../../core/paths.js";
|
|
12
12
|
import { removeValue, setValue } from "../../core/toml-edit.js";
|
|
13
|
-
import { DRY_RUN, JSON_FLAG, bool, flagsOf, parseFlags
|
|
13
|
+
import { DRY_RUN, JSON_FLAG, bool, flagsOf, parseFlags } from "../args.js";
|
|
14
|
+
import { emit, emitConfigValue, jsonOutput } from "../output.js";
|
|
14
15
|
import { group } from "../group.js";
|
|
15
16
|
import { highlightToml } from "../highlight.js";
|
|
16
|
-
import { colors, columns, fail, paint } from "../io.js";
|
|
17
|
+
import { CliError, colors, columns, fail, paint } from "../io.js";
|
|
17
18
|
import { parseColor } from "./profile.js";
|
|
19
|
+
/**
|
|
20
|
+
* `turno config path --json`: one entry per file, each {path, exists}; with --all,
|
|
21
|
+
* `all` lists every path turno uses, each {name, path, exists, about}.
|
|
22
|
+
*/
|
|
23
|
+
const PATH_JSON = jsonOutput(["config", "mcp", "accounts", "state", "backups", "all"]);
|
|
24
|
+
const PATH_FLAGS = { all: { type: "boolean" }, ...JSON_FLAG };
|
|
18
25
|
/** Keys `config set` may change; tables of their own have their own commands. */
|
|
19
26
|
const KEYS = {
|
|
20
27
|
system: 'profile the plain claude command (~/.claude) is logged into; "" for none (then turno auto needs a rule)',
|
|
@@ -25,6 +32,7 @@ const KEYS = {
|
|
|
25
32
|
icons: "auto, nerd or unicode",
|
|
26
33
|
nerd_terminals: "terminals whose font draws Nerd icons",
|
|
27
34
|
update_check: "true or false: look for new turno releases once a day",
|
|
35
|
+
hints: "true or false: print the next step after a command that writes",
|
|
28
36
|
"open.chrome_dir": "folder of the isolated Chrome profiles",
|
|
29
37
|
"mcpd.port": "port of the MCP gateway",
|
|
30
38
|
"mcpd.call_log": "true or false: keep the log of tool calls (turno mcp log)",
|
|
@@ -62,15 +70,42 @@ export function parseValue(raw) {
|
|
|
62
70
|
return raw;
|
|
63
71
|
}
|
|
64
72
|
function lookup(doc, key) {
|
|
65
|
-
return key
|
|
73
|
+
return key
|
|
74
|
+
.split(".")
|
|
75
|
+
.reduce((v, k) => (v && typeof v === "object" ? v[k] : undefined), doc);
|
|
66
76
|
}
|
|
67
77
|
async function path(args, io) {
|
|
68
|
-
const p = parseFlags(args,
|
|
78
|
+
const p = parseFlags(args, PATH_FLAGS, 0);
|
|
69
79
|
const env = io.env;
|
|
70
80
|
const pp = paths(env);
|
|
71
|
-
const files = {
|
|
81
|
+
const files = {
|
|
82
|
+
config: pp.configFile,
|
|
83
|
+
mcp: pp.mcpFile,
|
|
84
|
+
accounts: pp.accountsFile,
|
|
85
|
+
state: pp.state,
|
|
86
|
+
backups: pp.backupsDir,
|
|
87
|
+
};
|
|
88
|
+
const all = bool(p, "all") ? (await import("../diagnostics.js")).allPaths(env) : undefined;
|
|
72
89
|
if (bool(p, "json")) {
|
|
73
|
-
|
|
90
|
+
emit(io, p, PATH_JSON, {
|
|
91
|
+
...Object.fromEntries(Object.entries(files).map(([k, v]) => [k, { path: tildify(v, env), exists: existsSync(v) }])),
|
|
92
|
+
...(all
|
|
93
|
+
? {
|
|
94
|
+
all: all.map((e) => ({
|
|
95
|
+
name: e.name,
|
|
96
|
+
path: tildify(e.path, env),
|
|
97
|
+
exists: existsSync(e.path),
|
|
98
|
+
about: e.about,
|
|
99
|
+
})),
|
|
100
|
+
}
|
|
101
|
+
: {}),
|
|
102
|
+
});
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
if (all) {
|
|
106
|
+
const w = Math.max(...all.map((e) => e.name.length));
|
|
107
|
+
for (const e of all)
|
|
108
|
+
io.out(`${e.name.padEnd(w)} ${tildify(e.path, env)}${existsSync(e.path) ? "" : paint(io, " (not there yet)", "2")} ${paint(io, e.about, "2")}`);
|
|
74
109
|
return 0;
|
|
75
110
|
}
|
|
76
111
|
for (const [k, v] of Object.entries(files))
|
|
@@ -79,6 +114,9 @@ async function path(args, io) {
|
|
|
79
114
|
}
|
|
80
115
|
async function get(args, io) {
|
|
81
116
|
const p = parseFlags(args, JSON_FLAG, 1);
|
|
117
|
+
// A config value has config.toml's shape, not a schema of fields.
|
|
118
|
+
if (p.json)
|
|
119
|
+
fail("config get --json takes no fields: it prints the value as config.toml holds it");
|
|
82
120
|
const key = p.positionals[0];
|
|
83
121
|
const text = readConfigText(io.env);
|
|
84
122
|
loadConfig(io.env); // report a broken file before reading from it
|
|
@@ -87,11 +125,13 @@ async function get(args, io) {
|
|
|
87
125
|
if (v === undefined) {
|
|
88
126
|
if (!key)
|
|
89
127
|
return 0;
|
|
128
|
+
if (bool(p, "json"))
|
|
129
|
+
throw new CliError(`${key} is not set`);
|
|
90
130
|
io.err(`${key} is not set`);
|
|
91
131
|
return 1;
|
|
92
132
|
}
|
|
93
133
|
if (bool(p, "json") || typeof v === "object")
|
|
94
|
-
|
|
134
|
+
emitConfigValue(io, v);
|
|
95
135
|
else
|
|
96
136
|
io.out(String(v));
|
|
97
137
|
return 0;
|
|
@@ -138,8 +178,9 @@ export function checkValue(key, raw, env) {
|
|
|
138
178
|
fail("icons must be auto, nerd or unicode");
|
|
139
179
|
return raw;
|
|
140
180
|
case "update_check":
|
|
181
|
+
case "hints":
|
|
141
182
|
if (typeof value !== "boolean")
|
|
142
|
-
fail(
|
|
183
|
+
fail(`${key} must be true or false`);
|
|
143
184
|
return value;
|
|
144
185
|
case "mcpd.port":
|
|
145
186
|
if (typeof value !== "number" || value < 1024 || value > 65535)
|
|
@@ -238,16 +279,52 @@ async function check(args, io) {
|
|
|
238
279
|
return failed ? 1 : 0;
|
|
239
280
|
}
|
|
240
281
|
export const command = group("config", "read and change config.toml without losing its comments; check every config file", {
|
|
241
|
-
path: {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
282
|
+
path: {
|
|
283
|
+
summary: "where each config and state file lives (--all: every path turno uses)",
|
|
284
|
+
synopsis: "[--all] [--json]",
|
|
285
|
+
flags: flagsOf(PATH_FLAGS),
|
|
286
|
+
json: PATH_JSON,
|
|
287
|
+
details: "--all adds the logs, tokens, caches, service file, launchers, each agent's\nfolder and each profile's folder and launcher, with what turno keeps there.\nThe paths only, never what is in them.",
|
|
288
|
+
run: path,
|
|
289
|
+
},
|
|
290
|
+
get: {
|
|
291
|
+
summary: "print a value (the whole file as JSON without a key)",
|
|
292
|
+
synopsis: "[key] [--json]",
|
|
293
|
+
args: ["key"],
|
|
294
|
+
flags: ["--json"],
|
|
295
|
+
run: get,
|
|
296
|
+
},
|
|
297
|
+
set: {
|
|
298
|
+
summary: "set a value, checked like profile add checks it",
|
|
299
|
+
synopsis: "<key> <value> [--dry-run]",
|
|
300
|
+
args: ["key", "any"],
|
|
301
|
+
flags: flagsOf(SET_SPEC),
|
|
302
|
+
run: set,
|
|
303
|
+
},
|
|
304
|
+
unset: {
|
|
305
|
+
summary: "remove a value",
|
|
306
|
+
synopsis: "<key> [--dry-run]",
|
|
307
|
+
args: ["key"],
|
|
308
|
+
flags: ["--dry-run"],
|
|
309
|
+
run: unset,
|
|
310
|
+
},
|
|
245
311
|
edit: { summary: "open config.toml in $VISUAL or $EDITOR, then check it", run: edit },
|
|
246
312
|
check: { summary: "parse config.toml, mcp.toml and accounts.toml", run: check },
|
|
247
313
|
}, {
|
|
248
314
|
fallback: "path",
|
|
249
315
|
footer: `Keys:\n${columns(Object.entries(KEYS), 2, 26)}\n\nProjects use turno profile assign; MCP servers live in mcp.toml (turno mcp).
|
|
250
316
|
A [[projects]] rule with mcp = [...] limits the servers of that folder.`,
|
|
317
|
+
examples: [
|
|
318
|
+
"turno config path --json",
|
|
319
|
+
"turno config path --all",
|
|
320
|
+
"turno config get default",
|
|
321
|
+
"turno config get mcpd --json",
|
|
322
|
+
"turno config set default work",
|
|
323
|
+
"turno config set icons unicode --dry-run",
|
|
324
|
+
"turno config unset fallback",
|
|
325
|
+
"turno config edit",
|
|
326
|
+
"turno config check",
|
|
327
|
+
],
|
|
251
328
|
});
|
|
252
329
|
export const CONFIG_KEYS = Object.keys(KEYS);
|
|
253
330
|
//# sourceMappingURL=config.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync, } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
@@ -12,7 +12,7 @@ import { findOnPath } from "../launchers.js";
|
|
|
12
12
|
import { setupProfiles } from "./setup.js";
|
|
13
13
|
import { pidAlive } from "../../core/fsutil.js";
|
|
14
14
|
/**
|
|
15
|
-
* `turno demo
|
|
15
|
+
* `turno demo`: turno in a throwaway HOME under the OS temp folder, with two Claude
|
|
16
16
|
* Code profiles, a folder rule, two MCP servers behind an mcpd on a free port, and the status
|
|
17
17
|
* line. It never reads or writes the person's own HOME, never signs in, needs no global install
|
|
18
18
|
* (it works from npx's cache), and always stops mcpd and removes the folder when it ends.
|
|
@@ -21,7 +21,21 @@ const PREFIX = "turno-demo-";
|
|
|
21
21
|
/** A file in every demo HOME with the PID of the demo that owns it. */
|
|
22
22
|
const OWNER = ".turno-demo";
|
|
23
23
|
/** Variables a demo session keeps from the caller: terminal and locale, never config or tokens. */
|
|
24
|
-
const KEEP = [
|
|
24
|
+
const KEEP = [
|
|
25
|
+
"PATH",
|
|
26
|
+
"TERM",
|
|
27
|
+
"COLORTERM",
|
|
28
|
+
"TERM_PROGRAM",
|
|
29
|
+
"LANG",
|
|
30
|
+
"LC_ALL",
|
|
31
|
+
"LC_CTYPE",
|
|
32
|
+
"TMPDIR",
|
|
33
|
+
"USER",
|
|
34
|
+
"LOGNAME",
|
|
35
|
+
"SHELL",
|
|
36
|
+
"COLUMNS",
|
|
37
|
+
"NO_COLOR",
|
|
38
|
+
];
|
|
25
39
|
/** The env of everything that runs inside the demo: the demo HOME, its launchers first on PATH. */
|
|
26
40
|
export function demoEnv(base, home) {
|
|
27
41
|
const env = {};
|
|
@@ -84,7 +98,12 @@ function manifestText(server) {
|
|
|
84
98
|
return lines.join("\n");
|
|
85
99
|
}
|
|
86
100
|
function configText() {
|
|
87
|
-
const lines = [
|
|
101
|
+
const lines = [
|
|
102
|
+
"# turno demo: ~/code/acme opens with the work profile, every other folder with personal.",
|
|
103
|
+
'default = "personal"',
|
|
104
|
+
'icons = "unicode"',
|
|
105
|
+
"",
|
|
106
|
+
];
|
|
88
107
|
for (const p of PROFILES)
|
|
89
108
|
lines.push(`[profiles.${p.name}]`, `color = "${p.color}"`, "");
|
|
90
109
|
lines.push("[[projects]]", 'path = "~/code/acme"', 'profile = "work"', "");
|
|
@@ -97,7 +116,10 @@ function samplePayload(home, folder, now) {
|
|
|
97
116
|
workspace: { current_dir: join(home, folder), project_dir: join(home, folder) },
|
|
98
117
|
cost: { total_cost_usd: 0.42, total_lines_added: 120, total_lines_removed: 18 },
|
|
99
118
|
context_window: { used_percentage: 23, total_input_tokens: 46_000, context_window_size: 200_000 },
|
|
100
|
-
rate_limits: {
|
|
119
|
+
rate_limits: {
|
|
120
|
+
five_hour: { used_percentage: 38, resets_at: Math.trunc(now) + 2 * 3600 },
|
|
121
|
+
seven_day: { used_percentage: 12, resets_at: Math.trunc(now) + 4 * 86400 },
|
|
122
|
+
},
|
|
101
123
|
};
|
|
102
124
|
}
|
|
103
125
|
/** Build the demo HOME and start its gateway. The caller must call stop(). */
|
|
@@ -188,7 +210,10 @@ function intro(io, d) {
|
|
|
188
210
|
["turno undo --list", "every change turno made, each one undoable"],
|
|
189
211
|
];
|
|
190
212
|
if (findOnPath("claude", d.env))
|
|
191
|
-
rows.push([
|
|
213
|
+
rows.push([
|
|
214
|
+
"cd ~/code/acme && turno auto mcp list",
|
|
215
|
+
"Claude Code connects to both servers through mcpd (no sign-in)",
|
|
216
|
+
]);
|
|
192
217
|
// Commands up to 40 columns share one column; a longer one puts its note on the next line.
|
|
193
218
|
const w = Math.max(...rows.map(([c]) => c.length).filter((n) => n <= 40));
|
|
194
219
|
for (const [c, why] of rows) {
|
|
@@ -210,7 +235,11 @@ In a terminal it opens a shell in that HOME; exit the shell to end the demo. Wit
|
|
|
210
235
|
--, it runs that command in the demo instead. With --keep it waits for Ctrl-C instead, so you can
|
|
211
236
|
use the demo from another terminal. Without a terminal (a pipe, --no-input, an agent) and without
|
|
212
237
|
--keep it prints what it set up and ends. Either way it stops mcpd and removes the folder when it
|
|
213
|
-
ends. Works from npx: npx turno-cli demo
|
|
238
|
+
ends. Works from npx: npx turno-cli demo
|
|
239
|
+
|
|
240
|
+
Examples:
|
|
241
|
+
$ turno demo
|
|
242
|
+
$ turno demo -- turno status`;
|
|
214
243
|
const KEEP_FLAG = { keep: { type: "boolean" } };
|
|
215
244
|
/** Run the demo: a shell, a command, or a wait for Ctrl-C. Returns the exit code. */
|
|
216
245
|
export async function runDemo(args, io, opts = {}) {
|