@wayai/cli 0.3.338 → 0.3.339

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/index.js CHANGED
@@ -38921,17 +38921,55 @@ var init_case_review = __esm({
38921
38921
  }
38922
38922
  });
38923
38923
 
38924
+ // ../../packages/core/dist/contracts/case-file-paths.js
38925
+ var init_case_file_paths = __esm({
38926
+ "../../packages/core/dist/contracts/case-file-paths.js"() {
38927
+ "use strict";
38928
+ init_chunk_KWRHZBGU();
38929
+ init_chunk_FBV7NLKO();
38930
+ init_chunk_WEXVYJ5H();
38931
+ init_chunk_HZ6CADSY();
38932
+ init_chunk_ICYO56QW();
38933
+ init_chunk_WFQDSQJK();
38934
+ }
38935
+ });
38936
+
38937
+ // ../../packages/core/dist/contracts/case-types.js
38938
+ var init_case_types = __esm({
38939
+ "../../packages/core/dist/contracts/case-types.js"() {
38940
+ "use strict";
38941
+ init_chunk_PFPADFUC();
38942
+ init_chunk_KWRHZBGU();
38943
+ init_chunk_3T3D7LTE();
38944
+ init_chunk_M2T55BV6();
38945
+ init_chunk_VYINA6YP();
38946
+ init_chunk_ZVXO3XL6();
38947
+ init_chunk_FBV7NLKO();
38948
+ init_chunk_WEXVYJ5H();
38949
+ init_chunk_HZ6CADSY();
38950
+ init_chunk_ICYO56QW();
38951
+ init_chunk_WFQDSQJK();
38952
+ init_chunk_ZTNFLGW5();
38953
+ }
38954
+ });
38955
+
38924
38956
  // src/cases/case-clone-record.ts
38925
38957
  import * as fs30 from "fs";
38926
38958
  import * as path42 from "path";
