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.
Files changed (121) hide show
  1. package/CHANGELOG.md +432 -0
  2. package/README.md +228 -73
  3. package/dist/accounts/audit.js +154 -12
  4. package/dist/accounts/builtin.js +100 -25
  5. package/dist/accounts/delegate.js +199 -35
  6. package/dist/accounts/policy.js +79 -0
  7. package/dist/accounts/registry.js +39 -21
  8. package/dist/agents/adapter.js +29 -0
  9. package/dist/agents/claude.js +246 -0
  10. package/dist/agents/codex.js +186 -0
  11. package/dist/agents/copilot.js +56 -0
  12. package/dist/agents/cursor.js +58 -0
  13. package/dist/agents/index.js +26 -86
  14. package/dist/agents/snippets.js +43 -13
  15. package/dist/cli/args.js +38 -6
  16. package/dist/cli/commands/accounts.js +119 -52
  17. package/dist/cli/commands/auto.js +121 -33
  18. package/dist/cli/commands/browser-identity.js +514 -0
  19. package/dist/cli/commands/browser-session.js +102 -0
  20. package/dist/cli/commands/browser-vault.js +193 -0
  21. package/dist/cli/commands/browser.js +319 -138
  22. package/dist/cli/commands/complete.js +14 -3
  23. package/dist/cli/commands/completion.js +8 -2
  24. package/dist/cli/commands/config.js +186 -24
  25. package/dist/cli/commands/demo.js +321 -0
  26. package/dist/cli/commands/doctor.js +525 -123
  27. package/dist/cli/commands/handoff.js +33 -22
  28. package/dist/cli/commands/identity.js +192 -54
  29. package/dist/cli/commands/init.js +648 -0
  30. package/dist/cli/commands/limit.js +84 -16
  31. package/dist/cli/commands/mcp-call.js +240 -0
  32. package/dist/cli/commands/mcp-oauth.js +221 -0
  33. package/dist/cli/commands/mcp-observe.js +539 -0
  34. package/dist/cli/commands/mcp-share.js +201 -0
  35. package/dist/cli/commands/mcp.js +816 -187
  36. package/dist/cli/commands/mcpd.js +388 -76
  37. package/dist/cli/commands/migrate.js +6 -4
  38. package/dist/cli/commands/open.js +115 -27
  39. package/dist/cli/commands/profile.js +396 -78
  40. package/dist/cli/commands/resolve.js +14 -3
  41. package/dist/cli/commands/run.js +36 -6
  42. package/dist/cli/commands/secret.js +80 -76
  43. package/dist/cli/commands/session.js +17 -6
  44. package/dist/cli/commands/sessions.js +48 -12
  45. package/dist/cli/commands/setup.js +214 -164
  46. package/dist/cli/commands/status.js +227 -44
  47. package/dist/cli/commands/statusline.js +311 -114
  48. package/dist/cli/commands/ui.js +78 -68
  49. package/dist/cli/commands/undo.js +193 -18
  50. package/dist/cli/commands/uninstall.js +481 -0
  51. package/dist/cli/commands/upgrade.js +172 -79
  52. package/dist/cli/commands/usage.js +125 -51
  53. package/dist/cli/commands/version.js +21 -7
  54. package/dist/cli/commands/which.js +9 -24
  55. package/dist/cli/compile-cache.js +32 -0
  56. package/dist/cli/diagnostics.js +184 -0
  57. package/dist/cli/exit.js +65 -0
  58. package/dist/cli/group.js +24 -12
  59. package/dist/cli/help.js +62 -0
  60. package/dist/cli/highlight.js +236 -0
  61. package/dist/cli/hints.js +30 -0
  62. package/dist/cli/io.js +186 -1
  63. package/dist/cli/launch.js +52 -39
  64. package/dist/cli/launchers.js +161 -95
  65. package/dist/cli/main.js +201 -31
  66. package/dist/cli/optional.js +144 -0
  67. package/dist/cli/output.js +123 -0
  68. package/dist/cli/picker.js +459 -0
  69. package/dist/cli/registry.js +61 -6
  70. package/dist/cli/safe.js +87 -0
  71. package/dist/cli/secret-input.js +63 -0
  72. package/dist/cli/security.js +561 -0
  73. package/dist/cli/style.js +311 -0
  74. package/dist/cli/topics.js +142 -0
  75. package/dist/core/config.js +181 -23
  76. package/dist/core/exhausted.js +6 -8
  77. package/dist/core/fsutil.js +39 -0
  78. package/dist/core/journal.js +294 -16
  79. package/dist/core/manifest.js +153 -6
  80. package/dist/core/paths.js +14 -13
  81. package/dist/core/profiles.js +160 -10
  82. package/dist/core/resolve.js +139 -23
  83. package/dist/core/secrets.js +68 -23
  84. package/dist/core/sessions.js +13 -20
  85. package/dist/core/state-file.js +107 -0
  86. package/dist/core/update.js +31 -18
  87. package/dist/core/version.js +57 -10
  88. package/dist/demo/server.js +42 -0
  89. package/dist/mcpd/cache.js +23 -10
  90. package/dist/mcpd/calllog.js +254 -0
  91. package/dist/mcpd/client-names.js +46 -0
  92. package/dist/mcpd/connectors.js +188 -18
  93. package/dist/mcpd/daemon.js +472 -115
  94. package/dist/mcpd/folder-sets.js +42 -0
  95. package/dist/mcpd/gateway.js +473 -51
  96. package/dist/mcpd/health.js +313 -0
  97. package/dist/mcpd/importer.js +453 -36
  98. package/dist/mcpd/instances.js +453 -65
  99. package/dist/mcpd/jsonrpc.js +11 -1
  100. package/dist/mcpd/launchd.js +65 -48
  101. package/dist/mcpd/middleware.js +144 -0
  102. package/dist/mcpd/modern.js +686 -0
  103. package/dist/mcpd/oauth.js +845 -0
  104. package/dist/mcpd/peerpid.js +134 -6
  105. package/dist/mcpd/pressure.js +88 -0
  106. package/dist/mcpd/rss.js +166 -0
  107. package/dist/mcpd/service.js +191 -0
  108. package/dist/mcpd/share.js +217 -0
  109. package/dist/mcpd/state.js +183 -0
  110. package/dist/mcpd/sync.js +72 -87
  111. package/dist/mcpd/systemd.js +83 -0
  112. package/dist/mcpd/tokens.js +85 -0
  113. package/dist/mcpd/upstream.js +163 -46
  114. package/dist/statusline/cost.js +167 -44
  115. package/dist/statusline/input.js +78 -0
  116. package/dist/statusline/render.js +9 -3
  117. package/dist/ui/fonts.js +8 -3
  118. package/dist/ui/settings.js +33 -16
  119. package/npm-shrinkwrap.json +1102 -0
  120. package/package.json +10 -9
  121. package/dist/cli/commands/available.js +0 -18
