@rigxyz/tapd 0.6.5 → 0.6.8

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/dist/bin.js CHANGED
@@ -23,13 +23,15 @@ import {
23
23
  loadImportMounts,
24
24
  mint,
25
25
  openStateDb,
26
+ quarantineFiles,
26
27
  readBindingConfig,
28
+ readMerges,
27
29
  readNotSynced,
28
30
  removeImport,
29
31
  revoke,
30
32
  safeResolveRigPath,
31
33
  start
32
- } from "./chunk-7RKYNS5V.js";
34
+ } from "./chunk-S5AVBVLP.js";
33
35
 
34
36
  // src/bin.ts
35
37
  import { join as pathJoin, resolve } from "path";
@@ -266,9 +268,9 @@ async function restore(opts) {
266
268
  const overwrote = existsSync3(targetAbs);
267
269
  mkdirSync2(dirname2(targetAbs), { recursive: true });
268
270
  const tmp = `${targetAbs}.tap-restore-tmp.${Date.now().toString(36)}`;
269
- const mode = writeEvent.executable ? 493 : 420;
270
- writeFileSync2(tmp, bytes, { mode });
271
+ writeFileSync2(tmp, bytes, { mode: 420 });
271
272
  renameSync(tmp, targetAbs);
273
+ await quarantineFiles([targetAbs]);
272
274
  return {
273
275
  path: opts.path,
274
276
  restoredFromCursor: writeEvent.id,
@@ -283,7 +285,7 @@ import { existsSync as existsSync4 } from "fs";
283
285
  import { join as join4 } from "path";
284
286
 
285
287
  // src/version.ts
286
- var TAPD_VERSION = "0.6.5";
288
+ var TAPD_VERSION = "0.6.8";
287
289
 
288
290
  // src/status.ts
289
291
  var STATE_KEY_LAST_APPLY_ERROR = "last_apply_error";
@@ -306,6 +308,7 @@ function statusToJson(report) {
306
308
  pendingUploads: report.pendingUploads,
307
309
  notSynced: report.notSynced,
308
310
  conflicts: report.conflicts,
311
+ merged: report.merged,
309
312
  lastApplyError: report.lastApplyError,
310
313
  offline: report.offline,
311
314
  mounts: report.mounts
@@ -362,6 +365,7 @@ async function status(opts) {
362
365
  notSynced: [],
363
366
  conflicts: [],
364
367
  conflictCount: 0,
368
+ merged: [],
365
369
  lastApplyError: null,
366
370
  daemon,
367
371
  offline: false,
@@ -423,6 +427,7 @@ async function status(opts) {
423
427
  notSynced: readNotSynced(db),
424
428
  conflicts,
425
429
  conflictCount,
430
+ merged: readMerges(db),
426
431
  lastApplyError,
427
432
  daemon,
428
433
  offline,
@@ -596,6 +601,8 @@ ${C.bold().cyan("tapd init OPTIONS")}
596
601
  ${C.dim("--relay <url>")} override (defaults to the logged-in relay)
597
602
  ${C.dim("--device-label <l>")} default 'owner'
598
603
  ${C.dim("--org <slug>")} create this binding under an org you belong to
604
+ ${C.dim("--kind <rig|space>")} create it as a space (default: rig)
605
+ ${C.dim("--defer-upload")} create the binding only; \`tapd start\` uploads the files
599
606
  ${C.dim("--dir <path>")} default cwd
600
607
 
601
608
  ${C.bold().cyan("tapd join OPTIONS")}
@@ -1135,6 +1142,12 @@ async function runStatus(flags2) {
1135
1142
  } else {
1136
1143
  console.log(` conflicts: ${C.dim("none")}`);
1137
1144
  }
1145
+ if (report.merged.length > 0) {
1146
+ console.log(` merged: ${report.merged.length} ${C.dim("(local + remote edits merged automatically, recent)")}`);
1147
+ for (const m of report.merged.slice(-5)) {
1148
+ console.log(C.dim(` ${m.path} with ${m.theirsChangeId}${m.changeId ? ` \u2192 ${m.changeId}` : " (upload pending)"} ${m.at}`));
1149
+ }
1150
+ }
1138
1151
  if (report.lastApplyError) {
1139
1152
  const e = report.lastApplyError;
1140
1153
  console.log(
@@ -1158,6 +1171,20 @@ async function runStatus(flags2) {
1158
1171
  );
1159
1172
  for (const f of tooLarge) console.log(C.dim(` ${f.path}`));
1160
1173
  }
1174
+ const ownerOnly = report.notSynced.filter((f) => f.reason === "owner_only");
1175
+ if (ownerOnly.length > 0) {
1176
+ console.log(
1177
+ ` ${C.yellow(`${plural(ownerOnly.length)} not synced`)}: agent instructions only the space's owner can change`
1178
+ );
1179
+ for (const f of ownerOnly) console.log(C.dim(` ${f.path}`));
1180
+ }
1181
+ const protectedPaths = report.notSynced.filter((f) => f.reason === "protected");
1182
+ if (protectedPaths.length > 0) {
1183
+ console.log(
1184
+ ` ${C.yellow(`${plural(protectedPaths.length)} not synced`)}: protected paths never sync between members`
1185
+ );
1186
+ for (const f of protectedPaths) console.log(C.dim(` ${f.path}`));
1187
+ }
1161
1188
  } else {
1162
1189
  console.log(C.dim(" (import-only meta-rig \u2014 no primary binding)"));
1163
1190
  }
@@ -1426,9 +1453,18 @@ async function runInit(flags2) {
1426
1453
  process.exit(2);
1427
1454
  }
1428
1455
  const org = orgRaw;
1456
+ const kindRaw = flags2.get("kind");
1457
+ if (kindRaw !== void 0 && kindRaw !== "rig" && kindRaw !== "space") {
1458
+ const msg = "--kind must be rig or space";
1459
+ if (json) printJsonError("invalid_flag", msg);
1460
+ else console.error(kleur.red("error:"), msg);
1461
+ process.exit(2);
1462
+ }
1463
+ const kind = kindRaw;
1464
+ const deferUpload = flags2.get("defer-upload") === true;
1429
1465
  let result;
1430
1466
  try {
1431
- result = await init({ rootDir, relayUrl, accessToken, bindingName: name, deviceLabel, org });
1467
+ result = await init({ rootDir, relayUrl, accessToken, bindingName: name, deviceLabel, org, kind, deferUpload });
1432
1468
  } catch (err) {
1433
1469
  if (err instanceof AlreadyInitializedError) {
1434
1470
  if (json) printJsonError("already_initialized", err.message);
@@ -1450,6 +1486,8 @@ async function runInit(flags2) {
1450
1486
  protocolVersion: PROTOCOL_VERSION,
1451
1487
  bindingId: result.binding.id,
1452
1488
  bindingName: result.binding.name,
1489
+ // What the relay made (an older relay ignores `kind` and says nothing).
1490
+ kind: result.binding.kind ?? null,
1453
1491
  deviceId: result.device.id,
1454
1492
  deviceLabel: result.device.label,
1455
1493
  relayUrl,
@@ -1458,6 +1496,7 @@ async function runInit(flags2) {
1458
1496
  reusedHashes: result.reusedHashes,
1459
1497
  submittedEvents: result.submittedEvents,
1460
1498
  cursor: result.cursor,
1499
+ deferredUpload: result.deferredUpload,
1461
1500
  warnings: result.warnings
1462
1501
  });
1463
1502
  return;