@lace-cloud/canvas 0.29.0 → 0.31.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.
@@ -29,6 +29,7 @@ __export(engine_exports, {
29
29
  CommandUnobservedError: () => CommandUnobservedError,
30
30
  ConnectError: () => ConnectError,
31
31
  EMPTY_REPORT_FOLD: () => EMPTY_REPORT_FOLD,
32
+ GENERATE_STAGES: () => GENERATE_STAGES,
32
33
  InputMode: () => InputMode,
33
34
  Reason: () => Reason,
34
35
  SCHEMAS: () => SCHEMAS,
@@ -36,6 +37,7 @@ __export(engine_exports, {
36
37
  autosave: () => autosave,
37
38
  bridgeCaller: () => bridgeCaller,
38
39
  carriesFailure: () => carriesFailure,
40
+ commandPathOf: () => commandPathOf,
39
41
  commandUnderWay: () => commandUnderWay,
40
42
  connectCaller: () => connectCaller,
41
43
  createActionRunner: () => createActionRunner,
@@ -46,6 +48,7 @@ __export(engine_exports, {
46
48
  diagnosticsOfDocument: () => diagnosticsOfDocument,
47
49
  failureSays: () => failureSays,
48
50
  foldReport: () => foldReport,
51
+ generatedTree: () => generatedTree,
49
52
  isBoundPath: () => isBoundPath,
50
53
  liveSlots: () => liveSlots,
51
54
  openEngineCommands: () => openEngineCommands,
@@ -3450,6 +3453,7 @@ var Reason = /* @__PURE__ */ ((Reason2) => {
3450
3453
  Reason2[Reason2["REASON_NO_ORIGIN_REMOTE"] = 19] = "REASON_NO_ORIGIN_REMOTE";
3451
3454
  Reason2[Reason2["REASON_IMPORT_UNDECLARED"] = 20] = "REASON_IMPORT_UNDECLARED";
3452
3455
  Reason2[Reason2["REASON_ALREADY_IMPORTED"] = 21] = "REASON_ALREADY_IMPORTED";
3456
+ Reason2[Reason2["REASON_NO_LOCKFILE"] = 22] = "REASON_NO_LOCKFILE";
3453
3457
  Reason2[Reason2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
3454
3458
  return Reason2;
3455
3459
  })(Reason || {});
@@ -3521,6 +3525,9 @@ function reasonFromJSON(object) {
3521
3525
  case 21:
3522
3526
  case "REASON_ALREADY_IMPORTED":
3523
3527
  return 21 /* REASON_ALREADY_IMPORTED */;
3528
+ case 22:
3529
+ case "REASON_NO_LOCKFILE":
3530
+ return 22 /* REASON_NO_LOCKFILE */;
3524
3531
  case -1:
3525
3532
  case "UNRECOGNIZED":
3526
3533
  default:
@@ -3573,6 +3580,8 @@ function reasonToJSON(object) {
3573
3580
  return "REASON_IMPORT_UNDECLARED";
3574
3581
  case 21 /* REASON_ALREADY_IMPORTED */:
3575
3582
  return "REASON_ALREADY_IMPORTED";
3583
+ case 22 /* REASON_NO_LOCKFILE */:
3584
+ return "REASON_NO_LOCKFILE";
3576
3585
  case -1 /* UNRECOGNIZED */:
3577
3586
  default:
3578
3587
  return "UNRECOGNIZED";
@@ -4492,13 +4501,19 @@ var SessionGenerateRequest = {
4492
4501
  }
4493
4502
  };
4494
4503
  function createBaseSessionGenerateResponse() {
4495
- return { files_written: [], validate_json: "", revision: 0 };
4504
+ return { files_written: [], files_changed: [], files_removed: [], validate_json: "", revision: 0 };
4496
4505
  }
4497
4506
  var SessionGenerateResponse = {
4498
4507
  encode(message, writer = new import_wire4.BinaryWriter()) {
4499
4508
  for (const v of message.files_written) {
4500
4509
  writer.uint32(10).string(v);
4501
4510
  }
4511
+ for (const v of message.files_changed) {
4512
+ writer.uint32(50).string(v);
4513
+ }
4514
+ for (const v of message.files_removed) {
4515
+ writer.uint32(58).string(v);
4516
+ }
4502
4517
  if (message.validate_json !== "") {
4503
4518
  writer.uint32(34).string(message.validate_json);
4504
4519
  }
@@ -4521,6 +4536,20 @@ var SessionGenerateResponse = {
4521
4536
  message.files_written.push(reader.string());
4522
4537
  continue;
4523
4538
  }
4539
+ case 6: {
4540
+ if (tag !== 50) {
4541
+ break;
4542
+ }
4543
+ message.files_changed.push(reader.string());
4544
+ continue;
4545
+ }
4546
+ case 7: {
4547
+ if (tag !== 58) {
4548
+ break;
4549
+ }
4550
+ message.files_removed.push(reader.string());
4551
+ continue;
4552
+ }
4524
4553
  case 4: {
4525
4554
  if (tag !== 34) {
4526
4555
  break;
@@ -4546,6 +4575,8 @@ var SessionGenerateResponse = {
4546
4575
  fromJSON(object) {
4547
4576
  return {
4548
4577
  files_written: globalThis.Array.isArray(object?.filesWritten) ? object.filesWritten.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_written) ? object.files_written.map((e) => globalThis.String(e)) : [],
4578
+ files_changed: globalThis.Array.isArray(object?.filesChanged) ? object.filesChanged.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_changed) ? object.files_changed.map((e) => globalThis.String(e)) : [],
4579
+ files_removed: globalThis.Array.isArray(object?.filesRemoved) ? object.filesRemoved.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_removed) ? object.files_removed.map((e) => globalThis.String(e)) : [],
4549
4580
  validate_json: isSet3(object.validateJson) ? globalThis.String(object.validateJson) : isSet3(object.validate_json) ? globalThis.String(object.validate_json) : "",
4550
4581
  revision: isSet3(object.revision) ? globalThis.Number(object.revision) : 0
4551
4582
  };
@@ -4555,6 +4586,12 @@ var SessionGenerateResponse = {
4555
4586
  if (message.files_written?.length) {
4556
4587
  obj.filesWritten = message.files_written;
4557
4588
  }
4589
+ if (message.files_changed?.length) {
4590
+ obj.filesChanged = message.files_changed;
4591
+ }
4592
+ if (message.files_removed?.length) {
4593
+ obj.filesRemoved = message.files_removed;
4594
+ }
4558
4595
  if (message.validate_json !== "") {
4559
4596
  obj.validateJson = message.validate_json;
4560
4597
  }
@@ -4569,6 +4606,8 @@ var SessionGenerateResponse = {
4569
4606
  fromPartial(object) {
4570
4607
  const message = createBaseSessionGenerateResponse();
4571
4608
  message.files_written = object.files_written?.map((e) => e) || [];
4609
+ message.files_changed = object.files_changed?.map((e) => e) || [];
4610
+ message.files_removed = object.files_removed?.map((e) => e) || [];
4572
4611
  message.validate_json = object.validate_json ?? "";
4573
4612
  message.revision = object.revision ?? 0;
4574
4613
  return message;
@@ -8489,13 +8528,19 @@ var GenerateProgress = {
8489
8528
  }
8490
8529
  };
8491
8530
  function createBaseGenerateSuccess() {
8492
- return { files_written: [], validate_json: "", generate_id: "" };
8531
+ return { files_written: [], files_changed: [], files_removed: [], validate_json: "", generate_id: "" };
8493
8532
  }
8494
8533
  var GenerateSuccess = {
8495
8534
  encode(message, writer = new import_wire4.BinaryWriter()) {
8496
8535
  for (const v of message.files_written) {
8497
8536
  writer.uint32(10).string(v);
8498
8537
  }
8538
+ for (const v of message.files_changed) {
8539
+ writer.uint32(42).string(v);
8540
+ }
8541
+ for (const v of message.files_removed) {
8542
+ writer.uint32(50).string(v);
8543
+ }
8499
8544
  if (message.validate_json !== "") {
8500
8545
  writer.uint32(26).string(message.validate_json);
8501
8546
  }
@@ -8518,6 +8563,20 @@ var GenerateSuccess = {
8518
8563
  message.files_written.push(reader.string());
8519
8564
  continue;
8520
8565
  }
8566
+ case 5: {
8567
+ if (tag !== 42) {
8568
+ break;
8569
+ }
8570
+ message.files_changed.push(reader.string());
8571
+ continue;
8572
+ }
8573
+ case 6: {
8574
+ if (tag !== 50) {
8575
+ break;
8576
+ }
8577
+ message.files_removed.push(reader.string());
8578
+ continue;
8579
+ }
8521
8580
  case 3: {
8522
8581
  if (tag !== 26) {
8523
8582
  break;
@@ -8543,6 +8602,8 @@ var GenerateSuccess = {
8543
8602
  fromJSON(object) {
8544
8603
  return {
8545
8604
  files_written: globalThis.Array.isArray(object?.filesWritten) ? object.filesWritten.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_written) ? object.files_written.map((e) => globalThis.String(e)) : [],
8605
+ files_changed: globalThis.Array.isArray(object?.filesChanged) ? object.filesChanged.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_changed) ? object.files_changed.map((e) => globalThis.String(e)) : [],
8606
+ files_removed: globalThis.Array.isArray(object?.filesRemoved) ? object.filesRemoved.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.files_removed) ? object.files_removed.map((e) => globalThis.String(e)) : [],
8546
8607
  validate_json: isSet3(object.validateJson) ? globalThis.String(object.validateJson) : isSet3(object.validate_json) ? globalThis.String(object.validate_json) : "",
8547
8608
  generate_id: isSet3(object.generateId) ? globalThis.String(object.generateId) : isSet3(object.generate_id) ? globalThis.String(object.generate_id) : ""
8548
8609
  };
@@ -8552,6 +8613,12 @@ var GenerateSuccess = {
8552
8613
  if (message.files_written?.length) {
8553
8614
  obj.filesWritten = message.files_written;
8554
8615
  }
8616
+ if (message.files_changed?.length) {
8617
+ obj.filesChanged = message.files_changed;
8618
+ }
8619
+ if (message.files_removed?.length) {
8620
+ obj.filesRemoved = message.files_removed;
8621
+ }
8555
8622
  if (message.validate_json !== "") {
8556
8623
  obj.validateJson = message.validate_json;
8557
8624
  }
@@ -8566,6 +8633,8 @@ var GenerateSuccess = {
8566
8633
  fromPartial(object) {
8567
8634
  const message = createBaseGenerateSuccess();
8568
8635
  message.files_written = object.files_written?.map((e) => e) || [];
8636
+ message.files_changed = object.files_changed?.map((e) => e) || [];
8637
+ message.files_removed = object.files_removed?.map((e) => e) || [];
8569
8638
  message.validate_json = object.validate_json ?? "";
8570
8639
  message.generate_id = object.generate_id ?? "";
8571
8640
  return message;
@@ -10518,6 +10587,22 @@ function isSet3(value) {
10518
10587
 
10519
10588
  // src/ports.ts
10520
10589
  var import_proto = require("@lace-cloud/proto");
10590
+ var GENERATE_STAGES = ["generating", "validating"];
10591
+ function isGenerateStage(stage) {
10592
+ return GENERATE_STAGES.some((known) => known === stage);
10593
+ }
10594
+ function generatedTree({
10595
+ written,
10596
+ changed,
10597
+ removed
10598
+ }) {
10599
+ return {
10600
+ changed,
10601
+ removed,
10602
+ unchanged: written.length - changed.length,
10603
+ treeChanged: changed.length > 0 || removed.length > 0
10604
+ };
10605
+ }
10521
10606
  var ApplyUnobservedError = class extends Error {
10522
10607
  constructor(end) {
10523
10608
  super(`unobserved: the source stopped (${end.kind}) before the frame that carries the write`);
@@ -10915,6 +11000,30 @@ function bridgeCaller(bridge) {
10915
11000
  // src/adapters/engine/mapping.ts
10916
11001
  var import_proto2 = require("@lace-cloud/proto");
10917
11002
 
11003
+ // scripts/command-tree.mjs
11004
+ var EFFECTS = /* @__PURE__ */ new Map([
11005
+ ["writes", "write"],
11006
+ ["rewrites", "rewrite"]
11007
+ ]);
11008
+ var RESERVED = /* @__PURE__ */ new Set(["hidden", ...EFFECTS.keys()]);
11009
+ function commandWordsAt(words, { isNode: isNode2, rootFlags }) {
11010
+ const standsAlone = new Set(
11011
+ rootFlags.filter((f) => f.type === "bool").flatMap((f) => [`--${f.name}`, ...f.short ? [`-${f.short}`] : []])
11012
+ );
11013
+ const at = [];
11014
+ for (let i = 0; i < words.length; i++) {
11015
+ const word = words[i];
11016
+ if (word === "--") return { at, stop: i };
11017
+ if (word !== "" && !word.startsWith("-")) {
11018
+ if (!isNode2([...at.map((j) => words[j]), word].join(" "))) return { at, stop: i };
11019
+ at.push(i);
11020
+ } else if (!word.includes("=") && (word.startsWith("--") || word.length === 2) && !standsAlone.has(word)) {
11021
+ i++;
11022
+ }
11023
+ }
11024
+ return { at, stop: words.length };
11025
+ }
11026
+
10918
11027
  // src/contracts/commands.gen.ts
10919
11028
  var COMMANDS = {
10920
11029
  "chaos run": {
@@ -10960,7 +11069,8 @@ var COMMANDS = {
10960
11069
  "values": [
10961
11070
  "table",
10962
11071
  "json"
10963
- ]
11072
+ ],
11073
+ "short": "o"
10964
11074
  },
10965
11075
  "prUrl": {
10966
11076
  "type": "string"
@@ -11015,7 +11125,8 @@ var COMMANDS = {
11015
11125
  "values": [
11016
11126
  "table",
11017
11127
  "json"
11018
- ]
11128
+ ],
11129
+ "short": "o"
11019
11130
  },
11020
11131
  "team": {
11021
11132
  "type": "string"
@@ -11037,7 +11148,8 @@ var COMMANDS = {
11037
11148
  "values": [
11038
11149
  "table",
11039
11150
  "json"
11040
- ]
11151
+ ],
11152
+ "short": "o"
11041
11153
  },
11042
11154
  "provider": {
11043
11155
  "type": "string"
@@ -11058,7 +11170,8 @@ var COMMANDS = {
11058
11170
  "type": "bool"
11059
11171
  },
11060
11172
  "path": {
11061
- "type": "string"
11173
+ "type": "string",
11174
+ "short": "p"
11062
11175
  }
11063
11176
  },
11064
11177
  "effect": "write",
@@ -11070,7 +11183,8 @@ var COMMANDS = {
11070
11183
  "positionals": [],
11071
11184
  "flags": {
11072
11185
  "path": {
11073
- "type": "string"
11186
+ "type": "string",
11187
+ "short": "p"
11074
11188
  }
11075
11189
  },
11076
11190
  "effect": "write",
@@ -11104,7 +11218,8 @@ var COMMANDS = {
11104
11218
  "values": [
11105
11219
  "table",
11106
11220
  "json"
11107
- ]
11221
+ ],
11222
+ "short": "o"
11108
11223
  },
11109
11224
  "provider": {
11110
11225
  "type": "string"
@@ -11126,7 +11241,8 @@ var COMMANDS = {
11126
11241
  "values": [
11127
11242
  "table",
11128
11243
  "json"
11129
- ]
11244
+ ],
11245
+ "short": "o"
11130
11246
  }
11131
11247
  },
11132
11248
  "effect": "write",
@@ -11142,10 +11258,12 @@ var COMMANDS = {
11142
11258
  "values": [
11143
11259
  "table",
11144
11260
  "json"
11145
- ]
11261
+ ],
11262
+ "short": "o"
11146
11263
  },
11147
11264
  "path": {
11148
- "type": "string"
11265
+ "type": "string",
11266
+ "short": "p"
11149
11267
  }
11150
11268
  },
11151
11269
  "effect": "rewrite",
@@ -11166,10 +11284,12 @@ var COMMANDS = {
11166
11284
  "json",
11167
11285
  "terraform-docs-json",
11168
11286
  "terraform-docs-yaml"
11169
- ]
11287
+ ],
11288
+ "short": "o"
11170
11289
  },
11171
11290
  "path": {
11172
- "type": "string"
11291
+ "type": "string",
11292
+ "short": "p"
11173
11293
  }
11174
11294
  },
11175
11295
  "effect": "write",
@@ -11191,10 +11311,12 @@ var COMMANDS = {
11191
11311
  "values": [
11192
11312
  "table",
11193
11313
  "json"
11194
- ]
11314
+ ],
11315
+ "short": "o"
11195
11316
  },
11196
11317
  "path": {
11197
- "type": "string"
11318
+ "type": "string",
11319
+ "short": "p"
11198
11320
  },
11199
11321
  "recursive": {
11200
11322
  "type": "bool"
@@ -11216,10 +11338,12 @@ var COMMANDS = {
11216
11338
  "values": [
11217
11339
  "table",
11218
11340
  "json"
11219
- ]
11341
+ ],
11342
+ "short": "o"
11220
11343
  },
11221
11344
  "path": {
11222
- "type": "string"
11345
+ "type": "string",
11346
+ "short": "p"
11223
11347
  },
11224
11348
  "upgrade": {
11225
11349
  "type": "stringArray",
@@ -11243,10 +11367,12 @@ var COMMANDS = {
11243
11367
  "sarif",
11244
11368
  "junit",
11245
11369
  "checkstyle"
11246
- ]
11370
+ ],
11371
+ "short": "o"
11247
11372
  },
11248
11373
  "path": {
11249
- "type": "string"
11374
+ "type": "string",
11375
+ "short": "p"
11250
11376
  },
11251
11377
  "severity": {
11252
11378
  "type": "string",
@@ -11277,10 +11403,12 @@ var COMMANDS = {
11277
11403
  "values": [
11278
11404
  "table",
11279
11405
  "json"
11280
- ]
11406
+ ],
11407
+ "short": "o"
11281
11408
  },
11282
11409
  "path": {
11283
- "type": "string"
11410
+ "type": "string",
11411
+ "short": "p"
11284
11412
  },
11285
11413
  "view": {
11286
11414
  "type": "string",
@@ -11303,7 +11431,8 @@ var COMMANDS = {
11303
11431
  "values": [
11304
11432
  "table",
11305
11433
  "json"
11306
- ]
11434
+ ],
11435
+ "short": "o"
11307
11436
  }
11308
11437
  },
11309
11438
  "effect": "read",
@@ -11319,7 +11448,8 @@ var COMMANDS = {
11319
11448
  "values": [
11320
11449
  "table",
11321
11450
  "json"
11322
- ]
11451
+ ],
11452
+ "short": "o"
11323
11453
  }
11324
11454
  },
11325
11455
  "effect": "read",
@@ -11340,7 +11470,8 @@ var COMMANDS = {
11340
11470
  "values": [
11341
11471
  "table",
11342
11472
  "json"
11343
- ]
11473
+ ],
11474
+ "short": "o"
11344
11475
  }
11345
11476
  },
11346
11477
  "effect": "write",
@@ -11364,7 +11495,8 @@ var COMMANDS = {
11364
11495
  "values": [
11365
11496
  "table",
11366
11497
  "json"
11367
- ]
11498
+ ],
11499
+ "short": "o"
11368
11500
  },
11369
11501
  "team": {
11370
11502
  "type": "string"
@@ -11386,7 +11518,8 @@ var COMMANDS = {
11386
11518
  "values": [
11387
11519
  "table",
11388
11520
  "json"
11389
- ]
11521
+ ],
11522
+ "short": "o"
11390
11523
  },
11391
11524
  "stack": {
11392
11525
  "type": "string"
@@ -11416,7 +11549,8 @@ var COMMANDS = {
11416
11549
  "values": [
11417
11550
  "table",
11418
11551
  "json"
11419
- ]
11552
+ ],
11553
+ "short": "o"
11420
11554
  },
11421
11555
  "version": {
11422
11556
  "type": "string"
@@ -11443,7 +11577,8 @@ var COMMANDS = {
11443
11577
  "values": [
11444
11578
  "table",
11445
11579
  "json"
11446
- ]
11580
+ ],
11581
+ "short": "o"
11447
11582
  },
11448
11583
  "view": {
11449
11584
  "type": "string",
@@ -11486,7 +11621,8 @@ var COMMANDS = {
11486
11621
  "values": [
11487
11622
  "table",
11488
11623
  "json"
11489
- ]
11624
+ ],
11625
+ "short": "o"
11490
11626
  },
11491
11627
  "query": {
11492
11628
  "type": "string"
@@ -11522,7 +11658,8 @@ var COMMANDS = {
11522
11658
  "values": [
11523
11659
  "table",
11524
11660
  "json"
11525
- ]
11661
+ ],
11662
+ "short": "o"
11526
11663
  },
11527
11664
  "readme": {
11528
11665
  "type": "string"
@@ -11548,7 +11685,8 @@ var COMMANDS = {
11548
11685
  "type": "string",
11549
11686
  "values": [
11550
11687
  "json"
11551
- ]
11688
+ ],
11689
+ "short": "o"
11552
11690
  },
11553
11691
  "team": {
11554
11692
  "type": "string"
@@ -11575,7 +11713,8 @@ var COMMANDS = {
11575
11713
  "values": [
11576
11714
  "table",
11577
11715
  "json"
11578
- ]
11716
+ ],
11717
+ "short": "o"
11579
11718
  },
11580
11719
  "reason": {
11581
11720
  "type": "string"
@@ -11608,7 +11747,8 @@ var COMMANDS = {
11608
11747
  "values": [
11609
11748
  "table",
11610
11749
  "json"
11611
- ]
11750
+ ],
11751
+ "short": "o"
11612
11752
  },
11613
11753
  "team": {
11614
11754
  "type": "string"
@@ -11642,7 +11782,8 @@ var COMMANDS = {
11642
11782
  "values": [
11643
11783
  "table",
11644
11784
  "json"
11645
- ]
11785
+ ],
11786
+ "short": "o"
11646
11787
  },
11647
11788
  "stack": {
11648
11789
  "type": "string"
@@ -11681,7 +11822,8 @@ var COMMANDS = {
11681
11822
  "values": [
11682
11823
  "table",
11683
11824
  "json"
11684
- ]
11825
+ ],
11826
+ "short": "o"
11685
11827
  },
11686
11828
  "team": {
11687
11829
  "type": "string"
@@ -11708,7 +11850,8 @@ var COMMANDS = {
11708
11850
  "values": [
11709
11851
  "table",
11710
11852
  "json"
11711
- ]
11853
+ ],
11854
+ "short": "o"
11712
11855
  },
11713
11856
  "team": {
11714
11857
  "type": "string"
@@ -11741,7 +11884,8 @@ var COMMANDS = {
11741
11884
  "values": [
11742
11885
  "table",
11743
11886
  "json"
11744
- ]
11887
+ ],
11888
+ "short": "o"
11745
11889
  },
11746
11890
  "prUrl": {
11747
11891
  "type": "string"
@@ -11792,7 +11936,8 @@ var COMMANDS = {
11792
11936
  "values": [
11793
11937
  "table",
11794
11938
  "json"
11795
- ]
11939
+ ],
11940
+ "short": "o"
11796
11941
  },
11797
11942
  "source": {
11798
11943
  "type": "string"
@@ -11831,7 +11976,8 @@ var COMMANDS = {
11831
11976
  "values": [
11832
11977
  "table",
11833
11978
  "json"
11834
- ]
11979
+ ],
11980
+ "short": "o"
11835
11981
  },
11836
11982
  "team": {
11837
11983
  "type": "string"
@@ -11867,7 +12013,8 @@ var COMMANDS = {
11867
12013
  "values": [
11868
12014
  "table",
11869
12015
  "json"
11870
- ]
12016
+ ],
12017
+ "short": "o"
11871
12018
  },
11872
12019
  "team": {
11873
12020
  "type": "string"
@@ -11903,7 +12050,8 @@ var COMMANDS = {
11903
12050
  "values": [
11904
12051
  "table",
11905
12052
  "json"
11906
- ]
12053
+ ],
12054
+ "short": "o"
11907
12055
  },
11908
12056
  "prUrl": {
11909
12057
  "type": "string"
@@ -11950,7 +12098,8 @@ var COMMANDS = {
11950
12098
  "values": [
11951
12099
  "table",
11952
12100
  "json"
11953
- ]
12101
+ ],
12102
+ "short": "o"
11954
12103
  },
11955
12104
  "team": {
11956
12105
  "type": "string"
@@ -11980,10 +12129,12 @@ var COMMANDS = {
11980
12129
  "values": [
11981
12130
  "table",
11982
12131
  "json"
11983
- ]
12132
+ ],
12133
+ "short": "o"
11984
12134
  },
11985
12135
  "path": {
11986
- "type": "string"
12136
+ "type": "string",
12137
+ "short": "p"
11987
12138
  },
11988
12139
  "state": {
11989
12140
  "type": "string",
@@ -12018,7 +12169,8 @@ var COMMANDS = {
12018
12169
  "values": [
12019
12170
  "table",
12020
12171
  "json"
12021
- ]
12172
+ ],
12173
+ "short": "o"
12022
12174
  },
12023
12175
  "source": {
12024
12176
  "type": "string"
@@ -12048,7 +12200,8 @@ var COMMANDS = {
12048
12200
  "values": [
12049
12201
  "table",
12050
12202
  "json"
12051
- ]
12203
+ ],
12204
+ "short": "o"
12052
12205
  },
12053
12206
  "team": {
12054
12207
  "type": "string"
@@ -12086,7 +12239,8 @@ var COMMANDS = {
12086
12239
  "values": [
12087
12240
  "table",
12088
12241
  "json"
12089
- ]
12242
+ ],
12243
+ "short": "o"
12090
12244
  },
12091
12245
  "team": {
12092
12246
  "type": "string"
@@ -12125,7 +12279,8 @@ var COMMANDS = {
12125
12279
  "values": [
12126
12280
  "table",
12127
12281
  "json"
12128
- ]
12282
+ ],
12283
+ "short": "o"
12129
12284
  },
12130
12285
  "sourcePath": {
12131
12286
  "type": "string"
@@ -12156,7 +12311,8 @@ var COMMANDS = {
12156
12311
  "values": [
12157
12312
  "table",
12158
12313
  "json"
12159
- ]
12314
+ ],
12315
+ "short": "o"
12160
12316
  }
12161
12317
  },
12162
12318
  "effect": "read",
@@ -12181,7 +12337,8 @@ var COMMANDS = {
12181
12337
  "values": [
12182
12338
  "table",
12183
12339
  "json"
12184
- ]
12340
+ ],
12341
+ "short": "o"
12185
12342
  }
12186
12343
  },
12187
12344
  "effect": "read",
@@ -12205,7 +12362,8 @@ var COMMANDS = {
12205
12362
  "values": [
12206
12363
  "table",
12207
12364
  "json"
12208
- ]
12365
+ ],
12366
+ "short": "o"
12209
12367
  }
12210
12368
  },
12211
12369
  "effect": "write",
@@ -12221,7 +12379,8 @@ var COMMANDS = {
12221
12379
  "values": [
12222
12380
  "table",
12223
12381
  "json"
12224
- ]
12382
+ ],
12383
+ "short": "o"
12225
12384
  }
12226
12385
  },
12227
12386
  "effect": "read",
@@ -12237,7 +12396,8 @@ var COMMANDS = {
12237
12396
  "values": [
12238
12397
  "table",
12239
12398
  "json"
12240
- ]
12399
+ ],
12400
+ "short": "o"
12241
12401
  }
12242
12402
  },
12243
12403
  "effect": "read",
@@ -12245,6 +12405,21 @@ var COMMANDS = {
12245
12405
  "yes": false
12246
12406
  }
12247
12407
  };