38959
+ function isClonePath(rel) {
38960
+ return isCasePath(rel, rel.split("/").filter((segment2) => CASE_PHASE_FOLDER_PATTERN.test(segment2)));
38961
+ }
38962
+ function assertClonePaths(root, record, phaseFolders) {
38963
+ if (!Object.keys(record.files).every((rel) => isCasePath(rel, phaseFolders))) throw notAMarker(path42.join(root, CASE_CLONE_RECORD_FILE));
38964
+ }
38927
38965
  function isCloneRecord(value) {
38928
38966
  if (typeof value !== "object" || value === null) return false;
38929
38967
  const v = value;
38930
38968
  if (typeof v.org_id !== "string" || typeof v.space_id !== "string" || typeof v.code !== "string") return false;
38931
38969
  if (typeof v.files !== "object" || v.files === null || Array.isArray(v.files)) return false;
38932
- return Object.values(v.files).every((f) => {
38970
+ return Object.entries(v.files).every(([rel, f]) => {
38933
38971
  const e = f;
38934
- return typeof e === "object" && e !== null && typeof e.sha === "string" && CASE_FILE_SHA_PATTERN.test(e.sha) && typeof e.confidential === "boolean";
38972
+ return isClonePath(rel) && typeof e === "object" && e !== null && typeof e.sha === "string" && CASE_FILE_SHA_PATTERN.test(e.sha) && typeof e.confidential === "boolean";
38935
38973
  });
38936
38974
  }
38937
38975
  function readCloneRecord(root) {
@@ -38957,9 +38995,7 @@ function readCloneRecord(root) {
38957
38995
  } catch {
38958
38996
  parsed = void 0;
38959
38997
  }
38960
- if (!isCloneRecord(parsed)) {
38961
- throw expected(`${sanitizeTerminalText(file)} is not a marker \`wayai cases clone\` wrote. Move it aside and clone the case again.`);
38962
- }
38998
+ if (!isCloneRecord(parsed)) throw notAMarker(file);
38963
38999
  return parsed;
38964
39000
  }
38965
39001
  function writeCloneRecord(root, record) {
@@ -38992,7 +39028,7 @@ function findCaseClone(from) {
38992
39028
  dir = parent;
38993
39029
  }
38994
39030
  }
38995
- var CASE_CLONE_RECORD_FILE, sameCase;
39031
+ var CASE_CLONE_RECORD_FILE, isCasePath, notAMarker, sameCase;
38996
39032
  var init_case_clone_record = __esm({
38997
39033
  "src/cases/case-clone-record.ts"() {
38998
39034
  "use strict";
@@ -39000,7 +39036,11 @@ var init_case_clone_record = __esm({
39000
39036
  init_fs_safety();
39001
39037
  init_terminal_output();
39002
39038
  init_case_files();
39039
+ init_case_file_paths();
39040
+ init_case_types();
39003
39041
  CASE_CLONE_RECORD_FILE = ".wayai-case.json";
39042
+ isCasePath = (rel, phaseFolders) => checkCaseFilePath({ path: rel, type: "file" }, phaseFolders).ok;
39043
+ notAMarker = (file) => expected(`${sanitizeTerminalText(file)} is not a marker \`wayai cases clone\` wrote. Move it aside and clone the case again.`);
39004
39044
  sameCase = (a, b) => a.org_id === b.org_id && a.space_id === b.space_id && a.code === b.code;
39005
39045
  }
39006
39046
  });
@@ -39723,19 +39763,6 @@ var init_case_work = __esm({
39723
39763
  }
39724
39764
  });
39725
39765
 
39726
- // ../../packages/core/dist/contracts/case-file-paths.js
39727
- var init_case_file_paths = __esm({
39728
- "../../packages/core/dist/contracts/case-file-paths.js"() {
39729
- "use strict";
39730
- init_chunk_KWRHZBGU();
39731
- init_chunk_FBV7NLKO();
39732
- init_chunk_WEXVYJ5H();
39733
- init_chunk_HZ6CADSY();
39734
- init_chunk_ICYO56QW();
39735
- init_chunk_WFQDSQJK();
39736
- }
39737
- });
39738
-
39739
39766
  // src/data/files-sync/local.ts
39740
39767
  import * as fs34 from "fs";
39741
39768
  import * as path46 from "path";
@@ -40629,25 +40656,6 @@ var init_case_comments = __esm({
40629
40656
  }
40630
40657
  });
40631
40658
 
40632
- // ../../packages/core/dist/contracts/case-types.js
40633
- var init_case_types = __esm({
40634
- "../../packages/core/dist/contracts/case-types.js"() {
40635
- "use strict";
40636
- init_chunk_PFPADFUC();
40637
- init_chunk_KWRHZBGU();
40638
- init_chunk_3T3D7LTE();
40639
- init_chunk_M2T55BV6();
40640
- init_chunk_VYINA6YP();
40641
- init_chunk_ZVXO3XL6();
40642
- init_chunk_FBV7NLKO();
40643
- init_chunk_WEXVYJ5H();
40644
- init_chunk_HZ6CADSY();
40645
- init_chunk_ICYO56QW();
40646
- init_chunk_WFQDSQJK();
40647
- init_chunk_ZTNFLGW5();
40648
- }
40649
- });
40650
-
40651
40659
  // src/cases/case-mirror.ts
40652
40660
  import * as crypto4 from "crypto";
40653
40661
  import * as fs35 from "fs";
@@ -41270,6 +41278,7 @@ async function pullInto(calls, detail, record, opts) {
41270
41278
  const files = await calls.files();
41271
41279
  assertWritableCasePaths([...sidesOf(record, /* @__PURE__ */ new Map(), files, opts.confidential).listed.keys()], phaseFolders);
41272
41280
  const root = opts.root();
41281
+ assertClonePaths(root, record, phaseFolders);
41273
41282
  mirrorFolder(root);
41274
41283
  const local = scanClone(root, phaseFolders, opts.confidential);
41275
41284
  const { synced: synced2, local: localIn, remote, listed: listed3, theirsListed } = sidesOf(record, local, files, opts.confidential);
@@ -41445,6 +41454,7 @@ async function casePullMirror(opts) {
41445
41454
  mirrorFolder(root);
41446
41455
  await withMirrorLock(root, async () => {
41447
41456
  const record = readCloneRecord(root) ?? opened;
41457
+ assertClonePaths(root, record, phaseFoldersOf(detail));
41448
41458
  const files = await calls.files();
41449
41459
  await writeCaseMirror(calls, {
41450
41460
  root,
@@ -41527,6 +41537,7 @@ async function casePush(opts) {
41527
41537
  throw expected(`Your access to case ${safe3(detail.code)} does not write its files: that takes Edit level, on an open case.`);
41528
41538
  }
41529
41539
  const phaseFolders = phaseFoldersOf(detail);
41540
+ assertClonePaths(root, record, phaseFolders);
41530
41541
  const scanned = scanClone(root, phaseFolders, opts.confidential);
41531
41542
  const listing = await calls.files();
41532
41543
  const outside = outsideRun(record, listing, opts.confidential);