@@ -1,55 +1,63 @@
1
- import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, readlinkSync, renameSync, rmSync, rmdirSync, symlinkSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
3
- import { adapter, agentHub, agentProfileDir } from "../../agents/index.js";
1
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readdirSync, readlinkSync, writeFileSync } from "node:fs";
2
+ import { join, resolve as resolvePath } from "node:path";
3
+ import { DEFAULT_AGENT, adapter, agentHub, agentProfileDir } from "../../agents/index.js";
4
4
  import { isValidProfileName, loadConfig } from "../../core/config.js";
5
- import { setValue } from "../../core/toml-edit.js";
6
- import { paths, profileDir, tildify } from "../../core/paths.js";
5
+ import { Journal, stamp } from "../../core/journal.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
- import { fail } from "../io.js";
10
- import { SHARED_DIRS, launcherName, turnoCommand, writeHelperLaunchers, writeLauncher } from "../launchers.js";
11
- export { SHARED_DIRS };
12
- /** Hub files shared by every profile (linked only when they exist in the hub). */
13
- export const SHARED_FILES = ["CLAUDE.md", "settings.json", "keybindings.json", "statusline-command.sh", ".mcp.json"];
14
- /**
15
- * Owned by each account and never linked. history.jsonl cannot be a symlink: Claude Code
16
- * ignores it unless it is a regular file with a single link.
17
- */
18
- export const PER_ACCOUNT = [
19
- ".claude.json",
20
- ".credentials.json",
21
- "history.jsonl",
22
- "backups",
23
- "daemon",
24
- "daemon.log",
25
- "daemon-auth-cooldown",
26
- "daemon-auth-status.json",
27
- "daemon.lock",
28
- "daemon.status.json",
29
- "feedback",
30
- "jobs",
31
- "policy-limits.json",
32
- "policy-limits.json.stamp.json",
33
- "policy-limits.json.signature.json",
34
- "remote-settings.json",
35
- "remote-settings.json.signature.json",
36
- "remote-settings.json.synced-at",
37
- "mcp-needs-auth-cache.json",
38
- "stats-cache.json",
39
- "telemetry",
40
- "shell-snapshots",
41
- "debug",
42
- ".last-cleanup",
43
- ".last-update-result.json",
44
- "computer-use.lock",
45
- ];
9
+ import { fail, plural } from "../io.js";
10
+ import { style } from "../style.js";
11
+ import { launcherName, refuseNpx, resolveTurnoCommand, writeHelperLaunchers, writeLauncher } from "../launchers.js";
46
12
  /** Names a profile cannot take: every command, alias and legacy word. */
