ccsini 0.1.61 → 0.1.63

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 (2) hide show
  1. package/dist/index.js +53 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28058,7 +28058,7 @@ var {
28058
28058
  } = import__.default;
28059
28059
 
28060
28060
  // src/version.ts
28061
- var VERSION = "0.1.61";
28061
+ var VERSION = "0.1.63";
28062
28062
 
28063
28063
  // src/commands/init.ts
28064
28064
  init_source();
@@ -29491,11 +29491,13 @@ async function pushSync(client, masterKey, deviceName, configDir, onProgress, se
29491
29491
  const conflicts = [];
29492
29492
  let bytesTransferred = 0;
29493
29493
  const progress = onProgress ?? (() => {});
29494
- const { manifest: localManifest, cacheStats } = await generateManifest(claudeDir, deviceName, progress, sessionOptions);
29494
+ progress("Scanning local files & fetching remote manifest...");
29495
+ const [{ manifest: localManifest, cacheStats }, remoteManifestEnc] = await Promise.all([
29496
+ generateManifest(claudeDir, deviceName, progress, sessionOptions),
29497
+ client.getManifest()
29498
+ ]);
29495
29499
  const fileCount = Object.keys(localManifest.files).length;
29496
29500
  progress(`Scanned ${fileCount} files`);
29497
- progress("Fetching remote manifest...");
29498
- const remoteManifestEnc = await client.getManifest();
29499
29501
  let remoteManifest = null;
29500
29502
  if (remoteManifestEnc) {
29501
29503
  try {
@@ -29509,6 +29511,17 @@ async function pushSync(client, masterKey, deviceName, configDir, onProgress, se
29509
29511
  const diffs = diffManifests(localManifest, remoteManifest);
29510
29512
  const toPush = diffs.filter((d) => d.action === "push" || d.action === "merge");
29511
29513
  progress(`${toPush.length} files to push`);
29514
+ if (toPush.length === 0) {
29515
+ return {
29516
+ action: "push",
29517
+ filesChanged: 0,
29518
+ bytesTransferred: 0,
29519
+ durationMs: Date.now() - start,
29520
+ errors: [],
29521
+ conflicts: [],
29522
+ cacheStats
29523
+ };
29524
+ }
29512
29525
  if (remoteManifest && !pushOptions?.skipConflictBackup) {
29513
29526
  const merges = toPush.filter((d) => d.action === "merge" && d.remoteHash);
29514
29527
  for (const diff of merges) {
@@ -29532,9 +29545,9 @@ async function pushSync(client, masterKey, deviceName, configDir, onProgress, se
29532
29545
  const pushKeys = toPush.map((d) => blobKey(d.path, d.localHash));
29533
29546
  let existing = {};
29534
29547
  try {
29535
- for (const batch of chunkArray(pushKeys, 100)) {
29536
- Object.assign(existing, await client.checkBlobsExist(batch));
29537
- }
29548
+ const batchResults = await Promise.all(chunkArray(pushKeys, 100).map((batch) => client.checkBlobsExist(batch)));
29549
+ for (const r of batchResults)
29550
+ Object.assign(existing, r);
29538
29551
  } catch {}
29539
29552
  const toUpload = toPush.filter((d) => !existing[blobKey(d.path, d.localHash)]);
29540
29553
  progress(`${toPush.length} changed, ${toUpload.length} to upload (${toPush.length - toUpload.length} skipped)`);
@@ -29566,22 +29579,21 @@ async function pushSync(client, masterKey, deviceName, configDir, onProgress, se
29566
29579
  }
29567
29580
  const manifestJson = JSON.stringify(localManifest);
29568
29581
  const manifestEnc = encryptFile(masterKey, "__manifest__", new TextEncoder().encode(manifestJson));
29569
- await client.putManifest(manifestEnc);
29570
- await saveManifest(configDir, localManifest);
29582
+ await Promise.all([
29583
+ client.putManifest(manifestEnc),
29584
+ saveManifest(configDir, localManifest)
29585
+ ]);
29571
29586
  const durationMs = Date.now() - start;
29572
29587
  progress("Logging sync event...");
29573
- await client.logSyncEvent({
29574
- action: "push",
29575
- filesChanged: toPush.length,
29576
- bytesTransferred,
29577
- durationMs
29578
- });
29579
- try {
29580
- const projects = extractProjects(localManifest);
29581
- if (projects.length > 0) {
29582
- await client.putProjects(projects, deviceName);
29583
- }
29584
- } catch {}
29588
+ await Promise.all([
29589
+ client.logSyncEvent({
29590
+ action: "push",
29591
+ filesChanged: toPush.length,
29592
+ bytesTransferred,
29593
+ durationMs
29594
+ }).catch(() => {}),
29595
+ extractAndSendProjects(client, localManifest, deviceName).catch(() => {})
29596
+ ]);
29585
29597
  return {
29586
29598
  action: "push",
29587
29599
  filesChanged: toPush.length,
@@ -29723,7 +29735,7 @@ async function pullSync(client, masterKey, deviceName, configDir, onProgress, se
29723
29735
  filesChanged: toPull.length,
29724
29736
  bytesTransferred,
29725
29737
  durationMs
29726
- });
29738
+ }).catch(() => {});
29727
29739
  return {
29728
29740
  action: "pull",
29729
29741
  filesChanged: toPull.length,
@@ -29733,6 +29745,12 @@ async function pullSync(client, masterKey, deviceName, configDir, onProgress, se
29733
29745
  conflicts
29734
29746
  };
29735
29747
  }
29748
+ async function extractAndSendProjects(client, manifest, deviceName) {
29749
+ const projects = extractProjects(manifest);
29750
+ if (projects.length > 0) {
29751
+ await client.putProjects(projects, deviceName);
29752
+ }
29753
+ }
29736
29754
  function chunkArray(arr, size) {
29737
29755
  const chunks = [];
29738
29756
  for (let i = 0;i < arr.length; i += size) {
@@ -31963,7 +31981,7 @@ async function getAuthenticatedClient2(configDir) {
31963
31981
  const config = await loadKeys(configDir);
31964
31982
  const privateKey = await importPrivateKey(config.devicePrivateKey);
31965
31983
  const jwt = await createDeviceJWT(privateKey, config.deviceId);
31966
- return new CcsiniClient(config.apiUrl, jwt);
31984
+ return { client: new CcsiniClient(config.apiUrl, jwt), config };
31967
31985
  }
31968
31986
  async function ensureDaemon(configDir) {
31969
31987
  try {
@@ -31993,12 +32011,13 @@ function registerAutoCommands(program2) {
31993
32011
  const configDir = getConfigDir();
31994
32012
  if (!await configExists(configDir))
31995
32013
  return;
31996
- await ensureDaemon(configDir);
31997
32014
  try {
31998
- const masterKey = await getMasterKey2(configDir);
31999
- const client = await getAuthenticatedClient2(configDir);
32000
- const config = await loadKeys(configDir);
32001
- const storedSession = await loadSessionConfig(configDir);
32015
+ const [, masterKey, { client, config }, storedSession] = await Promise.all([
32016
+ ensureDaemon(configDir),
32017
+ getMasterKey2(configDir),
32018
+ getAuthenticatedClient2(configDir),
32019
+ loadSessionConfig(configDir)
32020
+ ]);
32002
32021
  const sessionOptions = {
32003
32022
  enabled: storedSession.enabled,
32004
32023
  maxPerProject: storedSession.maxPerProject,
@@ -32018,10 +32037,11 @@ function registerAutoCommands(program2) {
32018
32037
  if (!await configExists(configDir))
32019
32038
  return;
32020
32039
  try {
32021
- const masterKey = await getMasterKey2(configDir);
32022
- const client = await getAuthenticatedClient2(configDir);
32023
- const config = await loadKeys(configDir);
32024
- const storedSession = await loadSessionConfig(configDir);
32040
+ const [masterKey, { client, config }, storedSession] = await Promise.all([
32041
+ getMasterKey2(configDir),
32042
+ getAuthenticatedClient2(configDir),
32043
+ loadSessionConfig(configDir)
32044
+ ]);
32025
32045
  const sessionOptions = {
32026
32046
  enabled: storedSession.enabled,
32027
32047
  maxPerProject: storedSession.maxPerProject,
@@ -32067,7 +32087,7 @@ function registerAutoCommands(program2) {
32067
32087
  if (!await configExists(configDir))
32068
32088
  return;
32069
32089
  try {
32070
- const client = await getAuthenticatedClient2(configDir);
32090
+ const { client } = await getAuthenticatedClient2(configDir);
32071
32091
  await client.heartbeat();
32072
32092
  } catch {}
32073
32093
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccsini",
3
- "version": "0.1.61",
3
+ "version": "0.1.63",
4
4
  "description": "Claude Code seamless sync across devices",
5
5
  "type": "module",
6
6
  "bin": {