@lace-cloud/canvas 0.30.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.
@@ -37,6 +37,7 @@ __export(engine_exports, {
37
37
  autosave: () => autosave,
38
38
  bridgeCaller: () => bridgeCaller,
39
39
  carriesFailure: () => carriesFailure,
40
+ commandPathOf: () => commandPathOf,
40
41
  commandUnderWay: () => commandUnderWay,
41
42
  connectCaller: () => connectCaller,
42
43
  createActionRunner: () => createActionRunner,
@@ -3452,6 +3453,7 @@ var Reason = /* @__PURE__ */ ((Reason2) => {
3452
3453
  Reason2[Reason2["REASON_NO_ORIGIN_REMOTE"] = 19] = "REASON_NO_ORIGIN_REMOTE";
3453
3454
  Reason2[Reason2["REASON_IMPORT_UNDECLARED"] = 20] = "REASON_IMPORT_UNDECLARED";
3454
3455
  Reason2[Reason2["REASON_ALREADY_IMPORTED"] = 21] = "REASON_ALREADY_IMPORTED";
3456
+ Reason2[Reason2["REASON_NO_LOCKFILE"] = 22] = "REASON_NO_LOCKFILE";
3455
3457
  Reason2[Reason2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
3456
3458
  return Reason2;
3457
3459
  })(Reason || {});
@@ -3523,6 +3525,9 @@ function reasonFromJSON(object) {
3523
3525
  case 21:
3524
3526
  case "REASON_ALREADY_IMPORTED":
3525
3527
  return 21 /* REASON_ALREADY_IMPORTED */;
3528
+ case 22:
3529
+ case "REASON_NO_LOCKFILE":
3530
+ return 22 /* REASON_NO_LOCKFILE */;
3526
3531
  case -1:
3527
3532
  case "UNRECOGNIZED":
3528
3533
  default:
@@ -3575,6 +3580,8 @@ function reasonToJSON(object) {
3575
3580
  return "REASON_IMPORT_UNDECLARED";
3576
3581
  case 21 /* REASON_ALREADY_IMPORTED */:
3577
3582
  return "REASON_ALREADY_IMPORTED";
3583
+ case 22 /* REASON_NO_LOCKFILE */:
3584
+ return "REASON_NO_LOCKFILE";
3578
3585
  case -1 /* UNRECOGNIZED */:
3579
3586
  default:
3580
3587
  return "UNRECOGNIZED";
@@ -10993,6 +11000,30 @@ function bridgeCaller(bridge) {
10993
11000
  // src/adapters/engine/mapping.ts
10994
11001
  var import_proto2 = require("@lace-cloud/proto");
10995
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
+
10996
11027
  // src/contracts/commands.gen.ts
10997
11028
  var COMMANDS = {
10998
11029
  "chaos run": {
@@ -11038,7 +11069,8 @@ var COMMANDS = {
11038
11069
  "values": [
11039
11070
  "table",
11040
11071
  "json"
11041
- ]
11072
+ ],
11073
+ "short": "o"
11042
11074
  },
11043
11075
  "prUrl": {
11044
11076
  "type": "string"
@@ -11093,7 +11125,8 @@ var COMMANDS = {
11093
11125
  "values": [
11094
11126
  "table",
11095
11127
  "json"
11096
- ]
11128
+ ],
11129
+ "short": "o"
11097
11130
  },
11098
11131
  "team": {
11099
11132
  "type": "string"
@@ -11115,7 +11148,8 @@ var COMMANDS = {
11115
11148
  "values": [
11116
11149
  "table",
11117
11150
  "json"
11118
- ]
11151
+ ],
11152
+ "short": "o"
11119
11153
  },
11120
11154
  "provider": {
11121
11155
  "type": "string"
@@ -11136,7 +11170,8 @@ var COMMANDS = {
11136
11170
  "type": "bool"
11137
11171
  },
11138
11172
  "path": {
11139
- "type": "string"
11173
+ "type": "string",
11174
+ "short": "p"
11140
11175
  }
11141
11176
  },
11142
11177
  "effect": "write",
@@ -11148,7 +11183,8 @@ var COMMANDS = {
11148
11183
  "positionals": [],
11149
11184
  "flags": {
11150
11185
  "path": {
11151
- "type": "string"
11186
+ "type": "string",
11187
+ "short": "p"
11152
11188
  }
11153
11189
  },
11154
11190
  "effect": "write",
@@ -11182,7 +11218,8 @@ var COMMANDS = {
11182
11218
  "values": [
11183
11219
  "table",
11184
11220
  "json"
11185
- ]
11221
+ ],
11222
+ "short": "o"
11186
11223
  },
11187
11224
  "provider": {
11188
11225
  "type": "string"
@@ -11204,7 +11241,8 @@ var COMMANDS = {
11204
11241
  "values": [
11205
11242
  "table",
11206
11243
  "json"
11207
- ]
11244
+ ],
11245
+ "short": "o"
11208
11246
  }
11209
11247
  },
11210
11248
  "effect": "write",
@@ -11220,10 +11258,12 @@ var COMMANDS = {
11220
11258
  "values": [
11221
11259
  "table",
11222
11260
  "json"
11223
- ]
11261
+ ],
11262
+ "short": "o"
11224
11263
  },
11225
11264
  "path": {
11226
- "type": "string"
11265
+ "type": "string",
11266
+ "short": "p"
11227
11267
  }
11228
11268
  },
11229
11269
  "effect": "rewrite",
@@ -11244,10 +11284,12 @@ var COMMANDS = {
11244
11284
  "json",
11245
11285
  "terraform-docs-json",
11246
11286
  "terraform-docs-yaml"
11247
- ]
11287
+ ],
11288
+ "short": "o"
11248
11289
  },
11249
11290
  "path": {
11250
- "type": "string"
11291
+ "type": "string",
11292
+ "short": "p"
11251
11293
  }
11252
11294
  },
11253
11295
  "effect": "write",
@@ -11269,10 +11311,12 @@ var COMMANDS = {
11269
11311
  "values": [
11270
11312
  "table",
11271
11313
  "json"
11272
- ]
11314
+ ],
11315
+ "short": "o"
11273
11316
  },
