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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { loadConfig } from "../../core/config.js";
|
|
2
2
|
import { tildify } from "../../core/paths.js";
|
|
3
3
|
import { displayName, liveSessions } from "../../core/sessions.js";
|
|
4
|
-
import { JSON_FLAG, bool, parseFlags
|
|
4
|
+
import { JSON_FLAG, bool, parseFlags } from "../args.js";
|
|
5
|
+
import { emit, jsonOutput } from "../output.js";
|
|
5
6
|
import { group } from "../group.js";
|
|
6
7
|
import { command as handoff } from "./handoff.js";
|
|
7
8
|
import { command as sessions } from "./sessions.js";
|
|
@@ -9,22 +10,29 @@ export function sessionsData(env) {
|
|
|
9
10
|
const config = loadConfig(env);
|
|
10
11
|
return liveSessions(env, config).map((s) => ({
|
|
11
12
|
name: displayName(s),
|
|
12
|
-
profile: s.source === "record" ? (s.profile ?? null) : s.source === "desktop" ? null :
|
|
13
|
+
profile: s.source === "record" ? (s.profile ?? null) : s.source === "desktop" ? null : config.system || null,
|
|
13
14
|
source: s.source,
|
|
14
15
|
status: s.status,
|
|
15
16
|
cwd: s.cwd,
|
|
16
17
|
}));
|
|
17
18
|
}
|
|
19
|
+
const LIST_JSON = jsonOutput(["name", "profile", "source", "status", "cwd"]);
|
|
18
20
|
async function list(args, io) {
|
|
19
21
|
const p = parseFlags(args, JSON_FLAG, 0);
|
|
20
22
|
if (bool(p, "json")) {
|
|
21
|
-
|
|
23
|
+
emit(io, p, LIST_JSON, sessionsData(io.env).map((s) => ({ ...s, cwd: tildify(s.cwd, io.env) })));
|
|
22
24
|
return 0;
|
|
23
25
|
}
|
|
24
26
|
return sessions.run([], io);
|
|
25
27
|
}
|
|
26
28
|
export const command = group("session", "live Claude Code sessions, and moving one to another account", {
|
|
27
|
-
list: {
|
|
29
|
+
list: {
|
|
30
|
+
summary: "live sessions and the account of each",
|
|
31
|
+
synopsis: "[--json]",
|
|
32
|
+
flags: ["--json"],
|
|
33
|
+
json: LIST_JSON,
|
|
34
|
+
run: list,
|
|
35
|
+
},
|
|
28
36
|
handoff: {
|
|
29
37
|
summary: "print the command that continues or forks this session under another profile",
|
|
30
38
|
synopsis: "[profile|auto] [--fork] [--copy]",
|
|
@@ -32,5 +40,8 @@ export const command = group("session", "live Claude Code sessions, and moving o
|
|
|
32
40
|
flags: ["--fork", "--copy"],
|
|
33
41
|
run: (args, io) => handoff.run(args, io),
|
|
34
42
|
},
|
|
35
|
-
}, {
|
|
43
|
+
}, {
|
|
44
|
+
fallback: "list",
|
|
45
|
+
examples: ["turno session list", "turno session handoff personal", "turno session handoff work --fork --copy"],
|
|
46
|
+
});
|
|
36
47
|
//# sourceMappingURL=session.js.map
|
|
@@ -37,7 +37,13 @@ export const command = {
|
|
|
37
37
|
// Claude Code writes procStart in UTC; a reading in the future means it is local time.
|
|
38
38
|
const began = start ? (start.utc <= now + 60_000 ? start.utc : start.local) : undefined;
|
|
39
39
|
const status = x.status === "busy" ? s.warn(x.status) : x.status === "idle" ? s.ok(x.status) : x.status;
|
|
40
|
-
return [
|
|
40
|
+
return [
|
|
41
|
+
s.bold(displayName(x)),
|
|
42
|
+
account,
|
|
43
|
+
status,
|
|
44
|
+
s.muted(began !== undefined ? age(now - began) : "?"),
|
|
45
|
+
s.muted(tildify(x.cwd, io.env)),
|
|
46
|
+
];
|
|
41
47
|
});
|
|
42
48
|
if (rows.length === 0) {
|
|
43
49
|
io.out("No live sessions.");
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readlinkSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { join, resolve as resolvePath } from "node:path";
|
|
3
3
|
import { DEFAULT_AGENT, adapter, agentHub, agentProfileDir } from "../../agents/index.js";
|
|
4
4
|
import { isValidProfileName, loadConfig } from "../../core/config.js";
|
|
5
5
|
import { Journal, stamp } from "../../core/journal.js";
|
|
6
|
-
import { tildify } from "../../core/paths.js";
|
|
6
|
+
import { expandHome, tildify } from "../../core/paths.js";
|
|
7
7
|
import { agentOf } from "../../core/profiles.js";
|
|
8
8
|
import { profileBusy } from "../../core/sessions.js";
|
|
9
9
|
import { fail, plural } from "../io.js";
|
|
@@ -11,12 +11,53 @@ import { style } from "../style.js";
|
|
|
11
11
|
import { launcherName, refuseNpx, resolveTurnoCommand, writeHelperLaunchers, writeLauncher } from "../launchers.js";
|
|
12
12
|
/** Names a profile cannot take: every command, alias and legacy word. */
|
|
13
13
|
export const RESERVED = new Set([
|
|
14
|
-
"auto",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
14
|
+
"auto",
|
|
15
|
+
"which",
|
|
16
|
+
"resolve",
|
|
17
|
+
"sessions",
|
|
18
|
+
"usage",
|
|
19
|
+
"exhausted",
|
|
20
|
+
"available",
|
|
21
|
+
"hook",
|
|
22
|
+
"setup",
|
|
23
|
+
"status",
|
|
24
|
+
"open",
|
|
25
|
+
"migrate",
|
|
26
|
+
"doctor",
|
|
27
|
+
"statusline",
|
|
28
|
+
"handoff",
|
|
29
|
+
"mcp",
|
|
30
|
+
"mcpd",
|
|
31
|
+
"secret",
|
|
32
|
+
"accounts",
|
|
33
|
+
"browser",
|
|
34
|
+
"ui",
|
|
35
|
+
"help",
|
|
36
|
+
"version",
|
|
37
|
+
"cuenta",
|
|
38
|
+
"resolver",
|
|
39
|
+
"sesiones",
|
|
40
|
+
"uso",
|
|
41
|
+
"agotada",
|
|
42
|
+
"disponible",
|
|
43
|
+
"limite",
|
|
44
|
+
"abrir",
|
|
45
|
+
"sync-mcp",
|
|
46
|
+
"profile",
|
|
47
|
+
"navegador",
|
|
48
|
+
"run",
|
|
49
|
+
"limit",
|
|
50
|
+
"session",
|
|
51
|
+
"identity",
|
|
52
|
+
"config",
|
|
53
|
+
"undo",
|
|
54
|
+
"upgrade",
|
|
55
|
+
"completion",
|
|
56
|
+
"__complete",
|
|
57
|
+
"__update-check",
|
|
58
|
+
"uninstall",
|
|
59
|
+
"init",
|
|
60
|
+
"demo",
|
|
20
61
|
]);
|
|
21
62
|
export function checkName(name) {
|
|
22
63
|
if (!isValidProfileName(name))
|
|
@@ -43,7 +84,7 @@ function ownCopy(path) {
|
|
|
43
84
|
}
|
|
44
85
|
/**
|
|
45
86
|
* Make <dir>/<item> a symlink to the hub, moving a local copy aside. Every step goes through
|
|
46
|
-
* the journal, so `turno undo` removes the link and moves the copy back
|
|
87
|
+
* the journal, so `turno undo` removes the link and moves the copy back.
|
|
47
88
|
*/
|
|
48
89
|
function linkItem(dir, item, aside, journal, hub) {
|
|
49
90
|
const target = join(hub, item);
|
|
@@ -85,7 +126,12 @@ function writeOwn(file, text, journal) {
|
|
|
85
126
|
function sharedItems(name, agent, env) {
|
|
86
127
|
const a = adapter(agent);
|
|
87
128
|
const hub = agentHub(agent, env);
|
|
88
|
-
return {
|
|
129
|
+
return {
|
|
130
|
+
dir: agentProfileDir(name, agent, env),
|
|
131
|
+
hub,
|
|
132
|
+
dirs: [...a.sharedDirs],
|
|
133
|
+
files: a.sharedFiles.filter((f) => existsSync(join(hub, f))),
|
|
134
|
+
};
|
|
89
135
|
}
|
|
90
136
|
/**
|
|
91
137
|
* The person's own files that setting up `names` would move to .aside-<stamp>/, so a command
|
|
@@ -118,7 +164,7 @@ function reportLinks(name, label, dir, hub, results, aside, io, verbose, brief =
|
|
|
118
164
|
}
|
|
119
165
|
}
|
|
120
166
|
/**
|
|
121
|
-
* Set up one profile: its folder (0700), the hub links, the agent's own steps
|
|
167
|
+
* Set up one profile: its folder (0700), the hub links, the agent's own steps and
|
|
122
168
|
* its launcher. Local copies of shared items move to .aside-<stamp>/.
|
|
123
169
|
*/
|
|
124
170
|
function setupProfile(name, agent, io, verbose, journal, config, brief = false) {
|
|
@@ -155,9 +201,35 @@ function setupProfile(name, agent, io, verbose, journal, config, brief = false)
|
|
|
155
201
|
for (const why of held)
|
|
156
202
|
io.out(st.wrap(` ${st.warn("!")} `, why));
|
|
157
203
|
a.setup?.after?.(step);
|
|
204
|
+
a.ruleFolders?.({ ...step, folders: ruleFolders(name, config, io.env) });
|
|
158
205
|
writeLauncher(name, io.env, agent, journal);
|
|
159
206
|
io.out(` ${st.ok("+")} command ${st.bold(launcherName(name, agent))}`);
|
|
160
207
|
}
|
|
208
|
+
/** The absolute folders whose `[[projects]]` rules name `profile`. */
|
|
209
|
+
function ruleFolders(profile, config, env) {
|
|
210
|
+
return [
|
|
211
|
+
...new Set(config.projects.filter((r) => r.profile === profile).map((r) => resolvePath(expandHome(r.path, env)))),
|
|
212
|
+
];
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The agent's per-folder setup for `profile`'s rules, after `turno profile assign`
|
|
216
|
+
* changed them. Nothing for agents without a `ruleFolders` hook.
|
|
217
|
+
*/
|
|
218
|
+
export function applyRuleFolders(profile, io, journal) {
|
|
219
|
+
const config = loadConfig(io.env);
|
|
220
|
+
const agent = agentOf(profile, config);
|
|
221
|
+
const hook = adapter(agent).ruleFolders;
|
|
222
|
+
if (!hook)
|
|
223
|
+
return;
|
|
224
|
+
hook({
|
|
225
|
+
name: profile,
|
|
226
|
+
dir: agentProfileDir(profile, agent, io.env),
|
|
227
|
+
folders: ruleFolders(profile, config, io.env),
|
|
228
|
+
env: io.env,
|
|
229
|
+
out: (line) => io.out(line),
|
|
230
|
+
writeOwn: (file, text) => writeOwn(file, text, journal),
|
|
231
|
+
});
|
|
232
|
+
}
|
|
161
233
|
export function setupProfiles(names, io, opts = {}) {
|
|
162
234
|
if (names.length === 0)
|
|
163
235
|
fail("usage: turno profile repair <profile>...");
|
|
@@ -9,13 +9,14 @@ import { packageInfo } from "../../core/version.js";
|
|
|
9
9
|
import { FALLBACK, checkFonts, userFontDir } from "../../ui/fonts.js";
|
|
10
10
|
import { currentStatusLine, isTurnoStatusLine, statusLineLabel } from "../../ui/settings.js";
|
|
11
11
|
import { currentTerminal, nerdHere } from "../../ui/terminal-id.js";
|
|
12
|
-
import { JSON_FLAG, bool, parseFlags
|
|
12
|
+
import { JSON_FLAG, bool, parseFlags } from "../args.js";
|
|
13
|
+
import { emit, jsonOutput } from "../output.js";
|
|
13
14
|
import { plural } from "../io.js";
|
|
14
15
|
import { profileColor, style, visibleWidth } from "../style.js";
|
|
15
16
|
import { mcpdStatus } from "./doctor.js";
|
|
16
17
|
import { DEFAULT_AGENT, adapter } from "../../agents/index.js";
|
|
17
18
|
import { limitsData } from "./limit.js";
|
|
18
|
-
import { profilesData, resolveAll, usingText } from "./profile.js";
|
|
19
|
+
import { NO_DEFAULT_ACCOUNT, profilesData, resolveAll, usingText } from "./profile.js";
|
|
19
20
|
import { sessionsData } from "./session.js";
|
|
20
21
|
import { shortTime } from "./usage.js";
|
|
21
22
|
/** Servers in mcp.toml, or 0 when it is missing or unreadable (turno mcp list shows why). */
|
|
@@ -48,10 +49,16 @@ async function nextStep(env, d) {
|
|
|
48
49
|
return { command: "turno init", why: "no profiles yet; init finds your agents, folders and MCP servers" };
|
|
49
50
|
const notSetUp = d.profiles.find((x) => !x.setUp);
|
|
50
51
|
if (notSetUp)
|
|
51
|
-
return {
|
|
52
|
+
return {
|
|
53
|
+
command: `turno profile repair ${notSetUp.name}`,
|
|
54
|
+
why: `profile ${notSetUp.name} has no folder or launcher yet`,
|
|
55
|
+
};
|
|
52
56
|
const servers = manifestServers(env);
|
|
53
57
|
if (servers && !d.mcpd.running)
|
|
54
|
-
return {
|
|
58
|
+
return {
|
|
59
|
+
command: "turno mcp daemon start",
|
|
60
|
+
why: `mcp.toml has ${plural(servers, "server")} and the gateway is not running`,
|
|
61
|
+
};
|
|
55
62
|
if (servers) {
|
|
56
63
|
const pending = await syncPending(env);
|
|
57
64
|
if (pending)
|
|
@@ -70,7 +77,11 @@ export async function statusData(env, cwd = process.cwd()) {
|
|
|
70
77
|
}
|
|
71
78
|
async function statusBase(env, cwd) {
|
|
72
79
|
const config = loadConfig(env);
|
|
73
|
-
const [profiles, limits, mcpd] = await Promise.all([
|
|
80
|
+
const [profiles, limits, mcpd] = await Promise.all([
|
|
81
|
+
profilesData(env, config),
|
|
82
|
+
limitsData(env, false),
|
|
83
|
+
mcpdStatus(env, config),
|
|
84
|
+
]);
|
|
74
85
|
const all = resolveAll(cwd, config, env);
|
|
75
86
|
const here = all[0].r;
|
|
76
87
|
const sessions = sessionsData(env);
|
|
@@ -90,7 +101,7 @@ async function statusBase(env, cwd) {
|
|
|
90
101
|
chosen: here.chosen || null,
|
|
91
102
|
reason: here.reason,
|
|
92
103
|
note: here.note || null,
|
|
93
|
-
agents: Object.fromEntries(all.map(({ agent, r }) => [agent, { chosen: r.chosen || null, text: usingText(agent, r, env) }])),
|
|
104
|
+
agents: Object.fromEntries(all.map(({ agent, r }) => [agent, { chosen: r.chosen || null, text: usingText(agent, r, env, config) }])),
|
|
94
105
|
},
|
|
95
106
|
profiles: profiles.map((p) => {
|
|
96
107
|
const l = limits.find((x) => x.profile === p.name);
|
|
@@ -128,7 +139,11 @@ export function renderStatus(d, io, opts = {}) {
|
|
|
128
139
|
const s = style(io, { nerd: d.look.icons === "nerd" });
|
|
129
140
|
const pill = (name) => s.profile(name, opts.colors ? profileColor(opts.colors, name) : undefined);
|
|
130
141
|
const out = [];
|
|
131
|
-
|
|
142
|
+
// system = "" leaves plain claude without an account: say so rather than "plain claude".
|
|
143
|
+
const plain = d.here.agents[DEFAULT_AGENT]?.text.startsWith(NO_DEFAULT_ACCOUNT)
|
|
144
|
+
? s.warn("no profile")
|
|
145
|
+
: "plain claude";
|
|
146
|
+
const using = d.here.chosen ? pill(d.here.chosen) : plain;
|
|
132
147
|
out.push(s.wrap(`${s.bold(s.accent("turno"))} ${s.muted(d.version)} `, `${d.here.dir} ${s.icon("arrow")} ${using}`));
|
|
133
148
|
if (d.update)
|
|
134
149
|
out.push(s.warn(`${s.icon("info")} turno ${d.update} is available: turno upgrade`));
|
|
@@ -137,7 +152,13 @@ export function renderStatus(d, io, opts = {}) {
|
|
|
137
152
|
// Here: what each agent opens in this folder.
|
|
138
153
|
out.push("", s.header("Here"));
|
|
139
154
|
const why = d.here.note ? `${d.here.assigned} ${d.here.note}` : d.here.reason;
|
|
140
|
-
const here = [
|
|
155
|
+
const here = [
|
|
156
|
+
[
|
|
157
|
+
s.muted(DEFAULT_AGENT),
|
|
158
|
+
d.here.chosen ? pill(d.here.chosen) : plain,
|
|
159
|
+
s.muted(plain === "plain claude" ? why : `${why}; system = "" (turno auto exits 3)`),
|
|
160
|
+
],
|
|
161
|
+
];
|
|
141
162
|
for (const [agent, a] of Object.entries(d.here.agents)) {
|
|
142
163
|
if (agent === DEFAULT_AGENT)
|
|
143
164
|
continue;
|
|
@@ -158,10 +179,24 @@ export function renderStatus(d, io, opts = {}) {
|
|
|
158
179
|
};
|
|
159
180
|
const rows = [["", s.muted("5 hours"), "", s.muted("week"), "", s.muted("account")]];
|
|
160
181
|
for (const x of d.profiles) {
|
|
161
|
-
const who = !x.setUp
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
182
|
+
const who = !x.setUp
|
|
183
|
+
? s.warn("not set up")
|
|
184
|
+
: !adapter(x.agent).accountDetails
|
|
185
|
+
? adapter(x.agent).label
|
|
186
|
+
: x.email
|
|
187
|
+
? x.email
|
|
188
|
+
: s.warn("not logged in");
|
|
189
|
+
const flags = [...x.roles, x.exhaustedUntil ? `exhausted until ${shortTime(x.exhaustedUntil)}` : ""]
|
|
190
|
+
.filter(Boolean)
|
|
191
|
+
.join(", ");
|
|
192
|
+
const usage = adapter(x.agent).accountDetails
|
|
193
|
+
? [...win(x.fiveHour), ...win(x.week)]
|
|
194
|
+
: [s.muted("-"), "", s.muted("-"), ""];
|
|
195
|
+
rows.push([
|
|
196
|
+
pill(x.name),
|
|
197
|
+
...usage,
|
|
198
|
+
`${who}${x.plan ? s.muted(` · ${x.plan}`) : ""}${flags ? s.muted(` ${flags}`) : ""}`,
|
|
199
|
+
]);
|
|
165
200
|
}
|
|
166
201
|
out.push(...s.table(rows, { columns: [{}, {}, { drop: 3 }, {}, { drop: 4 }, {}] }));
|
|
167
202
|
}
|
|
@@ -178,7 +213,11 @@ export function renderStatus(d, io, opts = {}) {
|
|
|
178
213
|
: d.look.statusLine
|
|
179
214
|
? `status line ${statusLineLabel({ type: "command", command: d.look.statusLine }, io.env, 40)}`
|
|
180
215
|
: "no status line";
|
|
181
|
-
const look = [
|
|
216
|
+
const look = [
|
|
217
|
+
lineText,
|
|
218
|
+
d.look.font ? "font installed" : `font missing ${s.muted("(turno ui install)")}`,
|
|
219
|
+
`${d.look.icons} icons here`,
|
|
220
|
+
].join(s.muted(" · "));
|
|
182
221
|
out.push(s.kv("gateway", gateway, 8));
|
|
183
222
|
for (const problem of d.mcpd.problems)
|
|
184
223
|
out.push(s.wrap(` ${" ".repeat(8)} ${s.warn(s.icon("warn"))} `, s.warn(problem)));
|
|
@@ -195,15 +234,28 @@ function nextLines(s, next) {
|
|
|
195
234
|
const pad = " ".repeat(visibleWidth(label) + 2);
|
|
196
235
|
return [s.wrap(`${label} `, s.bold(next.command)), s.wrap(pad, s.muted(next.why))];
|
|
197
236
|
}
|
|
237
|
+
/** `turno status --json`. */
|
|
238
|
+
const STATUS_JSON = jsonOutput([
|
|
239
|
+
"version",
|
|
240
|
+
"update",
|
|
241
|
+
"migrationPending",
|
|
242
|
+
"here",
|
|
243
|
+
"profiles",
|
|
244
|
+
"sessions",
|
|
245
|
+
"mcpd",
|
|
246
|
+
"look",
|
|
247
|
+
"next",
|
|
248
|
+
]);
|
|
198
249
|
export const command = {
|
|
199
250
|
summary: "one screen with everything: this folder, profiles and usage, sessions, mcpd and the look",
|
|
200
|
-
usage: "Usage: turno status [--json]\n\nturno doctor checks each part in depth and can fix problems
|
|
251
|
+
usage: "Usage: turno status [--json]\n\nturno doctor checks each part in depth and can fix problems.\n\nExamples:\n $ turno status\n $ turno status --json=here,mcpd",
|
|
201
252
|
flags: ["--json"],
|
|
253
|
+
json: STATUS_JSON,
|
|
202
254
|
async run(args, io) {
|
|
203
255
|
const p = parseFlags(args, JSON_FLAG, 0);
|
|
204
256
|
const d = await statusData(io.env);
|
|
205
257
|
if (bool(p, "json")) {
|
|
206
|
-
|
|
258
|
+
emit(io, p, STATUS_JSON, d);
|
|
207
259
|
return 0;
|
|
208
260
|
}
|
|
209
261
|
let profiles = {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
|
-
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { loadConfig } from "../../core/config.js";
|
|
@@ -206,7 +206,11 @@ function turnHistory(cache, sid, promptId, five) {
|
|
|
206
206
|
function gitSpawn(cwd) {
|
|
207
207
|
const git = (args) => {
|
|
208
208
|
try {
|
|
209
|
-
return execFileSync("git", ["--no-optional-locks", "-C", cwd, ...args], {
|
|
209
|
+
return execFileSync("git", ["--no-optional-locks", "-C", cwd, ...args], {
|
|
210
|
+
encoding: "utf8",
|
|
211
|
+
timeout: 3000,
|
|
212
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
213
|
+
}).trim();
|
|
210
214
|
}
|
|
211
215
|
catch {
|
|
212
216
|
return "";
|
|
@@ -306,6 +310,7 @@ const FALLBACK_CONFIG = {
|
|
|
306
310
|
icons: "auto",
|
|
307
311
|
nerdTerminals: [],
|
|
308
312
|
updateCheck: true,
|
|
313
|
+
hints: true,
|
|
309
314
|
profiles: {},
|
|
310
315
|
agents: {},
|
|
311
316
|
projects: [],
|
package/dist/cli/commands/ui.js
CHANGED
|
@@ -8,7 +8,7 @@ import { checkFonts, fontSource, installFonts, userFontDir } from "../../ui/font
|
|
|
8
8
|
import { currentStatusLine, isTurnoStatusLine, setStatusLine, withNerdTerminals } from "../../ui/settings.js";
|
|
9
9
|
import { Journal } from "../../core/journal.js";
|
|
10
10
|
import { BUILTIN_SYMBOLS, currentTerminal } from "../../ui/terminal-id.js";
|
|
11
|
-
import { TERMINALS, detectNerdTerminals, fontOf, installed, isNerdFamily, terminal } from "../../ui/terminals.js";
|
|
11
|
+
import { TERMINALS, detectNerdTerminals, fontOf, installed, isNerdFamily, terminal, } from "../../ui/terminals.js";
|
|
12
12
|
import { DRY_RUN, FORCE, bool, flagsOf, parseFlags } from "../args.js";
|
|
13
13
|
import { group } from "../group.js";
|
|
14
14
|
import { fail, paint } from "../io.js";
|
|
@@ -40,7 +40,10 @@ function parse(args) {
|
|
|
40
40
|
const p = parseFlags(args, INSTALL_SPEC, 0);
|
|
41
41
|
const values = p.values.terminal ?? [];
|
|
42
42
|
return {
|
|
43
|
-
terminals: values.flatMap((v) => v
|
|
43
|
+
terminals: values.flatMap((v) => v
|
|
44
|
+
.split(",")
|
|
45
|
+
.map((s) => s.trim())
|
|
46
|
+
.filter(Boolean)),
|
|
44
47
|
font: !bool(p, "no-font"),
|
|
45
48
|
statusline: !bool(p, "no-statusline"),
|
|
46
49
|
force: bool(p, "force"),
|
|
@@ -60,7 +63,9 @@ function chosenTerminals(values, env, platform) {
|
|
|
60
63
|
const id = v === "current" ? currentTerminal(env) : v;
|
|
61
64
|
const t = id ? terminal(id) : undefined;
|
|
62
65
|
if (!t)
|
|
63
|
-
fail(v === "current"
|
|
66
|
+
fail(v === "current"
|
|
67
|
+
? "could not tell which terminal this is; name it (warp, vscode, cursor, alacritty)"
|
|
68
|
+
: `unknown terminal '${v}'`);
|
|
64
69
|
out.set(t.id, t);
|
|
65
70
|
}
|
|
66
71
|
return [...out.values()];
|
|
@@ -73,7 +78,10 @@ export function statusLineInfo(env, self = process.argv[1]) {
|
|
|
73
78
|
if (self) {
|
|
74
79
|
try {
|
|
75
80
|
const real = tildify(realpathSync(self), env);
|
|
76
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
command: `${real} statusline`,
|
|
83
|
+
warning: `wrote an absolute path (${real}) because turno is not on your PATH; it breaks if you switch Node versions or move this copy`,
|
|
84
|
+
};
|
|
77
85
|
}
|
|
78
86
|
catch {
|
|
79
87
|
/* fall through */
|
|
@@ -270,5 +278,9 @@ export const command = group("ui", "the status line, its font and icons in every
|
|
|
270
278
|
details: INSTALL_HELP,
|
|
271
279
|
run: install,
|
|
272
280
|
},
|
|
273
|
-
}, {
|
|
281
|
+
}, {
|
|
282
|
+
fallback: "status",
|
|
283
|
+
footer: "turno ui install --help explains each option.",
|
|
284
|
+
examples: ["turno ui status", "turno ui install --dry-run", "turno ui install --terminal warp,vscode --no-font"],
|
|
285
|
+
});
|
|
274
286
|
//# sourceMappingURL=ui.js.map
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { PRUNE_DEFAULT_AGE_MS, PRUNE_DEFAULT_KEEP, listJournals, parseAge, pruneJournals, undoJournal } from "../../core/journal.js";
|
|
1
|
+
import { PRUNE_DEFAULT_AGE_MS, PRUNE_DEFAULT_KEEP, listJournals, parseAge, pruneJournals, undoJournal, } from "../../core/journal.js";
|
|
2
2
|
import { tildify } from "../../core/paths.js";
|
|
3
|
-
import { DRY_RUN, FORCE, JSON_FLAG, bool, count, parseFlags,
|
|
3
|
+
import { DRY_RUN, FORCE, JSON_FLAG, bool, count, parseFlags, str } from "../args.js";
|
|
4
4
|
import { fail, paint } from "../io.js";
|
|
5
|
+
import { emit, jsonOutput } from "../output.js";
|
|
5
6
|
import { duration, style } from "../style.js";
|
|
7
|
+
/** `undo --list --json` (one element per change) and `undo --prune --json`. */
|
|
8
|
+
const LIST_JSON = jsonOutput(["stamp", "command", "files", "undoneBy"]);
|
|
9
|
+
const PRUNE_JSON = jsonOutput(["dryRun", "pruned", "kept"]);
|
|
6
10
|
const USAGE = `Usage:
|
|
7
11
|
turno undo --list [-n N] [--json] recent changes, newest first
|
|
8
12
|
turno undo <stamp|last> [--dry-run] [--force] [-v]
|
|
@@ -26,7 +30,13 @@ turno uninstall is recorded the same way, so undo puts back what it removed.
|
|
|
26
30
|
Backups can hold secrets that were in those files, so they are private (folders
|
|
27
31
|
0700, files 0600) and pruned: each new backup deletes those older than 30 days,
|
|
28
32
|
keeping the newest 10. A backup that is still the only way back for a file it
|
|
29
|
-
changed (the file is unchanged since) is kept
|
|
33
|
+
changed (the file is unchanged since) is kept.
|
|
34
|
+
|
|
35
|
+
Examples:
|
|
36
|
+
$ turno undo --list
|
|
37
|
+
$ turno undo last --dry-run
|
|
38
|
+
$ turno undo 20261117-101500
|
|
39
|
+
$ turno undo --prune --older-than 30d`;
|
|
30
40
|
function prune(p, io) {
|
|
31
41
|
let olderThanMs = PRUNE_DEFAULT_AGE_MS;
|
|
32
42
|
const age = str(p, "older-than");
|
|
@@ -45,7 +55,11 @@ function prune(p, io) {
|
|
|
45
55
|
const dry = bool(p, "dry-run");
|
|
46
56
|
const r = pruneJournals(io.env, { olderThanMs, keep, dryRun: dry });
|
|
47
57
|
if (bool(p, "json")) {
|
|
48
|
-
|
|
58
|
+
emit(io, p, PRUNE_JSON, {
|
|
59
|
+
dryRun: dry,
|
|
60
|
+
pruned: r.pruned,
|
|
61
|
+
kept: r.kept.map((k) => ({ stamp: k.stamp, path: tildify(k.path, io.env) })),
|
|
62
|
+
});
|
|
49
63
|
return 0;
|
|
50
64
|
}
|
|
51
65
|
const verb = dry ? "would delete" : "deleted";
|
|
@@ -128,7 +142,9 @@ function describe(j, io) {
|
|
|
128
142
|
const m = j.manifest;
|
|
129
143
|
const undone = m.undoneBy ? paint(io, ` undone by ${m.undoneBy}`, "2") : "";
|
|
130
144
|
const n = m.entries.length;
|
|
131
|
-
const what = m.entries.every((e) => (e.kind ?? "file") === "file")
|
|
145
|
+
const what = m.entries.every((e) => (e.kind ?? "file") === "file")
|
|
146
|
+
? `${n} file${n === 1 ? "" : "s"}`
|
|
147
|
+
: `${n} change${n === 1 ? "" : "s"}`;
|
|
132
148
|
return `${j.stamp} ${m.command} (${what})${undone}`;
|
|
133
149
|
}
|
|
134
150
|
export const command = {
|
|
@@ -136,8 +152,19 @@ export const command = {
|
|
|
136
152
|
usage: USAGE,
|
|
137
153
|
args: ["stamp"],
|
|
138
154
|
flags: ["--list", "--verbose", "--dry-run", "--force", "--json", "--tail", "--prune", "--older-than", "--keep"],
|
|
155
|
+
json: jsonOutput([...LIST_JSON.fields, ...PRUNE_JSON.fields]),
|
|
139
156
|
async run(args, io) {
|
|
140
|
-
const p = parseFlags(args, {
|
|
157
|
+
const p = parseFlags(args, {
|
|
158
|
+
list: { type: "boolean" },
|
|
159
|
+
prune: { type: "boolean" },
|
|
160
|
+
verbose: { type: "boolean", short: "v" },
|
|
161
|
+
"older-than": { type: "string" },
|
|
162
|
+
keep: { type: "string" },
|
|
163
|
+
...DRY_RUN,
|
|
164
|
+
...FORCE,
|
|
165
|
+
...JSON_FLAG,
|
|
166
|
+
tail: { type: "string", short: "n" },
|
|
167
|
+
}, 1);
|
|
141
168
|
if (bool(p, "prune")) {
|
|
142
169
|
if (p.positionals.length)
|
|
143
170
|
return fail("--prune takes no stamp");
|
|
@@ -150,7 +177,12 @@ export const command = {
|
|
|
150
177
|
if (bool(p, "list") || !target) {
|
|
151
178
|
const shown = all.slice(0, count(p, "tail", 10));
|
|
152
179
|
if (bool(p, "json")) {
|
|
153
|
-
|
|
180
|
+
emit(io, p, LIST_JSON, shown.map((j) => ({
|
|
181
|
+
stamp: j.stamp,
|
|
182
|
+
command: j.manifest?.command ?? null,
|
|
183
|
+
files: j.manifest?.entries.map((e) => tildify(e.path, io.env)) ?? null,
|
|
184
|
+
undoneBy: j.manifest?.undoneBy ?? null,
|
|
185
|
+
})));
|
|
154
186
|
return 0;
|
|
155
187
|
}
|
|
156
188
|
if (!shown.length)
|
|
@@ -16,7 +16,7 @@ import { confirm, needsAnswer } from "../io.js";
|
|
|
16
16
|
import { MARKER } from "../launchers.js";
|
|
17
17
|
import { realOr } from "../../core/fsutil.js";
|
|
18
18
|
/**
|
|
19
|
-
* `turno uninstall
|
|
19
|
+
* `turno uninstall`: remove everything turno set up outside its package, through
|
|
20
20
|
* one journal, so `turno undo <stamp>` puts it back while turno is still installed. It never
|
|
21
21
|
* deletes a profile folder (they hold logins), turno's backups, or anything turno did not write.
|
|
22
22
|
*/
|
|
@@ -46,7 +46,11 @@ folders still stay.
|
|
|
46
46
|
--dry-run print the list and change nothing
|
|
47
47
|
--yes do not ask (needed when there is no terminal to ask in)
|
|
48
48
|
--keep-config keep ~/.config/turno
|
|
49
|
-
--purge remove turno's state and caches too (no undo)
|
|
49
|
+
--purge remove turno's state and caches too (no undo)
|
|
50
|
+
|
|
51
|
+
Examples:
|
|
52
|
+
$ turno uninstall --dry-run
|
|
53
|
+
$ turno uninstall --yes --keep-config`;
|
|
50
54
|
function lstat(p) {
|
|
51
55
|
try {
|
|
52
56
|
return lstatSync(p);
|
|
@@ -67,7 +71,9 @@ function safeConfig(env) {
|
|
|
67
71
|
function serverNames(file) {
|
|
68
72
|
try {
|
|
69
73
|
const text = readFileSync(file, "utf8");
|
|
70
|
-
const servers = file.endsWith(".toml")
|
|
74
|
+
const servers = file.endsWith(".toml")
|
|
75
|
+
? parseToml(text).mcp_servers
|
|
76
|
+
: JSON.parse(text).mcpServers;
|
|
71
77
|
return servers && typeof servers === "object" ? Object.keys(servers) : [];
|
|
72
78
|
}
|
|
73
79
|
catch {
|
|
@@ -159,7 +165,15 @@ function purgeable(path, home) {
|
|
|
159
165
|
}
|
|
160
166
|
export async function planUninstall(env, opts = {}) {
|
|
161
167
|
const p = paths(env);
|
|
162
|
-
const plan = {
|
|
168
|
+
const plan = {
|
|
169
|
+
configs: [],
|
|
170
|
+
launchers: [],
|
|
171
|
+
completions: [],
|
|
172
|
+
profileTokens: [],
|
|
173
|
+
purge: [],
|
|
174
|
+
manual: [],
|
|
175
|
+
kept: [],
|
|
176
|
+
};
|
|
163
177
|
// Only a service whose file is in this HOME: never ask the service manager about one it is not.
|
|
164
178
|
const { installedBackend } = await import("../../mcpd/service.js");
|
|
165
179
|
const backend = await installedBackend(env);
|
|
@@ -408,7 +422,12 @@ export const command = {
|
|
|
408
422
|
usage: USAGE,
|
|
409
423
|
flags: ["--dry-run", "--yes", "--keep-config", "--purge"],
|
|
410
424
|
async run(args, io) {
|
|
411
|
-
const p = parseFlags(args, {
|
|
425
|
+
const p = parseFlags(args, {
|
|
426
|
+
...DRY_RUN,
|
|
427
|
+
yes: { type: "boolean", short: "y" },
|
|
428
|
+
"keep-config": { type: "boolean" },
|
|
429
|
+
purge: { type: "boolean" },
|
|
430
|
+
}, 0);
|
|
412
431
|
const dry = bool(p, "dry-run");
|
|
413
432
|
const plan = await planUninstall(io.env, { keepConfig: bool(p, "keep-config"), purge: bool(p, "purge") });
|
|
414
433
|
const remove = describe(plan, io.env);
|