47
13
  export const RESERVED = new Set([
48
- "auto", "which", "resolve", "sessions", "usage", "exhausted", "available", "hook", "setup", "status",
49
- "open", "migrate", "doctor", "statusline", "handoff", "mcp", "mcpd", "secret", "accounts", "browser", "ui", "help", "version",
50
- "cuenta", "resolver", "sesiones", "uso", "agotada", "disponible", "limite", "abrir", "sync-mcp",
51
- "profile", "navegador",
52
- "run", "limit", "session", "identity", "config", "undo", "upgrade", "completion", "__complete", "__update-check",
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",
53
61
  ]);
54
62
  export function checkName(name) {
55
63
  if (!isValidProfileName(name))
@@ -57,8 +65,6 @@ export function checkName(name) {
57
65
  if (RESERVED.has(name))
58
66
  fail(`'${name}' is reserved`);
59
67
  }
60
- export { stamp } from "../../core/journal.js";
61
- import { stamp } from "../../core/journal.js";
62
68
  function lstat(path) {
63
69
  try {
64
70
  return lstatSync(path);
@@ -67,150 +73,194 @@ function lstat(path) {
67
73
  return undefined;
68
74
  }
69
75
  }
70
- /** Make <dir>/<item> a symlink to the hub, moving a local copy aside. */
71
- function linkItem(dir, item, aside, io, hub = paths(io.env).hub) {
76
+ /** True when `path` holds the person's own data: a file, or a folder that is not empty. */
77
+ function ownCopy(path) {
78
+ const st = lstat(path);
79
+ if (!st || st.isSymbolicLink())
80
+ return false;
81
+ if (st.isDirectory())
82
+ return readdirSync(path).length > 0;
83
+ return true;
84
+ }
85
+ /**
86
+ * Make <dir>/<item> a symlink to the hub, moving a local copy aside. Every step goes through
87
+ * the journal, so `turno undo` removes the link and moves the copy back.
88
+ */
89
+ function linkItem(dir, item, aside, journal, hub) {
72
90
  const target = join(hub, item);
73
91
  const path = join(dir, item);
74
92
  const st = lstat(path);
93
+ let result = "linked";
75
94
  if (st?.isSymbolicLink()) {
76
95
  if (readlinkSync(path) === target)
77
- return;
78
- rmSync(path);
96
+ return "same";
97
+ journal.unlink(path);
79
98
  }
80
99
  else if (st?.isDirectory() && readdirSync(path).length === 0) {
81
- rmdirSync(path);
100
+ journal.rmdir(path);
82
101
  }
83
102
  else if (st) {
84
- mkdirSync(aside, { recursive: true });
85
- renameSync(path, join(aside, item));
86
- io.out(` ! ${item} was a local copy: moved to ${tildify(aside, io.env)}/ (merge it by hand if useful)`);
103
+ journal.mkdir(aside);
104
+ journal.move(path, join(aside, item));
105
+ result = "aside";
87
106
  }
88
- symlinkSync(target, path);
89
- io.out(` ↔ ${item}`);
90
- }
91
- const SEED_KEYS = ["mcpServers", "projects", "hasCompletedOnboarding", "lastOnboardingVersion", "theme"];
92
- /** First .claude.json of a profile: user MCP servers and per-project state, never the account. */
93
- function seedGlobalConfig(dir, io) {
94
- const dst = join(dir, ".claude.json");
95
- if (existsSync(dst)) {
96
- io.out(" = .claude.json already exists (turno mcp sync brings in new MCP servers)");
97
- return;
98
- }
99
- const src = paths(io.env).hubConfig;
100
- let hub;
101
- try {
102
- hub = JSON.parse(readFileSync(src, "utf8"));
103
- }
104
- catch {
105
- return;
106
- }
107
- const seed = {};
108
- for (const k of SEED_KEYS)
109
- if (k in hub)
110
- seed[k] = hub[k];
111
- writeFileSync(dst, `${JSON.stringify(seed, null, 2)}\n`, { mode: 0o600 });
112
- chmodSync(dst, 0o600);
113
- const count = (v) => (v && typeof v === "object" ? Object.keys(v).length : 0);
114
- io.out(` + .claude.json with ${count(seed.mcpServers)} MCP servers and ${count(seed.projects)} projects from the hub`);
107
+ journal.symlink(target, path);
108
+ return result;
115
109
  }
116
110
  /**
117
- * Codex profiles: seed config.toml from the hub once, and always store the login in the
118
- * profile (`cli_auth_credentials_store = "file"`), so each CODEX_HOME has its own account.
111
+ * Create a profile folder (0700) through the journal, so undo removes it while it is empty, or
112
+ * narrow an existing one to 0700, so undo puts its old mode back.
119
113
  */
120
- function prepareCodex(dir, io) {
121
- const file = join(dir, "config.toml");
122
- let text = "";
123
- if (existsSync(file))
124
- text = readFileSync(file, "utf8");
125
- else {
126
- const hubFile = join(agentHub("codex", io.env), "config.toml");
127
- if (existsSync(hubFile)) {
128
- text = readFileSync(hubFile, "utf8");
129
- io.out(" + config.toml from ~/.codex (the login is not copied)");
130
- }
131
- }
132
- const next = setValue(text, undefined, "cli_auth_credentials_store", "file");
133
- if (next !== text || !existsSync(file)) {
134
- writeFileSync(file, next, { mode: 0o600 });
135
- io.out(' + cli_auth_credentials_store = "file" (the login stays in this profile)');
136
- }
114
+ function profileFolder(dir, journal) {
115
+ journal.mkdir(dir, 0o700);
116
+ journal.chmod(dir, 0o700);
117
+ }
118
+ /** Write a file the setup creates or changes (seeds, agent config) through the journal. */
119
+ function writeOwn(file, text, journal) {
120
+ journal.save(file);
121
+ writeFileSync(file, text, { mode: 0o600 });
137
122
  chmodSync(file, 0o600);
123
+ journal.settle(file);
138
124
  }
139
- /** Profile of an agent other than Claude Code: its directory, hub links, config, launcher. */
140
- function setupAgentProfile(name, agent, io) {
125
+ /** Shared items of a profile: its folder, the agent's hub, and the items linked from it (files only when they exist). */
126
+ function sharedItems(name, agent, env) {
141
127
  const a = adapter(agent);
142
- const hub = agentHub(agent, io.env);
143
- const dir = agentProfileDir(name, agent, io.env);
144
- const aside = join(dir, `.aside-${stamp()}`);
145
- io.out(`▸ ${name} (${a.label}) → ${tildify(dir, io.env)}`);
146
- mkdirSync(dir, { recursive: true });
147
- chmodSync(dir, 0o700);
148
- for (const item of a.sharedDirs) {
149
- mkdirSync(join(hub, item), { recursive: true });
150
- linkItem(dir, item, aside, io, hub);
128
+ const hub = agentHub(agent, env);
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
+ };
135
+ }
136
+ /**
137
+ * The person's own files that setting up `names` would move to .aside-<stamp>/, so a command
138
+ * can ask before it moves anything. `config` is the one the setup will run with (turno init
139
+ * passes the config it is about to write, so a profile it declares has its own agent).
140
+ */
141
+ export function localCopies(names, env, config = loadConfig(env)) {
142
+ return names.map((name) => {
143
+ const s = sharedItems(name, agentOf(name, config), env);
144
+ return { name, dir: s.dir, items: [...s.dirs, ...s.files].filter((item) => ownCopy(join(s.dir, item))) };
145
+ });
146
+ }
147
+ /** Print what linking did: one line, or every item with `verbose`. */
148
+ function reportLinks(name, label, dir, hub, results, aside, io, verbose, brief = false) {
149
+ const env = io.env;
150
+ const dirs = results.length;
151
+ const st = style(io);
152
+ const more = verbose || !dirs ? "" : st.muted(" (-v lists them)");
153
+ io.out(st.wrap(`${st.accent("▸")} `, `${st.bold(name)}${label} → ${tildify(dir, env)}: shares ${plural(dirs, "item")} with ${tildify(hub, env)}${more}`));
154
+ if (verbose)
155
+ for (const [item, r] of results)
156
+ io.out(` ${r === "same" ? st.muted("=") : st.accent("↔")} ${item}`);
157
+ const moved = results.filter(([, r]) => r === "aside").map(([item]) => item);
158
+ if (moved.length) {
159
+ const it = moved.length === 1 ? "it" : "them";
160
+ const text = brief
161
+ ? `moved ${moved.join(", ")} aside ${st.muted(`(turno undo puts ${it} back)`)}`
162
+ : `moved your own ${moved.join(", ")} to ${tildify(aside, env)}/ ${st.muted("(merge by hand if useful; turno undo puts them back)")}`;
163
+ io.out(st.wrap(` ${st.warn("!")} `, text));
151
164
  }
152
- for (const item of a.sharedFiles) {
153
- if (existsSync(join(hub, item)))
154
- linkItem(dir, item, aside, io, hub);
165
+ }
166
+ /**
167
+ * Set up one profile: its folder (0700), the hub links, the agent's own steps and
168
+ * its launcher. Local copies of shared items move to .aside-<stamp>/.
169
+ */
170
+ function setupProfile(name, agent, io, verbose, journal, config, brief = false) {
171
+ const a = adapter(agent);
172
+ const step = {
173
+ name,
174
+ dir: agentProfileDir(name, agent, io.env),
175
+ hub: agentHub(agent, io.env),
176
+ env: io.env,
177
+ journal,
178
+ out: (line) => io.out(line),
179
+ writeOwn: (file, text) => writeOwn(file, text, journal),
180
+ busy: () => profileBusy(name, io.env, config),
181
+ };
182
+ a.setup?.before?.(step);
183
+ const s = sharedItems(name, agent, io.env);
184
+ const aside = join(s.dir, `.aside-${stamp()}`);
185
+ profileFolder(s.dir, journal);
186
+ const results = [];
187
+ const held = [];
188
+ for (const item of s.dirs) {
189
+ const why = a.setup?.hold?.(item, step);
190
+ if (why) {
191
+ held.push(why);
192
+ continue;
193
+ }
194
+ mkdirSync(join(s.hub, item), { recursive: true });
195
+ results.push([item, linkItem(s.dir, item, aside, journal, s.hub)]);
155
196
  }
156
- if (agent === "codex")
157
- prepareCodex(dir, io);
158
- writeLauncher(name, io.env, agent);
159
- io.out(` + command ${launcherName(name, agent)}`);
197
+ for (const item of s.files)
198
+ results.push([item, linkItem(s.dir, item, aside, journal, s.hub)]);
199
+ reportLinks(name, agent === DEFAULT_AGENT ? "" : ` (${a.label})`, s.dir, s.hub, results, aside, io, verbose, brief);
200
+ const st = style(io);
201
+ for (const why of held)
202
+ io.out(st.wrap(` ${st.warn("!")} `, why));
203
+ a.setup?.after?.(step);
204
+ a.ruleFolders?.({ ...step, folders: ruleFolders(name, config, io.env) });
205
+ writeLauncher(name, io.env, agent, journal);
206
+ io.out(` ${st.ok("+")} command ${st.bold(launcherName(name, agent))}`);
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
+ });
160
232
  }
161
233
  export function setupProfiles(names, io, opts = {}) {
162
234
  if (names.length === 0)
163
- fail("usage: turno setup <profile>...");
235
+ fail("usage: turno profile repair <profile>...");
164
236
  for (const name of names)
165
237
  checkName(name);
166
- const p = paths(io.env);
238
+ // Launchers keep the path of this turno; a path into npx's cache disappears.
239
+ if (opts.turno === undefined)
240
+ refuseNpx();
241
+ const turno = opts.turno !== undefined ? { words: opts.turno } : resolveTurnoCommand(io.env);
242
+ const verbose = Boolean(opts.verbose);
167
243
  const config = loadConfig(io.env);
168
- for (const name of names) {
169
- const agent = agentOf(name, config);
170
- if (agent !== "claude") {
171
- setupAgentProfile(name, agent, io);
172
- continue;
173
- }
174
- if (!existsSync(p.hub)) {
175
- // Claude Code creates it on first run; profiles need it now to link the shared folders.
176
- mkdirSync(p.hub, { recursive: true, mode: 0o700 });
177
- io.out(` + created ${tildify(p.hub, io.env)} (the folder every Claude Code profile shares)`);
178
- }
179
- const dir = profileDir(name, io.env);
180
- const aside = join(dir, `.aside-${stamp()}`);
181
- io.out(`▸ ${name} → ${tildify(dir, io.env)}`);
182
- mkdirSync(dir, { recursive: true });
183
- chmodSync(dir, 0o700);
184
- for (const item of SHARED_DIRS) {
185
- if (item === "sessions" && !lstat(join(dir, item))?.isSymbolicLink() && profileBusy(name, io.env, config)) {
186
- io.out(" ! sessions: this profile has open sessions; close them and run setup again");
187
- continue;
188
- }
189
- mkdirSync(join(p.hub, item), { recursive: true });
190
- linkItem(dir, item, aside, io);
191
- }
192
- for (const item of SHARED_FILES) {
193
- if (existsSync(join(p.hub, item)))
194
- linkItem(dir, item, aside, io);
195
- }
196
- seedGlobalConfig(dir, io);
197
- const history = join(dir, "history.jsonl");
198
- const hubHistory = join(p.hub, "history.jsonl");
199
- if (!existsSync(history) && lstat(hubHistory)?.isFile()) {
200
- copyFileSync(hubHistory, history);
201
- chmodSync(history, 0o600);
202
- io.out(" + history.jsonl (initial copy; the ↑ history cannot be shared)");
203
- }
204
- writeLauncher(name, io.env, "claude");
205
- io.out(` + command claude-${name}`);
244
+ const journal = opts.journal ?? new Journal(io.env, `profile repair ${names.join(" ")}`);
245
+ for (const name of names)
246
+ setupProfile(name, agentOf(name, config), io, verbose, journal, config, Boolean(opts.brief));
247
+ const written = writeHelperLaunchers(io.env, turno.words, journal);
248
+ if (verbose)
249
+ for (const w of written)
250
+ io.out(`+ command ${w}`);
251
+ if (turno.warning)
252
+ io.out(`! turno-auto and turno-open: ${turno.warning}`);
253
+ if (!opts.journal) {
254
+ const hint = journal.hint();
255
+ if (hint)
256
+ io.out(hint);
206
257
  }
207
- for (const written of writeHelperLaunchers(io.env, opts.turno ?? turnoCommand()))
208
- io.out(`+ command ${written}`);
209
258
  }
210
259
  export const command = {
211
260
  summary: "create or repair ~/.claude-<profile> and its claude-<profile> command",
261
+ hidden: true,
212
262
  usage: [
213
- "Usage: turno setup <profile>...",
263
+ "Usage: turno profile repair <profile>...",
214
264
  "",
215
265
  "Links the shared hub folders and files into the profile (local copies are moved",
216
266
  "to .aside-<timestamp>/), seeds .claude.json and history.jsonl, and writes the",