11274
11317
  "path": {
11275
- "type": "string"
11318
+ "type": "string",
11319
+ "short": "p"
11276
11320
  },
11277
11321
  "recursive": {
11278
11322
  "type": "bool"
@@ -11294,10 +11338,12 @@ var COMMANDS = {
11294
11338
  "values": [
11295
11339
  "table",
11296
11340
  "json"
11297
- ]
11341
+ ],
11342
+ "short": "o"
11298
11343
  },
11299
11344
  "path": {
11300
- "type": "string"
11345
+ "type": "string",
11346
+ "short": "p"
11301
11347
  },
11302
11348
  "upgrade": {
11303
11349
  "type": "stringArray",
@@ -11321,10 +11367,12 @@ var COMMANDS = {
11321
11367
  "sarif",
11322
11368
  "junit",
11323
11369
  "checkstyle"
11324
- ]
11370
+ ],
11371
+ "short": "o"
11325
11372
  },
11326
11373
  "path": {
11327
- "type": "string"
11374
+ "type": "string",
11375
+ "short": "p"
11328
11376
  },
11329
11377
  "severity": {
11330
11378
  "type": "string",
@@ -11355,10 +11403,12 @@ var COMMANDS = {
11355
11403
  "values": [
11356
11404
  "table",
11357
11405
  "json"
11358
- ]
11406
+ ],
11407
+ "short": "o"
11359
11408
  },
11360
11409
  "path": {
11361
- "type": "string"
11410
+ "type": "string",
11411
+ "short": "p"
11362
11412
  },
11363
11413
  "view": {
11364
11414
  "type": "string",
@@ -11381,7 +11431,8 @@ var COMMANDS = {
11381
11431
  "values": [
11382
11432
  "table",
11383
11433
  "json"
11384
- ]
11434
+ ],
11435
+ "short": "o"
11385
11436
  }
11386
11437
  },
11387
11438
  "effect": "read",
