@i14ks/ccv 0.38.0 → 0.40.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 (26) hide show
  1. package/bundle/ccv.mjs +174 -33
  2. package/package.json +1 -1
  3. package/web/assets/{codemirror-B0NAQjxW.js → codemirror-BFhD_Qok.js} +1 -1
  4. package/web/assets/{index-DhdpnWaP.js → index-BKQ3S7R4.js} +1 -1
  5. package/web/assets/{index-XwIPGsoL.js → index-BeqGzcF4.js} +1 -1
  6. package/web/assets/{index-B5iRbk6K.js → index-BfM9EE1E.js} +1 -1
  7. package/web/assets/{index-fSIv5wMF.js → index-Bng1dR8P.js} +1 -1
  8. package/web/assets/{index-1MYdpgaD.js → index-BqphMi4s.js} +1 -1
  9. package/web/assets/{index-BoyP7MYO.js → index-C--xwv_c.js} +1 -1
  10. package/web/assets/{index-D71l3zbz.js → index-C0UJgxDk.js} +1 -1
  11. package/web/assets/{index-CHbY4Q8q.js → index-CO8tJjX2.js} +1 -1
  12. package/web/assets/{index-D24xx07T.js → index-CTd3OD36.js} +1 -1
  13. package/web/assets/{index-CswcCN2I.js → index-Cp-Vx5md.js} +1 -1
  14. package/web/assets/index-D48z24MD.js +134 -0
  15. package/web/assets/{index-LOhDu6-9.js → index-D6n8Nr5h.js} +1 -1
  16. package/web/assets/{index-pL68uIyG.js → index-DGvQxxdB.js} +1 -1
  17. package/web/assets/{index-Cv6bq7Bb.js → index-DkREaKVS.js} +1 -1
  18. package/web/assets/{index-CO577SPK.css → index-DmlVq6mR.css} +1 -1
  19. package/web/assets/{index-CA0PxYkA.js → index-DswRCrFR.js} +1 -1
  20. package/web/assets/{index-Cg_JGWuj.js → index-DwvMx-lF.js} +1 -1
  21. package/web/assets/{index-C7I7Qrgh.js → index-H0NO4iIy.js} +1 -1
  22. package/web/assets/{index-DMq1FoW-.js → index-Jk59gidx.js} +1 -1
  23. package/web/assets/{index-DiyYHRov.js → index-MdNspwJW.js} +1 -1
  24. package/web/assets/{index-CF_pC8Hx.js → index-Sbrdg0Zd.js} +1 -1
  25. package/web/index.html +2 -2
  26. package/web/assets/index-wKK666LV.js +0 -134
package/bundle/ccv.mjs CHANGED
@@ -156,6 +156,17 @@ import { renameSession as renameSession2 } from "@anthropic-ai/claude-agent-sdk"
156
156
  // ../protocol/dist/index.js
157
157
  var PROTOCOL_VERSION = 1;
158
158
  var MAIN_ACCOUNT_ID = "main";
159
+ var SHARED_CONFIG_ITEMS = [
160
+ "skills",
161
+ "agents",
162
+ "hooks",
163
+ "commands",
164
+ "plugins",
165
+ "output-styles",
166
+ "CLAUDE.md",
167
+ "settings.json",
168
+ "keybindings.json"
169
+ ];
159
170
  var ACCOUNT_COLORS = ["orange", "blue", "green", "purple", "pink", "teal"];