12408
+ function isCommandPath(path) {
12409
+ return Object.prototype.hasOwnProperty.call(COMMANDS, path);
12410
+ }
12411
+ var ROOT_FLAGS = [
12412
+ {
12413
+ "name": "auth-url",
12414
+ "type": "string",
12415
+ "short": null
12416
+ },
12417
+ {
12418
+ "name": "timeout",
12419
+ "type": "duration",
12420
+ "short": null
12421
+ }
12422
+ ];
12248
12423
  function dashed(name) {
12249
12424
  return name.replace(/([A-Z])/g, (m) => `-${m.toLowerCase()}`);
12250
12425
  }
@@ -12275,6 +12450,12 @@ function toArgv(path, args) {
12275
12450
  }
12276
12451
  return argv;
12277
12452
  }
12453
+ var isNode = (path) => Object.keys(COMMANDS).some((p) => p === path || p.startsWith(`${path} `));
12454
+ function commandPathOf(words) {
12455
+ const { at } = commandWordsAt(words, { isNode, rootFlags: ROOT_FLAGS });
12456
+ const path = at.map((i) => words[i]).join(" ");
12457
+ return isCommandPath(path) ? path : void 0;
12458
+ }
12278
12459
 
12279
12460
  // src/contracts/complete-args.ts