@@ -11397,7 +11448,8 @@ var COMMANDS = {
11397
11448
  "values": [
11398
11449
  "table",
11399
11450
  "json"
11400
- ]
11451
+ ],
11452
+ "short": "o"
11401
11453
  }
11402
11454
  },
11403
11455
  "effect": "read",
@@ -11418,7 +11470,8 @@ var COMMANDS = {
11418
11470
  "values": [
11419
11471
  "table",
11420
11472
  "json"
11421
- ]
11473
+ ],
11474
+ "short": "o"
11422
11475
  }
11423
11476
  },
11424
11477
  "effect": "write",
@@ -11442,7 +11495,8 @@ var COMMANDS = {
11442
11495
  "values": [
11443
11496
  "table",
11444
11497
  "json"
11445
- ]
11498
+ ],
11499
+ "short": "o"
11446
11500
  },
11447
11501
  "team": {
11448
11502
  "type": "string"
@@ -11464,7 +11518,8 @@ var COMMANDS = {
11464
11518
  "values": [
11465
11519
  "table",
11466
11520
  "json"
11467
- ]
11521
+ ],
11522
+ "short": "o"
11468
11523
  },
11469
11524
  "stack": {
11470
11525
  "type": "string"
@@ -11494,7 +11549,8 @@ var COMMANDS = {
11494
11549
  "values": [
11495
11550
  "table",
11496
11551
  "json"
11497
- ]
11552
+ ],
11553
+ "short": "o"
11498
11554
  },
11499
11555
  "version": {
11500
11556
  "type": "string"
@@ -11521,7 +11577,8 @@ var COMMANDS = {
11521
11577
  "values": [
11522
11578
  "table",
11523
11579
  "json"
11524
- ]
11580
+ ],
11581
+ "short": "o"
11525
11582
  },
11526
11583
  "view": {
11527
11584
  "type": "string",
@@ -11564,7 +11621,8 @@ var COMMANDS = {
11564
11621
  "values": [
11565
11622
  "table",
11566
11623
  "json"
11567
- ]
11624
+ ],
11625
+ "short": "o"
11568
11626
  },
11569
11627
  "query": {
11570
11628
  "type": "string"
@@ -11600,7 +11658,8 @@ var COMMANDS = {
11600
11658
  "values": [
11601
11659
  "table",
11602
11660
  "json"
11603
- ]
11661
+ ],
11662
+ "short": "o"
11604
11663
  },
11605
11664
  "readme": {
11606
11665
  "type": "string"
@@ -11626,7 +11685,8 @@ var COMMANDS = {
11626
11685
  "type": "string",
11627
11686
  "values": [
11628
11687
  "json"
11629
- ]
11688
+ ],
11689
+ "short": "o"
11630
11690
  },
11631
11691
  "team": {
11632
11692
  "type": "string"
@@ -11653,7 +11713,8 @@ var COMMANDS = {
11653
11713
  "values": [
11654
11714
  "table",
11655
11715
  "json"
11656
- ]
11716
+ ],
11717
+ "short": "o"
11657
11718
  },
11658
11719
  "reason": {
11659
11720
  "type": "string"
@@ -11686,7 +11747,8 @@ var COMMANDS = {
11686
11747
  "values": [
11687
11748
  "table",
11688
11749
  "json"
11689
- ]
11750
+ ],
11751
+ "short": "o"
11690
11752
  },
11691
11753
  "team": {
11692
11754
  "type": "string"
@@ -11720,7 +11782,8 @@ var COMMANDS = {
11720
11782
  "values": [
11721
11783
  "table",
11722
11784
  "json"
11723
- ]
11785
+ ],
11786
+ "short": "o"
11724
11787
  },
11725
11788
  "stack": {
11726
11789
  "type": "string"
@@ -11759,7 +11822,8 @@ var COMMANDS = {
11759
11822
  "values": [
11760
11823
  "table",
11761
11824
  "json"
11762
- ]
11825
+ ],
11826
+ "short": "o"
11763
11827
  },
11764
11828
  "team": {
11765
11829
  "type": "string"
@@ -11786,7 +11850,8 @@ var COMMANDS = {
11786
11850
  "values": [
11787
11851
  "table",
11788
11852
  "json"
11789
- ]
11853
+ ],
11854
+ "short": "o"
11790
11855
  },