160
171
  function isClientFrame(value) {
161
172
  return typeof value === "object" && value !== null && typeof value.type === "string";
@@ -189,7 +200,7 @@ function hashText(text) {
189
200
 
190
201
  // ../host/dist/accounts.js
191
202
  import { randomUUID } from "node:crypto";
192
- import { lstat, mkdir, readFile as readFile2, rename, symlink, writeFile } from "node:fs/promises";
203
+ import { lstat, mkdir, readFile as readFile2, readdir, rename, stat, symlink, writeFile } from "node:fs/promises";
193
204
  import { homedir as homedir2 } from "node:os";
194
205
  import path3 from "node:path";
195
206
  var MAIN_DEFAULT = {
@@ -210,7 +221,10 @@ var AccountStore = class {
210
221
  const stored = (parsed.accounts ?? []).filter(isStored);
211
222
  const main = stored.find((a) => a.id === MAIN_ACCOUNT_ID);
212
223
  this.#accounts = [
213
- { ...MAIN_DEFAULT, ...main ? { name: main.name, color: main.color } : {} },
224
+ {
225
+ ...MAIN_DEFAULT,
226
+ ...main ? { name: main.name, color: main.color, configDir: main.configDir } : {}
227
+ },
214
228
  ...stored.filter((a) => a.id !== MAIN_ACCOUNT_ID && a.configDir)
215
229
  ];
216
230
  } catch {
@@ -222,22 +236,26 @@ var AccountStore = class {
222
236
  find(id) {
223
237
  return this.#accounts.find((a) => a.id === (id ?? MAIN_ACCOUNT_ID));
224
238
  }
225
- /** Каталог конфигурации аккаунта; null — унаследованный. */
239
+ /** Каталог конфигурации аккаунта, заданный явно; null — унаследованный. */
226
240
  configDir(id) {
227
241
  return this.find(id)?.configDir ?? null;
228
242
  }
243
+ /** Каталог, в который аккаунт смотрит на самом деле. */
244
+ effectiveDir(id) {
245
+ return this.find(id)?.configDir ?? inheritedDir();
246
+ }
229
247
  async add(input) {
230
248
  const name = cleanName(input.name);
231
249
  const id = randomUUID().slice(0, 8);
232
250
  const configDir = input.configDir?.trim() ? path3.resolve(input.configDir.trim()) : path3.join(homedir2(), `.claude-ccv-${id}`);
233
- if (this.#accounts.some((a) => sameDir(a.configDir ?? inheritedDir(), configDir))) {
251
+ if (this.#accounts.some((a) => sameDir(this.effectiveDir(a.id), configDir))) {
234
252
  throw new Error("\u042D\u0442\u043E\u0442 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0443\u0436\u0435 \u0437\u0430\u043D\u044F\u0442 \u0434\u0440\u0443\u0433\u0438\u043C \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C");
235
253
  }
236
254
  const color = input.color ?? this.#freeColor();
237
255
  const account = { id, name, color, configDir };
238
256
  await mkdir(configDir, { recursive: true });
239
257
  if (input.shareConfig)
240
- await linkSharedConfig(configDir);
258
+ await linkSharedConfig(configDir, this.effectiveDir(MAIN_ACCOUNT_ID), input.sharedItems);
241
259
  this.#accounts = [...this.#accounts, account];
242
260
  await this.#save();
243
261
  return account;
@@ -246,12 +264,48 @@ var AccountStore = class {
246
264
  const account = this.find(id);
247
265
  if (!account)
248
266
  throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
267
+ if (patch.configDir !== void 0) {
268
+ if (patch.configDir === null) {
269
+ if (account.id !== MAIN_ACCOUNT_ID)
270
+ throw new Error("\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438");
271
+ account.configDir = null;
272
+ } else {
273
+ const dir = path3.resolve(patch.configDir.trim());
274
+ if (!await isDirectory(dir))
275
+ throw new Error(`\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D: ${dir}`);
276
+ const taken = this.#accounts.find((a) => a.id !== account.id && sameDir(this.effectiveDir(a.id), dir));
277
+ if (taken)
278
+ throw new Error(`\u042D\u0442\u043E\u0442 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u0443\u0436\u0435 \u0437\u0430\u043D\u044F\u0442 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C \xAB${taken.name}\xBB`);
279
+ account.configDir = dir;
280
+ }
281
+ }
249
282
  if (patch.name !== void 0)
250
283
  account.name = cleanName(patch.name);
251
284
  if (patch.color !== void 0 && ACCOUNT_COLORS.includes(patch.color))
252
285
  account.color = patch.color;
253
286
  await this.#save();
254
287
  }
288
+ /**
289
+ * Поменять местами основной и `id`: каталог, имя и цвет переезжают вместе,
290
+ * чтобы личность входа не потеряла своего названия. Файлов не двигает.
291
+ */
292
+ async swapMain(id) {
293
+ if (id === MAIN_ACCOUNT_ID)
294
+ return;
295
+ const main = this.find(MAIN_ACCOUNT_ID);
296
+ const other = this.find(id);
297
+ if (!main || !other)
298
+ throw new Error("\u0410\u043A\u043A\u0430\u0443\u043D\u0442 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D");
299
+ const mainDir = this.effectiveDir(MAIN_ACCOUNT_ID);
300
+ const otherDir = other.configDir;
301
+ if (!otherDir)
302
+ throw new Error("\u0423 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u0430 \u043D\u0435\u0442 \u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438");
303
+ [main.name, other.name] = [other.name, main.name];
304
+ [main.color, other.color] = [other.color, main.color];
305
+ main.configDir = otherDir;
306
+ other.configDir = mainDir;
307
+ await this.#save();
308
+ }
255
309
  async remove(id) {
256
310
  if (id === MAIN_ACCOUNT_ID)
257
311
  throw new Error("\u041E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0430\u043A\u043A\u0430\u0443\u043D\u0442 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F");
@@ -314,17 +368,15 @@ function isStored(value) {
314
368
  const v = value;
315
369
  return typeof v.id === "string" && typeof v.name === "string" && typeof v.color === "string" && ACCOUNT_COLORS.includes(v.color) && (v.configDir === null || typeof v.configDir === "string");
316
370
  }
317
- var SHARED_DIRS = ["skills", "agents", "hooks", "commands", "plugins"];
318
- var SHARED_FILES = ["CLAUDE.md", "settings.json"];
371
+ var DIR_ITEMS = /* @__PURE__ */ new Set(["skills", "agents", "hooks", "commands", "plugins", "output-styles"]);
319
372
  function sharedConfigDir() {
320
373
  return process.env.CCV_SHARED_CONFIG_DIR?.trim() || path3.join(homedir2(), ".claude-shared");
321
374
  }
322
- async function linkSharedConfig(configDir) {
375
+ async function linkSharedConfig(configDir, main = inheritedDir(), items = SHARED_CONFIG_ITEMS) {
323
376
  const shared = sharedConfigDir();
324
- const main = inheritedDir();
325
377
  await mkdir(shared, { recursive: true });
326
- for (const name of [...SHARED_DIRS, ...SHARED_FILES]) {
327
- const isDir = SHARED_DIRS.includes(name);
378
+ for (const name of items) {
379
+ const isDir = DIR_ITEMS.has(name);
328
380
  const target = path3.join(shared, name);
329
381
  const origin = path3.join(main, name);
330
382
  if (!await exists(target)) {
@@ -353,7 +405,29 @@ async function exists(file) {
353
405
  return lstat(file).then(() => true, () => false);
354
406
  }
355
407
  async function isRealEntry(file) {
356
- return lstat(file).then((stat2) => !stat2.isSymbolicLink(), () => false);
408
+ return lstat(file).then((stat3) => !stat3.isSymbolicLink(), () => false);
409
+ }
410
+ async function candidateConfigDirs() {
411
+ const home = homedir2();
412
+ const found = /* @__PURE__ */ new Set();
413
+ const add = async (dir) => {
414
+ if (!await isDirectory(dir))
415
+ return;
416
+ const marked = await exists(path3.join(dir, ".credentials.json")) || await exists(path3.join(dir, ".claude.json"));
417
+ if (marked)
418
+ found.add(path3.resolve(dir));
419
+ };
420
+ const skip = /* @__PURE__ */ new Set([".claude-shared", ".claude-code-visual", ".claude-code"]);
421
+ for (const name of await readdir(home).catch(() => [])) {
422
+ if (!/^\.claude(-.+)?$/.test(name) || skip.has(name))
423
+ continue;
424
+ await add(path3.join(home, name));
425
+ }
426
+ await add(inheritedDir());
427
+ return [...found];
428
+ }
429
+ async function isDirectory(file) {
430
+ return stat(file).then((s) => s.isDirectory(), () => false);
357
431
  }
358
432
 
359
433
  // ../host/dist/workspace-ids.js
@@ -448,7 +522,7 @@ var AsyncQueue = class {
448
522
  };
449
523
 
450
524
  // ../host/dist/files.js
451
- import { cp, lstat as lstat2, mkdir as mkdir2, readFile as readFile3, readdir, realpath, rename as renamePath, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
525
+ import { cp, lstat as lstat2, mkdir as mkdir2, readFile as readFile3, readdir as readdir2, realpath, rename as renamePath, rm, stat as stat2, writeFile as writeFile2 } from "node:fs/promises";
452
526
  import path4 from "node:path";
453
527
  var MAX_FILE = 4 * 1024 * 1024;
454
528
  var MAX_MEDIA = 64 * 1024 * 1024;
@@ -482,14 +556,14 @@ var ProjectFiles = class {
482
556
  }
483
557
  async list(relative) {
484
558
  const dir = await this.#resolve(relative);
485
- const names2 = await readdir(dir, { withFileTypes: true });
559
+ const names2 = await readdir2(dir, { withFileTypes: true });
486
560
  const entries = [];
487
561
  for (const dirent of names2) {
488
562
  if (HIDDEN.has(dirent.name))
489
563
  continue;
490
564
  const full = path4.join(dir, dirent.name);
491
565
  const link2 = dirent.isSymbolicLink();
492
- const info = await stat(full).catch(() => null);
566
+ const info = await stat2(full).catch(() => null);
493
567
  if (!info)
494
568
  continue;
495
569
  entries.push({
@@ -529,7 +603,7 @@ var ProjectFiles = class {
529
603
  const walk = async (dir, relative) => {
530
604
  if (truncated)
531
605
  return;
532
- const names2 = await readdir(dir, { withFileTypes: true }).catch(() => []);
606
+ const names2 = await readdir2(dir, { withFileTypes: true }).catch(() => []);
533
607
  for (const dirent of names2) {
534
608
  if (truncated)
535
609
  return;
@@ -537,7 +611,7 @@ var ProjectFiles = class {
537
611
  continue;
538
612
  const full = path4.join(dir, dirent.name);
539
613
  const rel = join(relative, dirent.name);
540
- const info = await stat(full).catch(() => null);
614
+ const info = await stat2(full).catch(() => null);
541
615
  if (!info)
542
616
  continue;
543
617
  const isDir = info.isDirectory();
@@ -584,7 +658,7 @@ var ProjectFiles = class {
584
658
  const walk = async (dir, relative) => {
585
659
  if (truncated)
586
660
  return;
587
- const names2 = await readdir(dir, { withFileTypes: true }).catch(() => []);
661
+ const names2 = await readdir2(dir, { withFileTypes: true }).catch(() => []);
588
662
  for (const dirent of names2) {
589
663
  if (truncated)
590
664
  return;
@@ -598,7 +672,7 @@ var ProjectFiles = class {
598
672
  }
599
673
  if (!dirent.isFile())
600
674
  continue;
601
- const info = await stat(full).catch(() => null);
675
+ const info = await stat2(full).catch(() => null);
602
676
  if (!info || info.size > MAX_FILE)
603
677
  continue;
604
678
  const buffer = await readFile3(full).catch(() => null);
@@ -645,7 +719,7 @@ var ProjectFiles = class {
645
719
  }
646
720
  async read(relative) {
647
721
  const file = await this.#resolve(relative);
648
- const info = await stat(file);
722
+ const info = await stat2(file);
649
723
  if (info.isDirectory())
650
724
  throw new Error("\u042D\u0442\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433, \u0430 \u043D\u0435 \u0444\u0430\u0439\u043B");
651
725
  const blank = {
@@ -692,7 +766,7 @@ var ProjectFiles = class {
692
766
  const mime = MEDIA_MIME[path4.extname(file).toLowerCase()];
693
767
  if (!mime)
694
768
  throw new Error("\u0424\u0430\u0439\u043B \u043D\u0435 \u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D \u043A\u0430\u043A \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0430 \u0438\u043B\u0438 \u0432\u0438\u0434\u0435\u043E");
695
- const info = await stat(file);
769
+ const info = await stat2(file);
696
770
  if (info.isDirectory())
697
771
  throw new Error("\u042D\u0442\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433, \u0430 \u043D\u0435 \u0444\u0430\u0439\u043B");
698
772
  if (info.size > MAX_MEDIA)
@@ -710,7 +784,7 @@ var ProjectFiles = class {
710
784
  */
711
785
  async write(relative, content, eol, encoding, baseMtime, force = false) {
712
786
  const file = await this.#resolve(relative);
713
- const info = await stat(file).catch(() => null);
787
+ const info = await stat2(file).catch(() => null);
714
788
  if (info?.isDirectory())
715
789
  throw new Error("\u042D\u0442\u043E \u043A\u0430\u0442\u0430\u043B\u043E\u0433, \u0430 \u043D\u0435 \u0444\u0430\u0439\u043B");
716
790
  if (!force) {
@@ -720,7 +794,7 @@ var ProjectFiles = class {
720
794
  }
721
795
  }
722
796
  await writeFile2(file, encode(content, eol, encoding));
723
- const saved = await stat(file);
797
+ const saved = await stat2(file);
724
798
  return { mtime: Math.round(saved.mtimeMs), size: saved.size };
725
799
  }
726
800
  async create(relative, kind) {
@@ -758,7 +832,7 @@ var ProjectFiles = class {
758
832
  if (!source)
759
833
  throw new Error("\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u043A\u043E\u0440\u0435\u043D\u044C \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u043D\u0435\u043B\u044C\u0437\u044F");
760
834
  const from = await this.#resolve(source);
761
- const info = await stat(from);
835
+ const info = await stat2(from);
762
836
  const dir = normalize(toDir);
763
837
  if (info.isDirectory() && (dir === source || dir.startsWith(`${source}/`))) {
764
838
  throw new Error("\u041A\u0430\u0442\u0430\u043B\u043E\u0433 \u043D\u0435\u043B\u044C\u0437\u044F \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0432\u043D\u0443\u0442\u0440\u044C \u0441\u0430\u043C\u043E\u0433\u043E \u0441\u0435\u0431\u044F");
@@ -5364,7 +5438,7 @@ function describe4(error) {
5364
5438
 
5365
5439
  // ../host/dist/finder.js
5366
5440
  import { existsSync as existsSync2, statSync } from "node:fs";
5367
- import { readdir as readdir2 } from "node:fs/promises";
5441
+ import { readdir as readdir3 } from "node:fs/promises";
5368
5442
  import os2 from "node:os";
5369
5443
  import path12 from "node:path";
5370
5444
  import { listSessions } from "@anthropic-ai/claude-agent-sdk";
@@ -5455,7 +5529,7 @@ var ProjectFinder = class {
5455
5529
  const key = absolute.toLowerCase();
5456
5530
  if (seen.has(key))
5457
5531
  continue;
5458
- if (!isDirectory(absolute))
5532
+ if (!isDirectory2(absolute))
5459
5533
  continue;
5460
5534
  seen.add(key);
5461
5535
  const record = known.get(key);
@@ -5513,7 +5587,7 @@ var ProjectFinder = class {
5513
5587
  dirs.set(key, { path: cwd, sessions: 1, lastUsedAt: info.lastModified });
5514
5588
  }
5515
5589
  for (const parent of this.#parents(dirs.values())) {
5516
- const names2 = await readdir2(parent, { withFileTypes: true }).catch(() => []);
5590
+ const names2 = await readdir3(parent, { withFileTypes: true }).catch(() => []);
5517
5591
  for (const dirent of names2) {
5518
5592
  if (!dirent.isDirectory() || SKIP_NAMES.has(dirent.name) || dirent.name.startsWith(".")) {
5519
5593
  continue;
@@ -5562,7 +5636,7 @@ function matches(value, needles) {
5562
5636
  const flat = value.toLowerCase().replace(/[^a-z0-9а-яё]+/gi, "");
5563
5637
  return needles.every((needle) => flat.includes(needle));
5564
5638
  }
5565
- function isDirectory(dir) {
5639
+ function isDirectory2(dir) {
5566
5640
  try {
5567
5641
  return statSync(dir).isDirectory();
5568
5642
  } catch {
@@ -6640,6 +6714,9 @@ var PERMISSION_MODES = [
6640
6714
  "auto"
6641
6715
  ];
6642
6716
  var DEFAULT_APP_SETTINGS = {
6717
+ // Всё, что можно делить: так новый аккаунт получает ту же обстановку, что и
6718
+ // основной, а лишнее человек выключает сам.
6719
+ sharedConfigItems: [...SHARED_CONFIG_ITEMS],
6643
6720
  autoArchiveAfterMs: DEFAULT_AUTO_ARCHIVE_AFTER_MS,
6644
6721
  autoStopAfterMs: DEFAULT_AUTO_STOP_AFTER_MS,
6645
6722
  // Строгий режим по умолчанию: молча писать в чужой проект приложение начнёт
@@ -6748,6 +6825,10 @@ function sanitize2(value, fallback) {
6748
6825
  result[key] = pct <= 0 ? 0 : Math.min(Math.max(Math.round(pct), 1), 100);
6749
6826
  }
6750
6827
  }
6828
+ const shared = record.sharedConfigItems;
6829
+ if (Array.isArray(shared)) {
6830
+ result.sharedConfigItems = SHARED_CONFIG_ITEMS.filter((item) => shared.includes(item));
6831
+ }
6751
6832
  const providers = record.enabledProviders;
6752
6833
  if (Array.isArray(providers)) {
6753
6834
  const picked = PROVIDERS.filter((p) => providers.includes(p));
@@ -6784,7 +6865,7 @@ function writableRoots(mode, cwd, workspacePaths) {
6784
6865
  }
6785
6866
 
6786
6867
  // ../host/dist/handoff-store.js
6787
- import { mkdir as mkdir12, readFile as readFile14, readdir as readdir3, rm as rm4, writeFile as writeFile13 } from "node:fs/promises";
6868
+ import { mkdir as mkdir12, readFile as readFile14, readdir as readdir4, rm as rm4, writeFile as writeFile13 } from "node:fs/promises";
6788
6869
  import path19 from "node:path";
6789
6870
  var HandoffStore = class {
6790
6871
  #dir;
@@ -6817,7 +6898,7 @@ var HandoffStore = class {
6817
6898
  /** id всех сохранённых хэндоффов. */
6818
6899
  async list() {
6819
6900
  try {
6820
- return (await readdir3(this.#dir)).filter((name) => name.endsWith(".json")).map((name) => name.slice(0, -".json".length));
6901
+ return (await readdir4(this.#dir)).filter((name) => name.endsWith(".json")).map((name) => name.slice(0, -".json".length));
6821
6902
  } catch {
6822
6903
  return [];
6823
6904
  }
@@ -8189,6 +8270,7 @@ var HostServer = class {
8189
8270
  name: a.name,
8190
8271
  color: a.color,
8191
8272
  configDir: a.configDir,
8273
+ dir: this.#accounts.effectiveDir(a.id),
8192
8274
  main: a.id === MAIN_ACCOUNT_ID,
8193
8275
  liveSessions: live.filter((s) => s.accountId === a.id).length
8194
8276
  }));
@@ -8202,6 +8284,27 @@ var HostServer = class {
8202
8284
  }));
8203
8285
  return { type: "accounts.state", accounts, auth: Object.fromEntries(entries) };
8204
8286
  }
8287
+ /**
8288
+ * Каталоги с входом, найденные на устройстве, и кто в них вошёл.
8289
+ * Кто вошёл — отвечает CLI; каталоги без входа в предложение не идут.
8290
+ */
8291
+ async #discoverAccounts() {
8292
+ const dirs = await candidateConfigDirs();
8293
+ const results = await Promise.all(dirs.map(async (configDir) => {
8294
+ const status = await new AuthCli(configDir).status().catch(() => null);
8295
+ if (!status?.loggedIn)
8296
+ return null;
8297
+ const used = this.#accounts.all.find((a) => path24.resolve(this.#accounts.effectiveDir(a.id)).toLowerCase() === configDir.toLowerCase());
8298
+ return {
8299
+ configDir,
8300
+ email: status.email,
8301
+ plan: status.plan,
8302
+ organization: status.organization,
8303
+ accountId: used?.id ?? null
8304
+ };
8305
+ }));
8306
+ return results.filter((c) => c !== null);
8307
+ }
8205
8308
  async #sendAccounts() {
8206
8309
  this.#broadcast(await this.#accountsFrame());
8207
8310
  }
@@ -9194,17 +9297,55 @@ var HostServer = class {
9194
9297
  name: frame.name,
9195
9298
  ...frame.color ? { color: frame.color } : {},
9196
9299
  ...frame.configDir ? { configDir: frame.configDir } : {},
9197
- ...frame.shareConfig ? { shareConfig: true } : {}
9300
+ ...frame.shareConfig ? { shareConfig: true, sharedItems: this.#settings.current.sharedConfigItems } : {}
9198
9301
  });
9199
9302
  await this.#sendAccounts();
9200
9303
  return;
9201
- case "accounts.update":
9304
+ case "accounts.update": {
9305
+ if (frame.configDir !== void 0) {
9306
+ const live = this.#accountList().find((a) => a.id === frame.accountId)?.liveSessions ?? 0;
9307
+ if (live > 0) {
9308
+ throw new Error("\u041F\u043E\u0434 \u044D\u0442\u0438\u043C \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u043C \u0438\u0434\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438 \u2014 \u0437\u0430\u043A\u0440\u043E\u0439\u0442\u0435 \u0438\u0445, \u043F\u043E\u0442\u043E\u043C \u043C\u0435\u043D\u044F\u0439\u0442\u0435 \u043A\u0430\u0442\u0430\u043B\u043E\u0433");
9309
+ }
9310
+ }
9202
9311
  await this.#accounts.update(frame.accountId, {
9203
9312
  ...frame.name !== void 0 ? { name: frame.name } : {},
9204
- ...frame.color ? { color: frame.color } : {}
9313
+ ...frame.color ? { color: frame.color } : {},
9314
+ ...frame.configDir !== void 0 ? { configDir: frame.configDir } : {}
9205
9315
  });
9316
+ if (frame.configDir !== void 0) {
9317
+ this.#authFor(frame.accountId).cancel();
9318
+ this.#auths.delete(frame.accountId);
9319
+ }
9206
9320
  await this.#sendAccounts();
9207
9321
  return;
9322
+ }
9323
+ case "accounts.makeMain": {
9324
+ const accounts = this.#accountList();
9325
+ const main = accounts.find((a) => a.main);
9326
+ const target = accounts.find((a) => a.id === frame.accountId);
9327
+ if (!main || !target || target.main)
9328
+ return;
9329
+ if (main.liveSessions > 0 || target.liveSessions > 0) {
9330
+ throw new Error("\u041F\u043E\u0434 \u043E\u0434\u043D\u0438\u043C \u0438\u0437 \u044D\u0442\u0438\u0445 \u0430\u043A\u043A\u0430\u0443\u043D\u0442\u043E\u0432 \u0438\u0434\u0443\u0442 \u0441\u0435\u0441\u0441\u0438\u0438 \u2014 \u0437\u0430\u043A\u0440\u043E\u0439\u0442\u0435 \u0438\u0445, \u043F\u043E\u0442\u043E\u043C \u043C\u0435\u043D\u044F\u0439\u0442\u0435 \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439");
9331
+ }
9332
+ await this.#accounts.swapMain(target.id);
9333
+ for (const id of [main.id, target.id]) {
9334
+ this.#auths.get(id)?.cancel();
9335
+ this.#auths.delete(id);
9336
+ }
9337
+ this.#diskAccounts.clear();
9338
+ await this.#sendAccounts();
9339
+ for (const workspace of this.#workspaces.list())
9340
+ await this.#sendSessionList(workspace.id);
9341
+ return;
9342
+ }
9343
+ case "accounts.discover":
9344
+ this.#send(socket, {
9345
+ type: "accounts.candidates",
9346
+ candidates: await this.#discoverAccounts()
9347
+ });
9348
+ return;
9208
9349
  case "accounts.remove": {
9209
9350
  const account = this.#accountList().find((a) => a.id === frame.accountId);
9210
9351
  if (!account)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@i14ks/ccv",
3
- "version": "0.38.0",
3
+ "version": "0.40.0",
4
4
  "license": "UNLICENSED",
5
5
  "description": "GUI для Claude Code: сессии агента в каталогах проектов, дерево файлов и редактор рядом с разговором.",
6
6
  "homepage": "https://claudevisual.com",
@@ -1 +1 @@
1
- import{s as r,H as a}from"./index-CF_pC8Hx.js";import{E as e}from"./index-891wE-Rj.js";import{t as o}from"./index-wKK666LV.js";import"./index-BHot-lnj.js";const m=e.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--bg)",fontSize:"13px"},".cm-scroller":{fontFamily:"var(--mono)",lineHeight:"1.6"},".cm-content":{caretColor:"var(--accent)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--cm-selection)"},".cm-gutters":{backgroundColor:"var(--bg)",color:"var(--muted)",borderRight:"1px solid var(--border-soft)"},".cm-activeLineGutter":{backgroundColor:"var(--surface-2)",color:"var(--text-2)"},".cm-activeLine":{backgroundColor:"var(--cm-active)"},".cm-selectionMatch":{backgroundColor:"var(--cm-match)"},"&.cm-focused .cm-matchingBracket":{backgroundColor:"var(--cm-match)",outline:"1px solid var(--accent-line)"},".cm-foldPlaceholder":{backgroundColor:"var(--surface-2)",border:"1px solid var(--border)",color:"var(--muted)"},".cm-panels":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--border)"},".cm-panels input, .cm-panels button, .cm-panels select":{fontFamily:"var(--sans)",fontSize:"12px",background:"var(--surface-2)",color:"var(--text)",border:"1px solid var(--border)",borderRadius:"6px",padding:"3px 6px"},".cm-searchMatch":{backgroundColor:"var(--cm-match)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)"},".cm-tooltip":{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"var(--shadow-md)",color:"var(--text)"},".cm-tooltip-autocomplete ul li[aria-selected]":{background:"var(--surface-2)",color:"var(--text)"}}),i=r(a.define([{tag:[o.keyword,o.modifier,o.controlKeyword,o.moduleKeyword],color:"var(--cm-key)"},{tag:[o.name,o.deleted,o.character,o.macroName],color:"var(--text)"},{tag:[o.propertyName],color:"var(--cm-prop)"},{tag:[o.function(o.variableName),o.labelName],color:"var(--cm-fn)"},{tag:[o.color,o.constant(o.name),o.standard(o.name),o.bool],color:"var(--cm-const)"},{tag:[o.definition(o.name),o.separator],color:"var(--text)"},{tag:[o.typeName,o.className,o.changed,o.annotation,o.self,o.namespace],color:"var(--cm-type)"},{tag:[o.number,o.integer,o.float],color:"var(--cm-num)"},{tag:[o.string,o.special(o.string),o.regexp],color:"var(--cm-str)"},{tag:[o.operator,o.operatorKeyword,o.escape],color:"var(--cm-op)"},{tag:[o.meta,o.comment],color:"var(--cm-comment)",fontStyle:"italic"},{tag:o.strong,fontWeight:"650"},{tag:o.emphasis,fontStyle:"italic"},{tag:o.strikethrough,textDecoration:"line-through"},{tag:o.link,color:"var(--cm-str)",textDecoration:"underline"},{tag:o.heading,fontWeight:"650",color:"var(--cm-key)"},{tag:o.invalid,color:"var(--danger)"}]));export{i as editorHighlight,m as editorTheme};
1
+ import{s as r,H as a}from"./index-Sbrdg0Zd.js";import{E as e}from"./index-891wE-Rj.js";import{t as o}from"./index-D48z24MD.js";import"./index-BHot-lnj.js";const m=e.theme({"&":{height:"100%",color:"var(--text)",backgroundColor:"var(--bg)",fontSize:"13px"},".cm-scroller":{fontFamily:"var(--mono)",lineHeight:"1.6"},".cm-content":{caretColor:"var(--accent)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--accent)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--cm-selection)"},".cm-gutters":{backgroundColor:"var(--bg)",color:"var(--muted)",borderRight:"1px solid var(--border-soft)"},".cm-activeLineGutter":{backgroundColor:"var(--surface-2)",color:"var(--text-2)"},".cm-activeLine":{backgroundColor:"var(--cm-active)"},".cm-selectionMatch":{backgroundColor:"var(--cm-match)"},"&.cm-focused .cm-matchingBracket":{backgroundColor:"var(--cm-match)",outline:"1px solid var(--accent-line)"},".cm-foldPlaceholder":{backgroundColor:"var(--surface-2)",border:"1px solid var(--border)",color:"var(--muted)"},".cm-panels":{backgroundColor:"var(--surface)",color:"var(--text)",border:"1px solid var(--border)"},".cm-panels input, .cm-panels button, .cm-panels select":{fontFamily:"var(--sans)",fontSize:"12px",background:"var(--surface-2)",color:"var(--text)",border:"1px solid var(--border)",borderRadius:"6px",padding:"3px 6px"},".cm-searchMatch":{backgroundColor:"var(--cm-match)"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"var(--accent-soft)"},".cm-tooltip":{background:"var(--surface)",border:"1px solid var(--border)",borderRadius:"8px",boxShadow:"var(--shadow-md)",color:"var(--text)"},".cm-tooltip-autocomplete ul li[aria-selected]":{background:"var(--surface-2)",color:"var(--text)"}}),i=r(a.define([{tag:[o.keyword,o.modifier,o.controlKeyword,o.moduleKeyword],color:"var(--cm-key)"},{tag:[o.name,o.deleted,o.character,o.macroName],color:"var(--text)"},{tag:[o.propertyName],color:"var(--cm-prop)"},{tag:[o.function(o.variableName),o.labelName],color:"var(--cm-fn)"},{tag:[o.color,o.constant(o.name),o.standard(o.name),o.bool],color:"var(--cm-const)"},{tag:[o.definition(o.name),o.separator],color:"var(--text)"},{tag:[o.typeName,o.className,o.changed,o.annotation,o.self,o.namespace],color:"var(--cm-type)"},{tag:[o.number,o.integer,o.float],color:"var(--cm-num)"},{tag:[o.string,o.special(o.string),o.regexp],color:"var(--cm-str)"},{tag:[o.operator,o.operatorKeyword,o.escape],color:"var(--cm-op)"},{tag:[o.meta,o.comment],color:"var(--cm-comment)",fontStyle:"italic"},{tag:o.strong,fontWeight:"650"},{tag:o.emphasis,fontStyle:"italic"},{tag:o.strikethrough,textDecoration:"line-through"},{tag:o.link,color:"var(--cm-str)",textDecoration:"underline"},{tag:o.heading,fontWeight:"650",color:"var(--cm-key)"},{tag:o.invalid,color:"var(--danger)"}]));export{i as editorHighlight,m as editorTheme};
@@ -1 +1 @@
1
- import{L as r}from"./index-LOhDu6-9.js";import{s as a,t as O}from"./index-wKK666LV.js";import{L as P,k as o,l as s,n as e,o as t,p as Q}from"./index-CF_pC8Hx.js";import"./index-BHot-lnj.js";import"./index-891wE-Rj.js";const n=a({String:O.string,Number:O.number,"True False":O.bool,PropertyName:O.propertyName,Null:O.null,", :":O.separator,"[ ]":O.squareBracket,"{ }":O.brace}),i=r.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[n],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),p=o.define({name:"json",parser:i.configure({props:[s.add({Object:e({except:/^\s*\}/}),Array:e({except:/^\s*\]/})}),t.add({"Object Array":Q})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function u(){return new P(p)}export{u as json,p as jsonLanguage};
1
+ import{L as r}from"./index-D6n8Nr5h.js";import{s as a,t as O}from"./index-D48z24MD.js";import{L as P,k as o,l as s,n as e,o as t,p as Q}from"./index-Sbrdg0Zd.js";import"./index-BHot-lnj.js";import"./index-891wE-Rj.js";const n=a({String:O.string,Number:O.number,"True False":O.bool,PropertyName:O.propertyName,Null:O.null,", :":O.separator,"[ ]":O.squareBracket,"{ }":O.brace}),i=r.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[n],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),p=o.define({name:"json",parser:i.configure({props:[s.add({Object:e({except:/^\s*\}/}),Array:e({except:/^\s*\]/})}),t.add({"Object Array":Q})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function u(){return new P(p)}export{u as json,p as jsonLanguage};