12280
12461
  function requiredArgKeys(path) {
@@ -12763,7 +12944,7 @@ var gateChangeRequestSchema = import_zod.z.object({
12763
12944
  });
12764
12945
  var runEventSchema = import_zod.z.discriminatedUnion("type", [
12765
12946
  import_zod.z.object({ type: import_zod.z.literal("log"), text: import_zod.z.string() }),
12766
- import_zod.z.object({ type: import_zod.z.literal("phase"), name: import_zod.z.string() }),
12947
+ import_zod.z.object({ type: import_zod.z.literal("stage"), name: import_zod.z.string() }),
12767
12948
  import_zod.z.object({
12768
12949
  type: import_zod.z.literal("gate"),
12769
12950
  resolution: import_zod.z.object({ mode: import_zod.z.string(), reason: import_zod.z.string().optional() }),
@@ -12776,7 +12957,6 @@ var runEventSchema = import_zod.z.discriminatedUnion("type", [
12776
12957
  type: import_zod.z.literal("result"),
12777
12958
  run: runSchema,
12778
12959
  summary: planSummarySchema,
12779
- workspaceDir: import_zod.z.string(),
12780
12960
  error: import_zod.z.string().nullable()
12781
12961
  })
12782
12962
  ]);
@@ -12790,7 +12970,6 @@ var stackScanSchema = import_zod.z.object({
12790
12970
  scannedAt: import_zod.z.string(),
12791
12971
  undeterminedReason: import_zod.z.string().nullable(),
12792
12972
  undeterminedMessage: import_zod.z.string().nullable(),
12793
- standingDriftFindings: import_zod.z.number(),
12794
12973
  footprintDestroyed: import_zod.z.boolean(),
12795
12974
  drift: driftSchema
12796
12975
  }).nullable()
@@ -12987,6 +13166,7 @@ async function openEngineSession(caller, target, options = {}) {
12987
13166
  const progressListeners = /* @__PURE__ */ new Set();
12988
13167
  const ownGenerates = /* @__PURE__ */ new Set();
12989
13168
  let sessionGenerating = initialState.generating;
13169
+ let stage = "generating";
12990
13170
  let currentSource = null;
12991
13171
  let ended = null;
12992
13172
  let deliveredRevision = initialState.revision;
@@ -12996,6 +13176,7 @@ async function openEngineSession(caller, target, options = {}) {
12996
13176
  const published = state.bundle ?? import_proto2.EMPTY_BUNDLE;
12997
13177
  const bundle = currentSource && deepEqual(currentSource.bundle, published) ? currentSource.bundle : published;
12998
13178
  sessionGenerating = state.generating;
13179
+ if (!running()) stage = "generating";
12999
13180
  currentSource = {
13000
13181
  bundle,
13001
13182
  canUndo: state.can_undo,
@@ -13017,16 +13198,27 @@ async function openEngineSession(caller, target, options = {}) {
13017
13198
  }
13018
13199
  }
13019
13200
  adopt(initialState);
13020
- function generating() {
13201
+ function running() {
13021
13202
  return sessionGenerating || ownGenerates.size > 0;
13022
13203
  }
13204
+ function generating() {
13205
+ return running() && stage;
13206
+ }
13207
+ function republishGenerating() {
13208
+ if (!currentSource || currentSource.generating === generating()) return;
13209
+ currentSource = { ...currentSource, generating: generating() };
13210
+ for (const listener of sourceListeners) deliver(listener, currentSource);
13211
+ }
13023
13212
  function track(id, on) {
13024
- const was = generating();
13025
13213
  if (on) ownGenerates.add(id);
13026
13214
  else ownGenerates.delete(id);
13027
- if (!currentSource || generating() === was) return;
13028
- currentSource = { ...currentSource, generating: generating() };
13029
- for (const listener of sourceListeners) deliver(listener, currentSource);
13215
+ if (!running()) stage = "generating";
13216
+ republishGenerating();
13217
+ }
13218
+ function reached(next) {
13219
+ if (!running() || !isGenerateStage(next)) return;
13220
+ stage = next;
13221
+ republishGenerating();
13030
13222
  }
13031
13223
  function observed(revision) {
13032
13224
  if (deliveredRevision >= revision) return Promise.resolve();
@@ -13072,6 +13264,7 @@ async function openEngineSession(caller, target, options = {}) {
13072
13264
  continue;
13073
13265
  }
13074
13266
  if (event.generate_progress) {
13267
+ reached(event.generate_progress.stage);
13075
13268
  for (const listener of progressListeners) listener(event.generate_progress);
13076
13269
  }
13077
13270
  }
@@ -13140,9 +13333,8 @@ async function openEngineSession(caller, target, options = {}) {
13140
13333
  track(generateId, true);
13141
13334
  const onProgress = (progress) => {
13142
13335
  if (progress.generate_id !== generateId) return;
13143
- const stage = progress.stage;
13144
- if (stage === "generating" || stage === "validating") {
13145
- queue.push({ type: "progress", stage });
13336
+ if (isGenerateStage(progress.stage)) {
13337
+ queue.push({ type: "progress", stage: progress.stage });
13146
13338
  }
13147
13339
  };
13148
13340
  progressListeners.add(onProgress);
@@ -13261,6 +13453,8 @@ function generated(response) {
13261
13453
  return {
13262
13454
  type: "success",
13263
13455
  written: response.files_written,
13456
+ changed: response.files_changed,
13457
+ removed: response.files_removed,
13264
13458
  validate: parseBound("module validate", JSON.parse(response.validate_json))
13265
13459
  };
13266
13460
  }
@@ -13301,6 +13495,11 @@ function convertCreatedRef(r) {
13301
13495
  return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
13302
13496
  }
13303
13497
 
13498
+ // src/utils/counted.ts
13499
+ function counted(n, noun) {
13500
+ return `${n} ${noun}${n === 1 ? "" : "s"}`;
13501
+ }
13502
+
13304
13503
  // src/core/diagnostics.ts
13305
13504
  var NOT_LACE_SHAPE = "not_lace_shape";
13306
13505
  function holdsLaceShapeRefusal(diagnostics) {
@@ -13436,46 +13635,50 @@ function commandUnderWay({
13436
13635
  }) {
13437
13636
  return run?.outcome.kind === "running" || preview2?.outcome.kind === "running" || running.size > 0;
13438
13637
  }
13439
- function withPhase(phases, name) {
13440
- return [...phases.map((p) => ({ ...p, status: "done" })), { name, status: "current" }];
13638
+ function withStage(stages, name) {
13639
+ return [...stages.map((s) => ({ ...s, status: "done" })), { name, status: "current" }];
13441
13640
  }
13442
- function closePhases(phases) {
13443
- return phases.map((p) => p.status === "done" ? p : { ...p, status: "done" });
13641
+ function closeStages(stages) {
13642
+ return stages.map((s) => s.status === "done" ? s : { ...s, status: "done" });
13444
13643
  }
13445
13644
  function reduceRun(prev, token, event) {
13446
13645
  const carried = prev && prev.token === token ? prev : null;
13646
+ const run = event.type === "result" ? event.run : carried?.run ?? null;
13447
13647
  const lastLog = event.type === "log" ? event.text : carried?.lastLog ?? null;
13448
- const phases = event.type === "phase" ? withPhase(carried?.phases ?? [], event.name) : carried?.phases ?? [];
13449
- const submitted = carried?.submitted || event.type === "phase" && event.name === "submit";
13648
+ const stages = event.type === "stage" ? withStage(carried?.stages ?? [], event.name) : carried?.stages ?? [];
13649
+ const submitted = carried?.submitted || event.type === "stage" && event.name === "submit";
13450
13650
  if (event.type === "gate" && event.changeRequest !== null) {
13451
13651
  return {
13452
13652
  token,
13453
- outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest, runUrl: null },
13653
+ outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest },
13654
+ run,
13454
13655
  lastLog,
13455
13656
  submitted,
13456
- phases: closePhases(phases)
13657
+ stages: closeStages(stages)
13457
13658
  };
13458
13659
  }
13459
13660
  if (event.type === "result") {
13460
13661
  if (carried?.outcome.kind === "awaiting-approval") {
13461
13662
  return {
13462
13663
  token,
13463
- outcome: { ...carried.outcome, runUrl: event.run.url ?? null },
13664
+ outcome: carried.outcome,
13665
+ run,
13464
13666
  lastLog,
13465
13667
  submitted,
13466
- phases
13668
+ stages
13467
13669
  };
13468
13670
  }
13469
13671
  if (!event.error)
13470
13672
  return {
13471
13673
  token,
13472
13674
  outcome: { kind: "succeeded" },
13675
+ run,
13473
13676
  lastLog,
13474
13677
  submitted,
13475
- phases: closePhases(phases)
13678
+ stages: closeStages(stages)
13476
13679
  };
13477
13680
  }
13478
- return { token, outcome: { kind: "running" }, lastLog, submitted, phases };
13681
+ return { token, outcome: { kind: "running" }, run, lastLog, submitted, stages };
13479
13682
  }
13480
13683
  function runningFor(slot, token) {
13481
13684
  if (slot?.token !== token) return false;
@@ -13496,31 +13699,34 @@ function failureSays(error) {
13496
13699
  }
13497
13700
  function settleRun(prev, token, error) {
13498
13701
  const carried = prev && prev.token === token ? prev : null;
13702
+ const run = carried?.run ?? null;
13499
13703
  const lastLog = carried?.lastLog ?? null;
13500
13704
  const submitted = carried?.submitted ?? false;
13501
- const phases = closePhases(carried?.phases ?? []);
13705
+ const stages = closeStages(carried?.stages ?? []);
13502
13706
  if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13503
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13707
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13504
13708
  if (error instanceof CommandExitError) {
13505
13709
  if (error.code === 130)
13506
- return { token, outcome: { kind: "cancelled" }, lastLog, submitted, phases };
13710
+ return { token, outcome: { kind: "cancelled" }, run, lastLog, submitted, stages };
13507
13711
  if (error.code === 143)
13508
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13712
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13509
13713
  if (error.code === 7)
13510
13714
  return {
13511
13715
  token,
13512
13716
  outcome: { kind: "blocked", ...failureSays(error) },
13717
+ run,
13513
13718
  lastLog,
13514
13719
  submitted,
13515
- phases
13720
+ stages
13516
13721
  };
13517
13722
  }
13518
13723
  return {
13519
13724
  token,
13520
13725
  outcome: { kind: "failed", ...failureSays(error) },
13726
+ run,
13521
13727
  lastLog,
13522
13728
  submitted,
13523
- phases
13729
+ stages
13524
13730
  };
13525
13731
  }
13526
13732
  function reducePreview(_prev, token, event) {
@@ -13593,9 +13799,10 @@ function createResultStore() {
13593
13799
  run: {
13594
13800
  token,
13595
13801
  outcome: { kind: "running" },
13802
+ run: null,
13596
13803
  lastLog: null,
13597
13804
  submitted: false,
13598
- phases: [],
13805
+ stages: [],
13599
13806
  readOver
13600
13807
  }
13601
13808
  };
@@ -13704,12 +13911,26 @@ function whyNotValid(v) {
13704
13911
  if (v.failure) return v.failure.message;
13705
13912
  const errors = v.diagnostics.filter((d) => d.severity === "error");
13706
13913
  if (errors.length === 0) return void 0;
13707
- return `${errors[0].message} (${errors.length} ${errors.length === 1 ? "error" : "errors"})`;
13914
+ return `${errors[0].message} (${counted(errors.length, "error")})`;
13708
13915
  }
13709
13916
  function didNotValidate(v) {
13710
13917
  const why = whyNotValid(v);
13711
13918
  return why === void 0 ? "The tree did not validate: fix it before you commit it." : `The tree did not validate: ${why}. Fix it before you commit it.`;
13712
13919
  }
13920
+ function lockFailed(e) {
13921
+ return e.changed && e.lock === null;
13922
+ }
13923
+ var DID_NOT_LOCK = "The tree's providers did not lock: run `lace module lock` once the cause is fixed, before you commit it.";
13924
+ function lockfileOf(lock2) {
13925
+ const root = lock2.path.endsWith("/") ? lock2.path : `${lock2.path}/`;
13926
+ return lock2.lockfile.startsWith(root) ? lock2.lockfile.slice(root.length) : lock2.lockfile;
13927
+ }
13928
+ function lockedIn(lock2) {
13929
+ return `${counted(lock2.providers.length, "provider")} in ${lockfileOf(lock2)}`;
13930
+ }
13931
+ function listed(parts) {
13932
+ return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
13933
+ }
13713
13934
  function beside(v) {
13714
13935
  return v.failure ? [v.failure] : [];
13715
13936
  }
@@ -13757,12 +13978,6 @@ function scanNotice(e) {
13757
13978
  `Drift scan complete for stack ${slug}: IN_SYNC (0 drifted) \u2014 its resources were destroyed, so there was nothing to compare.`
13758
13979
  ];
13759
13980
  }
13760
- if (settled.standingDriftFindings > 0) {
13761
- return [
13762
- "info",
13763
- `Drift scan complete for stack ${slug}: the scan observed no drift, but ${settled.standingDriftFindings} drift finding(s) from earlier scans still stand \u2014 the stack remains DRIFTED.`
13764
- ];
13765
- }
13766
13981
  return [
13767
13982
  "info",
13768
13983
  `Drift scan complete for stack ${slug}: ${settled.driftStatus} (${settled.driftCount} drifted).`
@@ -13794,22 +14009,27 @@ function residualAddresses(residuals) {
13794
14009
  function treeChanges(e) {
13795
14010
  return [
13796
14011
  ...e.written.length === 0 ? [] : [`rewriting ${e.written.join(", ")} in place`],
13797
- ...e.removed.length === 0 ? [] : [`removing ${e.removed.join(", ")}`]
14012
+ ...e.removed.length === 0 ? [] : [`removing ${e.removed.join(", ")}`],
14013
+ ...e.lock === null ? [] : [`locking ${lockedIn(e.lock)}`]
13798
14014
  ];
13799
14015
  }
13800
14016
  function importNotice(e) {
13801
14017
  const { slug } = e.stack;
13802
14018
  const changes = treeChanges(e);
13803
- const files = changes.length > 0 ? `, ${changes.join(" and ")}` : "";
14019
+ const files = changes.length > 0 ? `, ${listed(changes)}` : "";
13804
14020
  const imported = `Imported ${e.importBlocks} resource(s) into ${slug}${files}.`;
13805
14021
  if (e.validate.exitClass !== "ok") {
13806
14022
  return ["warn", `${imported} ${didNotValidate(e.validate)}`, ...beside(e.validate)];
13807
14023
  }
13808
- const adopt = e.changed ? ` Review the change in git, commit it, then apply ${slug} to adopt them.` : "";
13809
- if (e.importResiduals.length === 0) return ["info", `${imported}${adopt}`];
14024
+ if (lockFailed(e)) return ["warn", `${imported} ${DID_NOT_LOCK}`];
14025
+ const adopts = e.importBlocks > 0;
14026
+ const next = adopts ? `, commit it, then apply ${slug} to adopt them` : " and commit it";
14027
+ const review = e.changed ? ` Review the change in git${next}.` : "";
14028
+ if (e.importResiduals.length === 0) return ["info", `${imported}${review}`];
14029
+ const unadopted = adopts ? "Not adopted" : "No resource was adopted";
13810
14030
  return [
13811
14031
  "warn",
13812
- `${imported}${adopt} Not adopted: ${residualAddresses(e.importResiduals)}; supply their import ids before applying, or the apply creates them anew.`
14032
+ `${imported}${review} ${unadopted}: ${residualAddresses(e.importResiduals)}; supply their import ids before applying, or the apply creates them anew.`
13813
14033
  ];
13814
14034
  }
13815
14035
  var importResult = {
@@ -13840,9 +14060,13 @@ function validateNotice(v) {
13840
14060
  return ["warn", why === void 0 ? "Not valid for Lace" : `Not valid: ${why}`];
13841
14061
  }
13842
14062
  function convertNotice(e) {
13843
- const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written` : "Already lace-style \u2014 nothing to write";
13844
- if (e.validate.exitClass === "ok") return ["info", converted];
13845
- return ["warn", `${converted}. ${didNotValidate(e.validate)}`, ...beside(e.validate)];
14063
+ const locked = e.lock === null ? "" : `, locking ${lockedIn(e.lock)}`;
14064
+ const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written${locked}` : "Already lace-style \u2014 nothing to write";
14065
+ if (e.validate.exitClass !== "ok") {
14066
+ return ["warn", `${converted}. ${didNotValidate(e.validate)}`, ...beside(e.validate)];
14067
+ }
14068
+ if (lockFailed(e)) return ["warn", `${converted}. ${DID_NOT_LOCK}`];
14069
+ return ["info", converted];
13846
14070
  }
13847
14071
  var validate = defineCommand({
13848
14072
  kind: "command",
@@ -13862,6 +14086,18 @@ var convert = defineCommand({
13862
14086
  consume: (rt, e) => rt.ports.presenter.notify(...convertNotice(e))
13863
14087
  }
13864
14088
  });
14089
+ var lock = defineCommand({
14090
+ kind: "command",
14091
+ path: "module lock",
14092
+ args: () => ({}),
14093
+ result: {
14094
+ kind: "notify",
14095
+ consume: (rt, e) => rt.ports.presenter.notify(
14096
+ "info",
14097
+ `Locked ${lockedIn(e)}. Commit it beside the tree, then run the command again.`
14098
+ )
14099
+ }
14100
+ });
13865
14101
  var preview = defineCommand({
13866
14102
  kind: "command",
13867
14103
  path: "stack preview",
@@ -13979,6 +14215,18 @@ var STACK_COMMAND_ACTIONS = [
13979
14215
  answers: ["import_residual"],
13980
14216
  binding: importPartial
13981
14217
  },
14218
+ // `stack apply`, `stack destroy` and `stack preview` refuse a root that
14219
+ // keeps no lockfile: `module lock`, run in the refused command's root,
14220
+ // writes it.
14221
+ {
14222
+ id: "lock-missing",
14223
+ label: "Lock providers",
14224
+ placement: { row: "failure" },
14225
+ requiredPorts: ["commands"],
14226
+ requiredContext: ["root"],
14227
+ answers: ["no_lockfile"],
14228
+ binding: lock
14229
+ },
13982
14230
  {
13983
14231
  id: "preview",
13984
14232
  label: "Preview",
@@ -14011,6 +14259,23 @@ var CORE_COMMAND_ACTIONS = [
14011
14259
  ...MODULE_COMMAND_ACTIONS
14012
14260
  ];
14013
14261
 
14262
+ // src/core/entry-scope.ts
14263
+ function enclosingGroups(view) {
14264
+ return new Map(view.groups.flatMap((g) => g.node_ids.map((id) => [id, g.id])));
14265
+ }
14266
+ function entryScopeIds(view) {
14267
+ const enclosing = enclosingGroups(view);
14268
+ return [...view.nodes, ...view.groups].map((n) => n.id).filter((id) => !enclosing.has(id));
14269
+ }
14270
+ function inOneScope(view, ids) {
14271
+ const enclosing = enclosingGroups(view);
14272
+ return new Set(ids.map((id) => enclosing.get(id) ?? null)).size <= 1;
14273
+ }
14274
+ function inEntryScope(view, ids) {
14275
+ const entry = new Set(entryScopeIds(view));
14276
+ return ids.filter((id) => entry.has(id));
14277
+ }
14278
+
14014
14279
  // src/registry.ts
14015
14280
  var CONTEXT_NEEDS = {
14016
14281
  root: "an authoring root",
@@ -14024,7 +14289,11 @@ var CONTEXT_NEEDS = {
14024
14289
  sourceRefused: "the source-refused lock",
14025
14290
  needsConversion: "a tree out of lace shape",
14026
14291
  "selection.node": "a selected node",
14027
- "selection.edge": "a selected connection",
14292
+ "selection.several": "two selected nodes or more",
14293
+ "selection.entryScope": "a selected top-level node or group",
14294
+ "selection.oneScope": "selected nodes that share one scope",
14295
+ "selection.edge": "one selected connection",
14296
+ "selection.edges": "selected connections",
14028
14297
  diagnostics: "diagnostics to show",
14029
14298
  settingsOpen: "the settings panel open",
14030
14299
  generateIdle: "no Generate running",
@@ -14041,7 +14310,14 @@ var TARGET_NEEDS = {
14041
14310
  failure: "a failed command"
14042
14311
  };
14043
14312
  function busyReason(busy) {
14044
- return busy.kind === "run" ? "A run is in progress" : `${busy.running.label} is running`;
14313
+ switch (busy.kind) {
14314
+ case "run":
14315
+ return "A run is in progress";
14316
+ case "notify":
14317
+ return `${busy.running.label} is running`;
14318
+ case "edit":
14319
+ return "An edit is in progress";
14320
+ }
14045
14321
  }
14046
14322
  function runsOn(action, ctx, target) {
14047
14323
  if (action.requiredTarget?.includes("runId")) return `run:${target.runId}`;
@@ -14050,6 +14326,10 @@ function runsOn(action, ctx, target) {
14050
14326
  if (required.includes("root")) return `root:${ctx.root}`;
14051
14327
  return "";
14052
14328
  }
14329
+ function wiresAlone(ctx) {
14330
+ const selection = ctx.selection;
14331
+ return selection && selection.nodes.length === 0 ? selection.edges.length : 0;
14332
+ }
14053
14333
  function keySatisfied(ctx, key) {
14054
14334
  if (key === "editable") return ctx.editable === true;
14055
14335
  if (key === "saved") return ctx.view?.unsaved === false;
@@ -14059,13 +14339,18 @@ function keySatisfied(ctx, key) {
14059
14339
  if (key === "sourceRefused") return ctx.sourceRefused === true;
14060
14340
  if (key === "needsConversion")
14061
14341
  return ctx.sourceRefused === true && holdsLaceShapeRefusal(ctx.diagnostics ?? []);
14062
- if (key === "selection.node")
14063
- return ctx.selection !== void 0 && ctx.selection.nodes.length > 0;
14064
- if (key === "selection.edge") return ctx.selection !== void 0 && ctx.selection.edge !== null;
14342
+ if (key === "selection.node") return (ctx.selection?.nodes.length ?? 0) > 0;
14343
+ if (key === "selection.several") return (ctx.selection?.nodes.length ?? 0) > 1;
14344
+ if (key === "selection.entryScope")
14345
+ return ctx.view !== void 0 && ctx.selection !== void 0 && inEntryScope(ctx.view, ctx.selection.nodes).length > 0;
14346
+ if (key === "selection.oneScope")
14347
+ return ctx.view !== void 0 && ctx.selection !== void 0 && inOneScope(ctx.view, ctx.selection.nodes);
14348
+ if (key === "selection.edge") return wiresAlone(ctx) === 1;
14349
+ if (key === "selection.edges") return wiresAlone(ctx) > 0;
14065
14350
  if (key === "diagnostics") return ctx.diagnostics !== void 0 && ctx.diagnostics.length > 0;
14066
14351
  if (key === "settingsOpen") return ctx.settingsOpen === true;
14067
14352
  if (key === "generateIdle") return ctx.generating === false;
14068
- if (key === "generating") return ctx.generating === true;
14353
+ if (key === "generating") return ctx.generating !== void 0 && ctx.generating !== false;
14069
14354
  if (key === "ungenerated") return ctx.view?.ungenerated === true;
14070
14355
  if (key === "undoable") return ctx.view?.can_undo === true;
14071
14356
  if (key === "redoable") return ctx.view?.can_redo === true;
@@ -14125,6 +14410,15 @@ function unmetRequirement(action, ports, ctx, target) {
14125
14410
  }
14126
14411
 
14127
14412
  // src/core/run-binding.ts
14413
+ var EDIT_IN_PROGRESS = { kind: "edit" };
14414
+ function refusedBatch(message, reason) {
14415
+ return {
14416
+ success: false,
14417
+ errors: [{ moduleKey: "", instanceId: "", inputName: "", message, reason }],
14418
+ created: [],
14419
+ ties: []
14420
+ };
14421
+ }
14128
14422
  function createClipboardStore() {
14129
14423
  let clip = null;
14130
14424
  return {
@@ -14150,6 +14444,7 @@ function createActionRunner(ports, store, options = {}) {
14150
14444
  const notifyControllers = /* @__PURE__ */ new Map();
14151
14445
  let edits = 0;
14152
14446
  const editingListeners = /* @__PURE__ */ new Set();
14447
+ const tickListeners = /* @__PURE__ */ new Set();
14153
14448
  async function asEdit(edit) {
14154
14449
  edits += 1;
14155
14450
  if (edits === 1) for (const listener of editingListeners) listener(true);
@@ -14167,20 +14462,7 @@ function createActionRunner(ports, store, options = {}) {
14167
14462
  } catch (error) {
14168
14463
  const message = error instanceof Error ? error.message : String(error);
14169
14464
  ports.presenter.notify("error", message);
14170
- return {
14171
- success: false,
14172
- errors: [
14173
- {
14174
- moduleKey: "",
14175
- instanceId: "",
14176
- inputName: "",
14177
- message,
14178
- reason: rejectionReason(error)
14179
- }
14180
- ],
14181
- created: [],
14182
- ties: []
14183
- };
14465
+ return refusedBatch(message, rejectionReason(error));
14184
14466
  }
14185
14467
  if (!result.success) {
14186
14468
  for (const err of result.errors) ports.presenter.notify("error", err.message);
@@ -14199,8 +14481,14 @@ function createActionRunner(ports, store, options = {}) {
14199
14481
  async function applyActions(actions) {
14200
14482
  const editor = ports.editor;
14201
14483
  if (!editor) return;
14484
+ if (edits > 0) return heldEdit();
14202
14485
  return asEdit(() => applyWith(editor, actions));
14203
14486
  }
14487
+ function heldEdit() {
14488
+ const message = busyReason(EDIT_IN_PROGRESS);
14489
+ ports.presenter.notify("warn", message);
14490
+ return refusedBatch(message, 0 /* REASON_UNSPECIFIED */);
14491
+ }
14204
14492
  function askConfirm(spec) {
14205
14493
  const confirm = ports.presenter.confirm;
14206
14494
  return confirm ? confirm(spec) : Promise.resolve(false);
@@ -14221,7 +14509,10 @@ function createActionRunner(ports, store, options = {}) {
14221
14509
  },
14222
14510
  fail: (error) => run ? store.fail(run.resultKind, token, error) : false,
14223
14511
  detach: (kind, tok) => store.detach(kind, tok),
14224
- tick: () => store.bumpTick(),
14512
+ tick: () => {
14513
+ store.bumpTick();
14514
+ if (run) for (const listener of tickListeners) listener(run);
14515
+ },
14225
14516
  settled: onSettle
14226
14517
  };
14227
14518
  }
@@ -14234,8 +14525,14 @@ function createActionRunner(ports, store, options = {}) {
14234
14525
  }
14235
14526
  function busyOf(action, ctx, target) {
14236
14527
  const binding = action.binding;
14237
- if (binding.kind !== "command") return void 0;
14238
- return busyOn(binding.resultKind, action, ctx, target).busy;
14528
+ switch (binding.kind) {
14529
+ case "command":
14530
+ return busyOn(binding.resultKind, action, ctx, target).busy;
14531
+ case "editor":
14532
+ return edits > 0 ? EDIT_IN_PROGRESS : void 0;
14533
+ case "host":
14534
+ return void 0;
14535
+ }
14239
14536
  }
14240
14537
  function cwdOf(action, ctx) {
14241
14538
  return (action.requiredContext ?? []).includes("root") ? ctx.root : void 0;
@@ -14352,8 +14649,9 @@ function createActionRunner(ports, store, options = {}) {
14352
14649
  const hostSpec = binding.confirm?.(ctx);
14353
14650
  if (hostSpec && !await askConfirm(hostSpec)) return;
14354
14651
  const token = {};
14355
- await binding.run(runtimeFor(token, readOverOf(ctx), cwdOf(action, ctx)), ctx, target);
14356
- if (binding.invalidates) store.bumpTick();
14652
+ const rt = runtimeFor(token, readOverOf(ctx), cwdOf(action, ctx));
14653
+ await binding.run(rt, ctx, target);
14654
+ if (binding.invalidates) rt.tick();
14357
14655
  }
14358
14656
  return {
14359
14657
  async run(action, ...rest) {
@@ -14400,6 +14698,12 @@ function createActionRunner(ports, store, options = {}) {
14400
14698
  editingListeners.delete(listener);
14401
14699
  };
14402
14700
  },
14701
+ onDidTick(listener) {
14702
+ tickListeners.add(listener);
14703
+ return () => {
14704
+ tickListeners.delete(listener);
14705
+ };
14706
+ },
14403
14707
  busy(action, ctx, target) {
14404
14708
  return busyOf(action, ctx, target);
14405
14709
  },
@@ -14419,6 +14723,7 @@ function createActionRunner(ports, store, options = {}) {
14419
14723
  store.detach("notify", token);
14420
14724
  }
14421
14725
  notifyControllers.clear();
14726
+ tickListeners.clear();
14422
14727
  }
14423
14728
  };
14424
14729
  }
@@ -14520,6 +14825,7 @@ function autosave(source, save, policy, report) {
14520
14825
  CommandUnobservedError,
14521
14826
  ConnectError,
14522
14827
  EMPTY_REPORT_FOLD,
14828
+ GENERATE_STAGES,
14523
14829
  InputMode,
14524
14830
  Reason,
14525
14831
  SCHEMAS,
@@ -14527,6 +14833,7 @@ function autosave(source, save, policy, report) {
14527
14833
  autosave,
14528
14834
  bridgeCaller,
14529
14835
  carriesFailure,
14836
+ commandPathOf,
14530
14837
  commandUnderWay,
14531
14838
  connectCaller,
14532
14839
  createActionRunner,
@@ -14537,6 +14844,7 @@ function autosave(source, save, policy, report) {
14537
14844
  diagnosticsOfDocument,
14538
14845
  failureSays,
14539
14846
  foldReport,
14847
+ generatedTree,
14540
14848
  isBoundPath,
14541
14849
  liveSlots,
14542
14850
  openEngineCommands,