11791
11856
  "team": {
11792
11857
  "type": "string"
@@ -11819,7 +11884,8 @@ var COMMANDS = {
11819
11884
  "values": [
11820
11885
  "table",
11821
11886
  "json"
11822
- ]
11887
+ ],
11888
+ "short": "o"
11823
11889
  },
11824
11890
  "prUrl": {
11825
11891
  "type": "string"
@@ -11870,7 +11936,8 @@ var COMMANDS = {
11870
11936
  "values": [
11871
11937
  "table",
11872
11938
  "json"
11873
- ]
11939
+ ],
11940
+ "short": "o"
11874
11941
  },
11875
11942
  "source": {
11876
11943
  "type": "string"
@@ -11909,7 +11976,8 @@ var COMMANDS = {
11909
11976
  "values": [
11910
11977
  "table",
11911
11978
  "json"
11912
- ]
11979
+ ],
11980
+ "short": "o"
11913
11981
  },
11914
11982
  "team": {
11915
11983
  "type": "string"
@@ -11945,7 +12013,8 @@ var COMMANDS = {
11945
12013
  "values": [
11946
12014
  "table",
11947
12015
  "json"
11948
- ]
12016
+ ],
12017
+ "short": "o"
11949
12018
  },
11950
12019
  "team": {
11951
12020
  "type": "string"
@@ -11981,7 +12050,8 @@ var COMMANDS = {
11981
12050
  "values": [
11982
12051
  "table",
11983
12052
  "json"
11984
- ]
12053
+ ],
12054
+ "short": "o"
11985
12055
  },
11986
12056
  "prUrl": {
11987
12057
  "type": "string"
@@ -12028,7 +12098,8 @@ var COMMANDS = {
12028
12098
  "values": [
12029
12099
  "table",
12030
12100
  "json"
12031
- ]
12101
+ ],
12102
+ "short": "o"
12032
12103
  },
12033
12104
  "team": {
12034
12105
  "type": "string"
@@ -12058,10 +12129,12 @@ var COMMANDS = {
12058
12129
  "values": [
12059
12130
  "table",
12060
12131
  "json"
12061
- ]
12132
+ ],
12133
+ "short": "o"
12062
12134
  },
12063
12135
  "path": {
12064
- "type": "string"
12136
+ "type": "string",
12137
+ "short": "p"
12065
12138
  },
12066
12139
  "state": {
12067
12140
  "type": "string",
@@ -12096,7 +12169,8 @@ var COMMANDS = {
12096
12169
  "values": [
12097
12170
  "table",
12098
12171
  "json"
12099
- ]
12172
+ ],
12173
+ "short": "o"
12100
12174
  },
12101
12175
  "source": {
12102
12176
  "type": "string"
@@ -12126,7 +12200,8 @@ var COMMANDS = {
12126
12200
  "values": [
12127
12201
  "table",
12128
12202
  "json"
12129
- ]
12203
+ ],
12204
+ "short": "o"
12130
12205
  },
12131
12206
  "team": {
12132
12207
  "type": "string"
@@ -12164,7 +12239,8 @@ var COMMANDS = {
12164
12239
  "values": [
12165
12240
  "table",
12166
12241
  "json"
12167
- ]
12242
+ ],
12243
+ "short": "o"
12168
12244
  },
12169
12245
  "team": {
12170
12246
  "type": "string"
@@ -12203,7 +12279,8 @@ var COMMANDS = {
12203
12279
  "values": [
12204
12280
  "table",
12205
12281
  "json"
12206
- ]
12282
+ ],
12283
+ "short": "o"
12207
12284
  },
12208
12285
  "sourcePath": {
12209
12286
  "type": "string"
@@ -12234,7 +12311,8 @@ var COMMANDS = {
12234
12311
  "values": [
12235
12312
  "table",
12236
12313
  "json"
12237
- ]
12314
+ ],
12315
+ "short": "o"
12238
12316
  }
12239
12317
  },
12240
12318
  "effect": "read",
@@ -12259,7 +12337,8 @@ var COMMANDS = {
12259
12337
  "values": [
12260
12338
  "table",
12261
12339
  "json"
12262
- ]
12340
+ ],
12341
+ "short": "o"
12263
12342
  }
12264
12343
  },
12265
12344
  "effect": "read",
@@ -12283,7 +12362,8 @@ var COMMANDS = {
12283
12362
  "values": [
12284
12363
  "table",
12285
12364
  "json"
12286
- ]
12365
+ ],
12366
+ "short": "o"
12287
12367
  }
12288
12368
  },
12289
12369
  "effect": "write",
@@ -12299,7 +12379,8 @@ var COMMANDS = {
12299
12379
  "values": [
12300
12380
  "table",
12301
12381
  "json"
12302
- ]
12382
+ ],
12383
+ "short": "o"
12303
12384
  }
12304
12385
  },
12305
12386
  "effect": "read",
@@ -12315,7 +12396,8 @@ var COMMANDS = {
12315
12396
  "values": [
12316
12397
  "table",
12317
12398
  "json"
12318
- ]
12399
+ ],
12400
+ "short": "o"
12319
12401
  }
12320
12402
  },
12321
12403
  "effect": "read",
@@ -12323,6 +12405,21 @@ var COMMANDS = {
12323
12405
  "yes": false
12324
12406
  }
12325
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
+ ];
12326
12423
  function dashed(name) {
12327
12424
  return name.replace(/([A-Z])/g, (m) => `-${m.toLowerCase()}`);
12328
12425
  }
@@ -12353,6 +12450,12 @@ function toArgv(path, args) {
12353
12450
  }
12354
12451
  return argv;
12355
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
+ }
12356
12459
 
12357
12460
  // src/contracts/complete-args.ts
12358
12461
  function requiredArgKeys(path) {
@@ -12841,7 +12944,7 @@ var gateChangeRequestSchema = import_zod.z.object({
12841
12944
  });
12842
12945
  var runEventSchema = import_zod.z.discriminatedUnion("type", [
12843
12946
  import_zod.z.object({ type: import_zod.z.literal("log"), text: import_zod.z.string() }),
12844
- 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() }),
12845
12948
  import_zod.z.object({
12846
12949
  type: import_zod.z.literal("gate"),
12847
12950
  resolution: import_zod.z.object({ mode: import_zod.z.string(), reason: import_zod.z.string().optional() }),
@@ -12854,7 +12957,6 @@ var runEventSchema = import_zod.z.discriminatedUnion("type", [
12854
12957
  type: import_zod.z.literal("result"),
12855
12958
  run: runSchema,
12856
12959
  summary: planSummarySchema,
12857
- workspaceDir: import_zod.z.string(),
12858
12960
  error: import_zod.z.string().nullable()
12859
12961
  })
12860
12962
  ]);
@@ -12868,7 +12970,6 @@ var stackScanSchema = import_zod.z.object({
12868
12970
  scannedAt: import_zod.z.string(),
12869
12971
  undeterminedReason: import_zod.z.string().nullable(),
12870
12972
  undeterminedMessage: import_zod.z.string().nullable(),
12871
- standingDriftFindings: import_zod.z.number(),
12872
12973
  footprintDestroyed: import_zod.z.boolean(),
12873
12974
  drift: driftSchema
12874
12975
  }).nullable()
@@ -13394,6 +13495,11 @@ function convertCreatedRef(r) {
13394
13495
  return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
13395
13496
  }
13396
13497
 
13498
+ // src/utils/counted.ts
13499
+ function counted(n, noun) {
13500
+ return `${n} ${noun}${n === 1 ? "" : "s"}`;
13501
+ }
13502
+
13397
13503
  // src/core/diagnostics.ts
13398
13504
  var NOT_LACE_SHAPE = "not_lace_shape";
13399
13505
  function holdsLaceShapeRefusal(diagnostics) {
@@ -13529,46 +13635,50 @@ function commandUnderWay({
13529
13635
  }) {
13530
13636
  return run?.outcome.kind === "running" || preview2?.outcome.kind === "running" || running.size > 0;
13531
13637
  }
13532
- function withPhase(phases, name) {
13533
- 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" }];
13534
13640
  }
13535
- function closePhases(phases) {
13536
- 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" });
13537
13643
  }
13538
13644
  function reduceRun(prev, token, event) {
13539
13645
  const carried = prev && prev.token === token ? prev : null;
13646
+ const run = event.type === "result" ? event.run : carried?.run ?? null;
13540
13647
  const lastLog = event.type === "log" ? event.text : carried?.lastLog ?? null;
13541
- const phases = event.type === "phase" ? withPhase(carried?.phases ?? [], event.name) : carried?.phases ?? [];
13542
- 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";
13543
13650
  if (event.type === "gate" && event.changeRequest !== null) {
13544
13651
  return {
13545
13652
  token,
13546
- outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest, runUrl: null },
13653
+ outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest },
13654
+ run,
13547
13655
  lastLog,
13548
13656
  submitted,
13549
- phases: closePhases(phases)
13657
+ stages: closeStages(stages)
13550
13658
  };
13551
13659
  }
13552
13660
  if (event.type === "result") {
13553
13661
  if (carried?.outcome.kind === "awaiting-approval") {
13554
13662
  return {
13555
13663
  token,
13556
- outcome: { ...carried.outcome, runUrl: event.run.url ?? null },
13664
+ outcome: carried.outcome,
13665
+ run,
13557
13666
  lastLog,
13558
13667
  submitted,
13559
- phases
13668
+ stages
13560
13669
  };
13561
13670
  }
13562
13671
  if (!event.error)
13563
13672
  return {
13564
13673
  token,
13565
13674
  outcome: { kind: "succeeded" },
13675
+ run,
13566
13676
  lastLog,
13567
13677
  submitted,
13568
- phases: closePhases(phases)
13678
+ stages: closeStages(stages)
13569
13679
  };
13570
13680
  }
13571
- return { token, outcome: { kind: "running" }, lastLog, submitted, phases };
13681
+ return { token, outcome: { kind: "running" }, run, lastLog, submitted, stages };
13572
13682
  }
13573
13683
  function runningFor(slot, token) {
13574
13684
  if (slot?.token !== token) return false;
@@ -13589,31 +13699,34 @@ function failureSays(error) {
13589
13699
  }
13590
13700
  function settleRun(prev, token, error) {
13591
13701
  const carried = prev && prev.token === token ? prev : null;
13702
+ const run = carried?.run ?? null;
13592
13703
  const lastLog = carried?.lastLog ?? null;
13593
13704
  const submitted = carried?.submitted ?? false;
13594
- const phases = closePhases(carried?.phases ?? []);
13705
+ const stages = closeStages(carried?.stages ?? []);
13595
13706
  if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13596
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13707
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13597
13708
  if (error instanceof CommandExitError) {
13598
13709
  if (error.code === 130)
13599
- return { token, outcome: { kind: "cancelled" }, lastLog, submitted, phases };
13710
+ return { token, outcome: { kind: "cancelled" }, run, lastLog, submitted, stages };
13600
13711
  if (error.code === 143)
13601
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13712
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13602
13713
  if (error.code === 7)
13603
13714
  return {
13604
13715
  token,
13605
13716
  outcome: { kind: "blocked", ...failureSays(error) },
13717
+ run,
13606
13718
  lastLog,
13607
13719
  submitted,
13608
- phases
13720
+ stages
13609
13721
  };
13610
13722
  }
13611
13723
  return {
13612
13724
  token,
13613
13725
  outcome: { kind: "failed", ...failureSays(error) },
13726
+ run,
13614
13727
  lastLog,
13615
13728
  submitted,
13616
- phases
13729
+ stages
13617
13730
  };
13618
13731
  }
13619
13732
  function reducePreview(_prev, token, event) {
@@ -13686,9 +13799,10 @@ function createResultStore() {
13686
13799
  run: {
13687
13800
  token,
13688
13801
  outcome: { kind: "running" },
13802
+ run: null,
13689
13803
  lastLog: null,
13690
13804
  submitted: false,
13691
- phases: [],
13805
+ stages: [],
13692
13806
  readOver
13693
13807
  }
13694
13808
  };
@@ -13797,7 +13911,7 @@ function whyNotValid(v) {
13797
13911
  if (v.failure) return v.failure.message;
13798
13912
  const errors = v.diagnostics.filter((d) => d.severity === "error");
13799
13913
  if (errors.length === 0) return void 0;
13800
- return `${errors[0].message} (${errors.length} ${errors.length === 1 ? "error" : "errors"})`;
13914
+ return `${errors[0].message} (${counted(errors.length, "error")})`;
13801
13915
  }
13802
13916
  function didNotValidate(v) {
13803
13917
  const why = whyNotValid(v);
@@ -13807,6 +13921,16 @@ function lockFailed(e) {
13807
13921
  return e.changed && e.lock === null;
13808
13922
  }
13809
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
+ }
13810
13934
  function beside(v) {
13811
13935
  return v.failure ? [v.failure] : [];
13812
13936
  }
@@ -13854,12 +13978,6 @@ function scanNotice(e) {
13854
13978
  `Drift scan complete for stack ${slug}: IN_SYNC (0 drifted) \u2014 its resources were destroyed, so there was nothing to compare.`
13855
13979
  ];
13856
13980
  }
13857
- if (settled.standingDriftFindings > 0) {
13858
- return [
13859
- "info",
13860
- `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.`
13861
- ];
13862
- }
13863
13981
  return [
13864
13982
  "info",
13865
13983
  `Drift scan complete for stack ${slug}: ${settled.driftStatus} (${settled.driftCount} drifted).`
@@ -13891,13 +14009,14 @@ function residualAddresses(residuals) {
13891
14009
  function treeChanges(e) {
13892
14010
  return [
13893
14011
  ...e.written.length === 0 ? [] : [`rewriting ${e.written.join(", ")} in place`],
13894
- ...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)}`]
13895
14014
  ];
13896
14015
  }
13897
14016
  function importNotice(e) {
13898
14017
  const { slug } = e.stack;
13899
14018
  const changes = treeChanges(e);
13900
- const files = changes.length > 0 ? `, ${changes.join(" and ")}` : "";
14019
+ const files = changes.length > 0 ? `, ${listed(changes)}` : "";
13901
14020
  const imported = `Imported ${e.importBlocks} resource(s) into ${slug}${files}.`;
13902
14021
  if (e.validate.exitClass !== "ok") {
13903
14022
  return ["warn", `${imported} ${didNotValidate(e.validate)}`, ...beside(e.validate)];
@@ -13941,7 +14060,8 @@ function validateNotice(v) {
13941
14060
  return ["warn", why === void 0 ? "Not valid for Lace" : `Not valid: ${why}`];
13942
14061
  }
13943
14062
  function convertNotice(e) {
13944
- const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written` : "Already lace-style \u2014 nothing to write";
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";
13945
14065
  if (e.validate.exitClass !== "ok") {
13946
14066
  return ["warn", `${converted}. ${didNotValidate(e.validate)}`, ...beside(e.validate)];
13947
14067
  }
@@ -13966,6 +14086,18 @@ var convert = defineCommand({
13966
14086
  consume: (rt, e) => rt.ports.presenter.notify(...convertNotice(e))
13967
14087
  }
13968
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
+ });
13969
14101
  var preview = defineCommand({
13970
14102
  kind: "command",
13971
14103
  path: "stack preview",
@@ -14083,6 +14215,18 @@ var STACK_COMMAND_ACTIONS = [
14083
14215
  answers: ["import_residual"],
14084
14216
  binding: importPartial
14085
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
+ },
14086
14230
  {
14087
14231
  id: "preview",
14088
14232
  label: "Preview",
@@ -14116,9 +14260,16 @@ var CORE_COMMAND_ACTIONS = [
14116
14260
  ];
14117
14261
 
14118
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
+ }
14119
14266
  function entryScopeIds(view) {
14120
- const nested = new Set(view.groups.flatMap((g) => g.node_ids));
14121
- return [...view.nodes, ...view.groups].map((n) => n.id).filter((id) => !nested.has(id));
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;
14122
14273
  }
14123
14274
  function inEntryScope(view, ids) {
14124
14275
  const entry = new Set(entryScopeIds(view));
@@ -14140,6 +14291,7 @@ var CONTEXT_NEEDS = {
14140
14291
  "selection.node": "a selected node",
14141
14292
  "selection.several": "two selected nodes or more",
14142
14293
  "selection.entryScope": "a selected top-level node or group",
14294
+ "selection.oneScope": "selected nodes that share one scope",
14143
14295
  "selection.edge": "one selected connection",
14144
14296
  "selection.edges": "selected connections",
14145
14297
  diagnostics: "diagnostics to show",
@@ -14158,7 +14310,14 @@ var TARGET_NEEDS = {
14158
14310
  failure: "a failed command"
14159
14311
  };
14160
14312
  function busyReason(busy) {
14161
- 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
+ }
14162
14321
  }
14163
14322
  function runsOn(action, ctx, target) {
14164
14323
  if (action.requiredTarget?.includes("runId")) return `run:${target.runId}`;
@@ -14184,6 +14343,8 @@ function keySatisfied(ctx, key) {
14184
14343
  if (key === "selection.several") return (ctx.selection?.nodes.length ?? 0) > 1;
14185
14344
  if (key === "selection.entryScope")
14186
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);
14187
14348
  if (key === "selection.edge") return wiresAlone(ctx) === 1;
14188
14349
  if (key === "selection.edges") return wiresAlone(ctx) > 0;
14189
14350
  if (key === "diagnostics") return ctx.diagnostics !== void 0 && ctx.diagnostics.length > 0;
@@ -14249,6 +14410,15 @@ function unmetRequirement(action, ports, ctx, target) {
14249
14410
  }
14250
14411
 
14251
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
+ }
14252
14422
  function createClipboardStore() {
14253
14423
  let clip = null;
14254
14424
  return {
@@ -14292,20 +14462,7 @@ function createActionRunner(ports, store, options = {}) {
14292
14462
  } catch (error) {
14293
14463
  const message = error instanceof Error ? error.message : String(error);
14294
14464
  ports.presenter.notify("error", message);
14295
- return {
14296
- success: false,
14297
- errors: [
14298
- {
14299
- moduleKey: "",
14300
- instanceId: "",
14301
- inputName: "",
14302
- message,
14303
- reason: rejectionReason(error)
14304
- }
14305
- ],
14306
- created: [],
14307
- ties: []
14308
- };
14465
+ return refusedBatch(message, rejectionReason(error));
14309
14466
  }
14310
14467
  if (!result.success) {
14311
14468
  for (const err of result.errors) ports.presenter.notify("error", err.message);
@@ -14324,8 +14481,14 @@ function createActionRunner(ports, store, options = {}) {
14324
14481
  async function applyActions(actions) {
14325
14482
  const editor = ports.editor;
14326
14483
  if (!editor) return;
14484
+ if (edits > 0) return heldEdit();
14327
14485
  return asEdit(() => applyWith(editor, actions));
14328
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
+ }
14329
14492
  function askConfirm(spec) {
14330
14493
  const confirm = ports.presenter.confirm;
14331
14494
  return confirm ? confirm(spec) : Promise.resolve(false);
@@ -14362,8 +14525,14 @@ function createActionRunner(ports, store, options = {}) {
14362
14525
  }
14363
14526
  function busyOf(action, ctx, target) {
14364
14527
  const binding = action.binding;
14365
- if (binding.kind !== "command") return void 0;
14366
- 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
+ }
14367
14536
  }
14368
14537
  function cwdOf(action, ctx) {
14369
14538
  return (action.requiredContext ?? []).includes("root") ? ctx.root : void 0;
@@ -14664,6 +14833,7 @@ function autosave(source, save, policy, report) {
14664
14833
  autosave,
14665
14834
  bridgeCaller,
14666
14835
  carriesFailure,
14836
+ commandPathOf,
14667
14837
  commandUnderWay,
14668
14838
  connectCaller,
14669
14839
  createActionRunner,