@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.
@@ -3384,6 +3384,7 @@ var Reason = /* @__PURE__ */ ((Reason2) => {
3384
3384
  Reason2[Reason2["REASON_NO_ORIGIN_REMOTE"] = 19] = "REASON_NO_ORIGIN_REMOTE";
3385
3385
  Reason2[Reason2["REASON_IMPORT_UNDECLARED"] = 20] = "REASON_IMPORT_UNDECLARED";
3386
3386
  Reason2[Reason2["REASON_ALREADY_IMPORTED"] = 21] = "REASON_ALREADY_IMPORTED";
3387
+ Reason2[Reason2["REASON_NO_LOCKFILE"] = 22] = "REASON_NO_LOCKFILE";
3387
3388
  Reason2[Reason2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
3388
3389
  return Reason2;
3389
3390
  })(Reason || {});
@@ -3455,6 +3456,9 @@ function reasonFromJSON(object) {
3455
3456
  case 21:
3456
3457
  case "REASON_ALREADY_IMPORTED":
3457
3458
  return 21 /* REASON_ALREADY_IMPORTED */;
3459
+ case 22:
3460
+ case "REASON_NO_LOCKFILE":
3461
+ return 22 /* REASON_NO_LOCKFILE */;
3458
3462
  case -1:
3459
3463
  case "UNRECOGNIZED":
3460
3464
  default:
@@ -3507,6 +3511,8 @@ function reasonToJSON(object) {
3507
3511
  return "REASON_IMPORT_UNDECLARED";
3508
3512
  case 21 /* REASON_ALREADY_IMPORTED */:
3509
3513
  return "REASON_ALREADY_IMPORTED";
3514
+ case 22 /* REASON_NO_LOCKFILE */:
3515
+ return "REASON_NO_LOCKFILE";
3510
3516
  case -1 /* UNRECOGNIZED */:
3511
3517
  default:
3512
3518
  return "UNRECOGNIZED";
@@ -10944,6 +10950,30 @@ import {
10944
10950
  ENGINE_PROTOCOL_VERSION
10945
10951
  } from "@lace-cloud/proto";
10946
10952
 
10953
+ // scripts/command-tree.mjs
10954
+ var EFFECTS = /* @__PURE__ */ new Map([
10955
+ ["writes", "write"],
10956
+ ["rewrites", "rewrite"]
10957
+ ]);
10958
+ var RESERVED = /* @__PURE__ */ new Set(["hidden", ...EFFECTS.keys()]);
10959
+ function commandWordsAt(words, { isNode: isNode2, rootFlags }) {
10960
+ const standsAlone = new Set(
10961
+ rootFlags.filter((f) => f.type === "bool").flatMap((f) => [`--${f.name}`, ...f.short ? [`-${f.short}`] : []])
10962
+ );
10963
+ const at = [];
10964
+ for (let i = 0; i < words.length; i++) {
10965
+ const word = words[i];
10966
+ if (word === "--") return { at, stop: i };
10967
+ if (word !== "" && !word.startsWith("-")) {
10968
+ if (!isNode2([...at.map((j) => words[j]), word].join(" "))) return { at, stop: i };
10969
+ at.push(i);
10970
+ } else if (!word.includes("=") && (word.startsWith("--") || word.length === 2) && !standsAlone.has(word)) {
10971
+ i++;
10972
+ }
10973
+ }
10974
+ return { at, stop: words.length };
10975
+ }
10976
+
10947
10977
  // src/contracts/commands.gen.ts
10948
10978
  var COMMANDS = {
10949
10979
  "chaos run": {
@@ -10989,7 +11019,8 @@ var COMMANDS = {
10989
11019
  "values": [
10990
11020
  "table",
10991
11021
  "json"
10992
- ]
11022
+ ],
11023
+ "short": "o"
10993
11024
  },
10994
11025
  "prUrl": {
10995
11026
  "type": "string"
@@ -11044,7 +11075,8 @@ var COMMANDS = {
11044
11075
  "values": [
11045
11076
  "table",
11046
11077
  "json"
11047
- ]
11078
+ ],
11079
+ "short": "o"
11048
11080
  },
11049
11081
  "team": {
11050
11082
  "type": "string"
@@ -11066,7 +11098,8 @@ var COMMANDS = {
11066
11098
  "values": [
11067
11099
  "table",
11068
11100
  "json"
11069
- ]
11101
+ ],
11102
+ "short": "o"
11070
11103
  },
11071
11104
  "provider": {
11072
11105
  "type": "string"
@@ -11087,7 +11120,8 @@ var COMMANDS = {
11087
11120
  "type": "bool"
11088
11121
  },
11089
11122
  "path": {
11090
- "type": "string"
11123
+ "type": "string",
11124
+ "short": "p"
11091
11125
  }
11092
11126
  },
11093
11127
  "effect": "write",
@@ -11099,7 +11133,8 @@ var COMMANDS = {
11099
11133
  "positionals": [],
11100
11134
  "flags": {
11101
11135
  "path": {
11102
- "type": "string"
11136
+ "type": "string",
11137
+ "short": "p"
11103
11138
  }
11104
11139
  },
11105
11140
  "effect": "write",
@@ -11133,7 +11168,8 @@ var COMMANDS = {
11133
11168
  "values": [
11134
11169
  "table",
11135
11170
  "json"
11136
- ]
11171
+ ],
11172
+ "short": "o"
11137
11173
  },
11138
11174
  "provider": {
11139
11175
  "type": "string"
@@ -11155,7 +11191,8 @@ var COMMANDS = {
11155
11191
  "values": [
11156
11192
  "table",
11157
11193
  "json"
11158
- ]
11194
+ ],
11195
+ "short": "o"
11159
11196
  }
11160
11197
  },
11161
11198
  "effect": "write",
@@ -11171,10 +11208,12 @@ var COMMANDS = {
11171
11208
  "values": [
11172
11209
  "table",
11173
11210
  "json"
11174
- ]
11211
+ ],
11212
+ "short": "o"
11175
11213
  },
11176
11214
  "path": {
11177
- "type": "string"
11215
+ "type": "string",
11216
+ "short": "p"
11178
11217
  }
11179
11218
  },
11180
11219
  "effect": "rewrite",
@@ -11195,10 +11234,12 @@ var COMMANDS = {
11195
11234
  "json",
11196
11235
  "terraform-docs-json",
11197
11236
  "terraform-docs-yaml"
11198
- ]
11237
+ ],
11238
+ "short": "o"
11199
11239
  },
11200
11240
  "path": {
11201
- "type": "string"
11241
+ "type": "string",
11242
+ "short": "p"
11202
11243
  }
11203
11244
  },
11204
11245
  "effect": "write",
@@ -11220,10 +11261,12 @@ var COMMANDS = {
11220
11261
  "values": [
11221
11262
  "table",
11222
11263
  "json"
11223
- ]
11264
+ ],
11265
+ "short": "o"
11224
11266
  },
11225
11267
  "path": {
11226
- "type": "string"
11268
+ "type": "string",
11269
+ "short": "p"
11227
11270
  },
11228
11271
  "recursive": {
11229
11272
  "type": "bool"
@@ -11245,10 +11288,12 @@ var COMMANDS = {
11245
11288
  "values": [
11246
11289
  "table",
11247
11290
  "json"
11248
- ]
11291
+ ],
11292
+ "short": "o"
11249
11293
  },
11250
11294
  "path": {
11251
- "type": "string"
11295
+ "type": "string",
11296
+ "short": "p"
11252
11297
  },
11253
11298
  "upgrade": {
11254
11299
  "type": "stringArray",
@@ -11272,10 +11317,12 @@ var COMMANDS = {
11272
11317
  "sarif",
11273
11318
  "junit",
11274
11319
  "checkstyle"
11275
- ]
11320
+ ],
11321
+ "short": "o"
11276
11322
  },
11277
11323
  "path": {
11278
- "type": "string"
11324
+ "type": "string",
11325
+ "short": "p"
11279
11326
  },
11280
11327
  "severity": {
11281
11328
  "type": "string",
@@ -11306,10 +11353,12 @@ var COMMANDS = {
11306
11353
  "values": [
11307
11354
  "table",
11308
11355
  "json"
11309
- ]
11356
+ ],
11357
+ "short": "o"
11310
11358
  },
11311
11359
  "path": {
11312
- "type": "string"
11360
+ "type": "string",
11361
+ "short": "p"
11313
11362
  },
11314
11363
  "view": {
11315
11364
  "type": "string",
@@ -11332,7 +11381,8 @@ var COMMANDS = {
11332
11381
  "values": [
11333
11382
  "table",
11334
11383
  "json"
11335
- ]
11384
+ ],
11385
+ "short": "o"
11336
11386
  }
11337
11387
  },
11338
11388
  "effect": "read",
@@ -11348,7 +11398,8 @@ var COMMANDS = {
11348
11398
  "values": [
11349
11399
  "table",
11350
11400
  "json"
11351
- ]
11401
+ ],
11402
+ "short": "o"
11352
11403
  }
11353
11404
  },
11354
11405
  "effect": "read",
@@ -11369,7 +11420,8 @@ var COMMANDS = {
11369
11420
  "values": [
11370
11421
  "table",
11371
11422
  "json"
11372
- ]
11423
+ ],
11424
+ "short": "o"
11373
11425
  }
11374
11426
  },
11375
11427
  "effect": "write",
@@ -11393,7 +11445,8 @@ var COMMANDS = {
11393
11445
  "values": [
11394
11446
  "table",
11395
11447
  "json"
11396
- ]
11448
+ ],
11449
+ "short": "o"
11397
11450
  },
11398
11451
  "team": {
11399
11452
  "type": "string"
@@ -11415,7 +11468,8 @@ var COMMANDS = {
11415
11468
  "values": [
11416
11469
  "table",
11417
11470
  "json"
11418
- ]
11471
+ ],
11472
+ "short": "o"
11419
11473
  },
11420
11474
  "stack": {
11421
11475
  "type": "string"
@@ -11445,7 +11499,8 @@ var COMMANDS = {
11445
11499
  "values": [
11446
11500
  "table",
11447
11501
  "json"
11448
- ]
11502
+ ],
11503
+ "short": "o"
11449
11504
  },
11450
11505
  "version": {
11451
11506
  "type": "string"
@@ -11472,7 +11527,8 @@ var COMMANDS = {
11472
11527
  "values": [
11473
11528
  "table",
11474
11529
  "json"
11475
- ]
11530
+ ],
11531
+ "short": "o"
11476
11532
  },
11477
11533
  "view": {
11478
11534
  "type": "string",
@@ -11515,7 +11571,8 @@ var COMMANDS = {
11515
11571
  "values": [
11516
11572
  "table",
11517
11573
  "json"
11518
- ]
11574
+ ],
11575
+ "short": "o"
11519
11576
  },
11520
11577
  "query": {
11521
11578
  "type": "string"
@@ -11551,7 +11608,8 @@ var COMMANDS = {
11551
11608
  "values": [
11552
11609
  "table",
11553
11610
  "json"
11554
- ]
11611
+ ],
11612
+ "short": "o"
11555
11613
  },
11556
11614
  "readme": {
11557
11615
  "type": "string"
@@ -11577,7 +11635,8 @@ var COMMANDS = {
11577
11635
  "type": "string",
11578
11636
  "values": [
11579
11637
  "json"
11580
- ]
11638
+ ],
11639
+ "short": "o"
11581
11640
  },
11582
11641
  "team": {
11583
11642
  "type": "string"
@@ -11604,7 +11663,8 @@ var COMMANDS = {
11604
11663
  "values": [
11605
11664
  "table",
11606
11665
  "json"
11607
- ]
11666
+ ],
11667
+ "short": "o"
11608
11668
  },
11609
11669
  "reason": {
11610
11670
  "type": "string"
@@ -11637,7 +11697,8 @@ var COMMANDS = {
11637
11697
  "values": [
11638
11698
  "table",
11639
11699
  "json"
11640
- ]
11700
+ ],
11701
+ "short": "o"
11641
11702
  },
11642
11703
  "team": {
11643
11704
  "type": "string"
@@ -11671,7 +11732,8 @@ var COMMANDS = {
11671
11732
  "values": [
11672
11733
  "table",
11673
11734
  "json"
11674
- ]
11735
+ ],
11736
+ "short": "o"
11675
11737
  },
11676
11738
  "stack": {
11677
11739
  "type": "string"
@@ -11710,7 +11772,8 @@ var COMMANDS = {
11710
11772
  "values": [
11711
11773
  "table",
11712
11774
  "json"
11713
- ]
11775
+ ],
11776
+ "short": "o"
11714
11777
  },
11715
11778
  "team": {
11716
11779
  "type": "string"
@@ -11737,7 +11800,8 @@ var COMMANDS = {
11737
11800
  "values": [
11738
11801
  "table",
11739
11802
  "json"
11740
- ]
11803
+ ],
11804
+ "short": "o"
11741
11805
  },
11742
11806
  "team": {
11743
11807
  "type": "string"
@@ -11770,7 +11834,8 @@ var COMMANDS = {
11770
11834
  "values": [
11771
11835
  "table",
11772
11836
  "json"
11773
- ]
11837
+ ],
11838
+ "short": "o"
11774
11839
  },
11775
11840
  "prUrl": {
11776
11841
  "type": "string"
@@ -11821,7 +11886,8 @@ var COMMANDS = {
11821
11886
  "values": [
11822
11887
  "table",
11823
11888
  "json"
11824
- ]
11889
+ ],
11890
+ "short": "o"
11825
11891
  },
11826
11892
  "source": {
11827
11893
  "type": "string"
@@ -11860,7 +11926,8 @@ var COMMANDS = {
11860
11926
  "values": [
11861
11927
  "table",
11862
11928
  "json"
11863
- ]
11929
+ ],
11930
+ "short": "o"
11864
11931
  },
11865
11932
  "team": {
11866
11933
  "type": "string"
@@ -11896,7 +11963,8 @@ var COMMANDS = {
11896
11963
  "values": [
11897
11964
  "table",
11898
11965
  "json"
11899
- ]
11966
+ ],
11967
+ "short": "o"
11900
11968
  },
11901
11969
  "team": {
11902
11970
  "type": "string"
@@ -11932,7 +12000,8 @@ var COMMANDS = {
11932
12000
  "values": [
11933
12001
  "table",
11934
12002
  "json"
11935
- ]
12003
+ ],
12004
+ "short": "o"
11936
12005
  },
11937
12006
  "prUrl": {
11938
12007
  "type": "string"
@@ -11979,7 +12048,8 @@ var COMMANDS = {
11979
12048
  "values": [
11980
12049
  "table",
11981
12050
  "json"
11982
- ]
12051
+ ],
12052
+ "short": "o"
11983
12053
  },
11984
12054
  "team": {
11985
12055
  "type": "string"
@@ -12009,10 +12079,12 @@ var COMMANDS = {
12009
12079
  "values": [
12010
12080
  "table",
12011
12081
  "json"
12012
- ]
12082
+ ],
12083
+ "short": "o"
12013
12084
  },
12014
12085
  "path": {
12015
- "type": "string"
12086
+ "type": "string",
12087
+ "short": "p"
12016
12088
  },
12017
12089
  "state": {
12018
12090
  "type": "string",
@@ -12047,7 +12119,8 @@ var COMMANDS = {
12047
12119
  "values": [
12048
12120
  "table",
12049
12121
  "json"
12050
- ]
12122
+ ],
12123
+ "short": "o"
12051
12124
  },
12052
12125
  "source": {
12053
12126
  "type": "string"
@@ -12077,7 +12150,8 @@ var COMMANDS = {
12077
12150
  "values": [
12078
12151
  "table",
12079
12152
  "json"
12080
- ]
12153
+ ],
12154
+ "short": "o"
12081
12155
  },
12082
12156
  "team": {
12083
12157
  "type": "string"
@@ -12115,7 +12189,8 @@ var COMMANDS = {
12115
12189
  "values": [
12116
12190
  "table",
12117
12191
  "json"
12118
- ]
12192
+ ],
12193
+ "short": "o"
12119
12194
  },
12120
12195
  "team": {
12121
12196
  "type": "string"
@@ -12154,7 +12229,8 @@ var COMMANDS = {
12154
12229
  "values": [
12155
12230
  "table",
12156
12231
  "json"
12157
- ]
12232
+ ],
12233
+ "short": "o"
12158
12234
  },
12159
12235
  "sourcePath": {
12160
12236
  "type": "string"
@@ -12185,7 +12261,8 @@ var COMMANDS = {
12185
12261
  "values": [
12186
12262
  "table",
12187
12263
  "json"
12188
- ]
12264
+ ],
12265
+ "short": "o"
12189
12266
  }
12190
12267
  },
12191
12268
  "effect": "read",
@@ -12210,7 +12287,8 @@ var COMMANDS = {
12210
12287
  "values": [
12211
12288
  "table",
12212
12289
  "json"
12213
- ]
12290
+ ],
12291
+ "short": "o"
12214
12292
  }
12215
12293
  },
12216
12294
  "effect": "read",
@@ -12234,7 +12312,8 @@ var COMMANDS = {
12234
12312
  "values": [
12235
12313
  "table",
12236
12314
  "json"
12237
- ]
12315
+ ],
12316
+ "short": "o"
12238
12317
  }
12239
12318
  },
12240
12319
  "effect": "write",
@@ -12250,7 +12329,8 @@ var COMMANDS = {
12250
12329
  "values": [
12251
12330
  "table",
12252
12331
  "json"
12253
- ]
12332
+ ],
12333
+ "short": "o"
12254
12334
  }
12255
12335
  },
12256
12336
  "effect": "read",
@@ -12266,7 +12346,8 @@ var COMMANDS = {
12266
12346
  "values": [
12267
12347
  "table",
12268
12348
  "json"
12269
- ]
12349
+ ],
12350
+ "short": "o"
12270
12351
  }
12271
12352
  },
12272
12353
  "effect": "read",
@@ -12274,6 +12355,21 @@ var COMMANDS = {
12274
12355
  "yes": false
12275
12356
  }
12276
12357
  };
12358
+ function isCommandPath(path) {
12359
+ return Object.prototype.hasOwnProperty.call(COMMANDS, path);
12360
+ }
12361
+ var ROOT_FLAGS = [
12362
+ {
12363
+ "name": "auth-url",
12364
+ "type": "string",
12365
+ "short": null
12366
+ },
12367
+ {
12368
+ "name": "timeout",
12369
+ "type": "duration",
12370
+ "short": null
12371
+ }
12372
+ ];
12277
12373
  function dashed(name) {
12278
12374
  return name.replace(/([A-Z])/g, (m) => `-${m.toLowerCase()}`);
12279
12375
  }
@@ -12304,6 +12400,12 @@ function toArgv(path, args) {
12304
12400
  }
12305
12401
  return argv;
12306
12402
  }
12403
+ var isNode = (path) => Object.keys(COMMANDS).some((p) => p === path || p.startsWith(`${path} `));
12404
+ function commandPathOf(words) {
12405
+ const { at } = commandWordsAt(words, { isNode, rootFlags: ROOT_FLAGS });
12406
+ const path = at.map((i) => words[i]).join(" ");
12407
+ return isCommandPath(path) ? path : void 0;
12408
+ }
12307
12409
 
12308
12410
  // src/contracts/complete-args.ts
12309
12411
  function requiredArgKeys(path) {
@@ -12792,7 +12894,7 @@ var gateChangeRequestSchema = z.object({
12792
12894
  });
12793
12895
  var runEventSchema = z.discriminatedUnion("type", [
12794
12896
  z.object({ type: z.literal("log"), text: z.string() }),
12795
- z.object({ type: z.literal("phase"), name: z.string() }),
12897
+ z.object({ type: z.literal("stage"), name: z.string() }),
12796
12898
  z.object({
12797
12899
  type: z.literal("gate"),
12798
12900
  resolution: z.object({ mode: z.string(), reason: z.string().optional() }),
@@ -12805,7 +12907,6 @@ var runEventSchema = z.discriminatedUnion("type", [
12805
12907
  type: z.literal("result"),
12806
12908
  run: runSchema,
12807
12909
  summary: planSummarySchema,
12808
- workspaceDir: z.string(),
12809
12910
  error: z.string().nullable()
12810
12911
  })
12811
12912
  ]);
@@ -12819,7 +12920,6 @@ var stackScanSchema = z.object({
12819
12920
  scannedAt: z.string(),
12820
12921
  undeterminedReason: z.string().nullable(),
12821
12922
  undeterminedMessage: z.string().nullable(),
12822
- standingDriftFindings: z.number(),
12823
12923
  footprintDestroyed: z.boolean(),
12824
12924
  drift: driftSchema
12825
12925
  }).nullable()
@@ -13345,6 +13445,11 @@ function convertCreatedRef(r) {
13345
13445
  return { scope: r.scope, id: r.id, moduleKey: r.module_key, sourceId: r.source_id };
13346
13446
  }
13347
13447
 
13448
+ // src/utils/counted.ts
13449
+ function counted(n, noun) {
13450
+ return `${n} ${noun}${n === 1 ? "" : "s"}`;
13451
+ }
13452
+
13348
13453
  // src/core/diagnostics.ts
13349
13454
  var NOT_LACE_SHAPE = "not_lace_shape";
13350
13455
  function holdsLaceShapeRefusal(diagnostics) {
@@ -13480,46 +13585,50 @@ function commandUnderWay({
13480
13585
  }) {
13481
13586
  return run?.outcome.kind === "running" || preview2?.outcome.kind === "running" || running.size > 0;
13482
13587
  }
13483
- function withPhase(phases, name) {
13484
- return [...phases.map((p) => ({ ...p, status: "done" })), { name, status: "current" }];
13588
+ function withStage(stages, name) {
13589
+ return [...stages.map((s) => ({ ...s, status: "done" })), { name, status: "current" }];
13485
13590
  }
13486
- function closePhases(phases) {
13487
- return phases.map((p) => p.status === "done" ? p : { ...p, status: "done" });
13591
+ function closeStages(stages) {
13592
+ return stages.map((s) => s.status === "done" ? s : { ...s, status: "done" });
13488
13593
  }
13489
13594
  function reduceRun(prev, token, event) {
13490
13595
  const carried = prev && prev.token === token ? prev : null;
13596
+ const run = event.type === "result" ? event.run : carried?.run ?? null;
13491
13597
  const lastLog = event.type === "log" ? event.text : carried?.lastLog ?? null;
13492
- const phases = event.type === "phase" ? withPhase(carried?.phases ?? [], event.name) : carried?.phases ?? [];
13493
- const submitted = carried?.submitted || event.type === "phase" && event.name === "submit";
13598
+ const stages = event.type === "stage" ? withStage(carried?.stages ?? [], event.name) : carried?.stages ?? [];
13599
+ const submitted = carried?.submitted || event.type === "stage" && event.name === "submit";
13494
13600
  if (event.type === "gate" && event.changeRequest !== null) {
13495
13601
  return {
13496
13602
  token,
13497
- outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest, runUrl: null },
13603
+ outcome: { kind: "awaiting-approval", changeRequest: event.changeRequest },
13604
+ run,
13498
13605
  lastLog,
13499
13606
  submitted,
13500
- phases: closePhases(phases)
13607
+ stages: closeStages(stages)
13501
13608
  };
13502
13609
  }
13503
13610
  if (event.type === "result") {
13504
13611
  if (carried?.outcome.kind === "awaiting-approval") {
13505
13612
  return {
13506
13613
  token,
13507
- outcome: { ...carried.outcome, runUrl: event.run.url ?? null },
13614
+ outcome: carried.outcome,
13615
+ run,
13508
13616
  lastLog,
13509
13617
  submitted,
13510
- phases
13618
+ stages
13511
13619
  };
13512
13620
  }
13513
13621
  if (!event.error)
13514
13622
  return {
13515
13623
  token,
13516
13624
  outcome: { kind: "succeeded" },
13625
+ run,
13517
13626
  lastLog,
13518
13627
  submitted,
13519
- phases: closePhases(phases)
13628
+ stages: closeStages(stages)
13520
13629
  };
13521
13630
  }
13522
- return { token, outcome: { kind: "running" }, lastLog, submitted, phases };
13631
+ return { token, outcome: { kind: "running" }, run, lastLog, submitted, stages };
13523
13632
  }
13524
13633
  function runningFor(slot, token) {
13525
13634
  if (slot?.token !== token) return false;
@@ -13540,31 +13649,34 @@ function failureSays(error) {
13540
13649
  }
13541
13650
  function settleRun(prev, token, error) {
13542
13651
  const carried = prev && prev.token === token ? prev : null;
13652
+ const run = carried?.run ?? null;
13543
13653
  const lastLog = carried?.lastLog ?? null;
13544
13654
  const submitted = carried?.submitted ?? false;
13545
- const phases = closePhases(carried?.phases ?? []);
13655
+ const stages = closeStages(carried?.stages ?? []);
13546
13656
  if (error instanceof CommandDetachedError || error instanceof CommandUnobservedError)
13547
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13657
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13548
13658
  if (error instanceof CommandExitError) {
13549
13659
  if (error.code === 130)
13550
- return { token, outcome: { kind: "cancelled" }, lastLog, submitted, phases };
13660
+ return { token, outcome: { kind: "cancelled" }, run, lastLog, submitted, stages };
13551
13661
  if (error.code === 143)
13552
- return { token, outcome: { kind: "detached", submitted }, lastLog, submitted, phases };
13662
+ return { token, outcome: { kind: "detached", submitted }, run, lastLog, submitted, stages };
13553
13663
  if (error.code === 7)
13554
13664
  return {
13555
13665
  token,
13556
13666
  outcome: { kind: "blocked", ...failureSays(error) },
13667
+ run,
13557
13668
  lastLog,
13558
13669
  submitted,
13559
- phases
13670
+ stages
13560
13671
  };
13561
13672
  }
13562
13673
  return {
13563
13674
  token,
13564
13675
  outcome: { kind: "failed", ...failureSays(error) },
13676
+ run,
13565
13677
  lastLog,
13566
13678
  submitted,
13567
- phases
13679
+ stages
13568
13680
  };
13569
13681
  }
13570
13682
  function reducePreview(_prev, token, event) {
@@ -13637,9 +13749,10 @@ function createResultStore() {
13637
13749
  run: {
13638
13750
  token,
13639
13751
  outcome: { kind: "running" },
13752
+ run: null,
13640
13753
  lastLog: null,
13641
13754
  submitted: false,
13642
- phases: [],
13755
+ stages: [],
13643
13756
  readOver
13644
13757
  }
13645
13758
  };
@@ -13748,7 +13861,7 @@ function whyNotValid(v) {
13748
13861
  if (v.failure) return v.failure.message;
13749
13862
  const errors = v.diagnostics.filter((d) => d.severity === "error");
13750
13863
  if (errors.length === 0) return void 0;
13751
- return `${errors[0].message} (${errors.length} ${errors.length === 1 ? "error" : "errors"})`;
13864
+ return `${errors[0].message} (${counted(errors.length, "error")})`;
13752
13865
  }
13753
13866
  function didNotValidate(v) {
13754
13867
  const why = whyNotValid(v);
@@ -13758,6 +13871,16 @@ function lockFailed(e) {
13758
13871
  return e.changed && e.lock === null;
13759
13872
  }
13760
13873
  var DID_NOT_LOCK = "The tree's providers did not lock: run `lace module lock` once the cause is fixed, before you commit it.";
13874
+ function lockfileOf(lock2) {
13875
+ const root = lock2.path.endsWith("/") ? lock2.path : `${lock2.path}/`;
13876
+ return lock2.lockfile.startsWith(root) ? lock2.lockfile.slice(root.length) : lock2.lockfile;
13877
+ }
13878
+ function lockedIn(lock2) {
13879
+ return `${counted(lock2.providers.length, "provider")} in ${lockfileOf(lock2)}`;
13880
+ }
13881
+ function listed(parts) {
13882
+ return parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
13883
+ }
13761
13884
  function beside(v) {
13762
13885
  return v.failure ? [v.failure] : [];
13763
13886
  }
@@ -13805,12 +13928,6 @@ function scanNotice(e) {
13805
13928
  `Drift scan complete for stack ${slug}: IN_SYNC (0 drifted) \u2014 its resources were destroyed, so there was nothing to compare.`
13806
13929
  ];
13807
13930
  }
13808
- if (settled.standingDriftFindings > 0) {
13809
- return [
13810
- "info",
13811
- `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.`
13812
- ];
13813
- }
13814
13931
  return [
13815
13932
  "info",
13816
13933
  `Drift scan complete for stack ${slug}: ${settled.driftStatus} (${settled.driftCount} drifted).`
@@ -13842,13 +13959,14 @@ function residualAddresses(residuals) {
13842
13959
  function treeChanges(e) {
13843
13960
  return [
13844
13961
  ...e.written.length === 0 ? [] : [`rewriting ${e.written.join(", ")} in place`],
13845
- ...e.removed.length === 0 ? [] : [`removing ${e.removed.join(", ")}`]
13962
+ ...e.removed.length === 0 ? [] : [`removing ${e.removed.join(", ")}`],
13963
+ ...e.lock === null ? [] : [`locking ${lockedIn(e.lock)}`]
13846
13964
  ];
13847
13965
  }
13848
13966
  function importNotice(e) {
13849
13967
  const { slug } = e.stack;
13850
13968
  const changes = treeChanges(e);
13851
- const files = changes.length > 0 ? `, ${changes.join(" and ")}` : "";
13969
+ const files = changes.length > 0 ? `, ${listed(changes)}` : "";
13852
13970
  const imported = `Imported ${e.importBlocks} resource(s) into ${slug}${files}.`;
13853
13971
  if (e.validate.exitClass !== "ok") {
13854
13972
  return ["warn", `${imported} ${didNotValidate(e.validate)}`, ...beside(e.validate)];
@@ -13892,7 +14010,8 @@ function validateNotice(v) {
13892
14010
  return ["warn", why === void 0 ? "Not valid for Lace" : `Not valid: ${why}`];
13893
14011
  }
13894
14012
  function convertNotice(e) {
13895
- const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written` : "Already lace-style \u2014 nothing to write";
14013
+ const locked = e.lock === null ? "" : `, locking ${lockedIn(e.lock)}`;
14014
+ const converted = e.changed ? `Converted \u2014 ${e.written.length} file(s) written${locked}` : "Already lace-style \u2014 nothing to write";
13896
14015
  if (e.validate.exitClass !== "ok") {
13897
14016
  return ["warn", `${converted}. ${didNotValidate(e.validate)}`, ...beside(e.validate)];
13898
14017
  }
@@ -13917,6 +14036,18 @@ var convert = defineCommand({
13917
14036
  consume: (rt, e) => rt.ports.presenter.notify(...convertNotice(e))
13918
14037
  }
13919
14038
  });
14039
+ var lock = defineCommand({
14040
+ kind: "command",
14041
+ path: "module lock",
14042
+ args: () => ({}),
14043
+ result: {
14044
+ kind: "notify",
14045
+ consume: (rt, e) => rt.ports.presenter.notify(
14046
+ "info",
14047
+ `Locked ${lockedIn(e)}. Commit it beside the tree, then run the command again.`
14048
+ )
14049
+ }
14050
+ });
13920
14051
  var preview = defineCommand({
13921
14052
  kind: "command",
13922
14053
  path: "stack preview",
@@ -14034,6 +14165,18 @@ var STACK_COMMAND_ACTIONS = [
14034
14165
  answers: ["import_residual"],
14035
14166
  binding: importPartial
14036
14167
  },
14168
+ // `stack apply`, `stack destroy` and `stack preview` refuse a root that
14169
+ // keeps no lockfile: `module lock`, run in the refused command's root,
14170
+ // writes it.
14171
+ {
14172
+ id: "lock-missing",
14173
+ label: "Lock providers",
14174
+ placement: { row: "failure" },
14175
+ requiredPorts: ["commands"],
14176
+ requiredContext: ["root"],
14177
+ answers: ["no_lockfile"],
14178
+ binding: lock
14179
+ },
14037
14180
  {
14038
14181
  id: "preview",
14039
14182
  label: "Preview",
@@ -14067,9 +14210,16 @@ var CORE_COMMAND_ACTIONS = [
14067
14210
  ];
14068
14211
 
14069
14212
  // src/core/entry-scope.ts
14213
+ function enclosingGroups(view) {
14214
+ return new Map(view.groups.flatMap((g) => g.node_ids.map((id) => [id, g.id])));
14215
+ }
14070
14216
  function entryScopeIds(view) {
14071
- const nested = new Set(view.groups.flatMap((g) => g.node_ids));
14072
- return [...view.nodes, ...view.groups].map((n) => n.id).filter((id) => !nested.has(id));
14217
+ const enclosing = enclosingGroups(view);
14218
+ return [...view.nodes, ...view.groups].map((n) => n.id).filter((id) => !enclosing.has(id));
14219
+ }
14220
+ function inOneScope(view, ids) {
14221
+ const enclosing = enclosingGroups(view);
14222
+ return new Set(ids.map((id) => enclosing.get(id) ?? null)).size <= 1;
14073
14223
  }
14074
14224
  function inEntryScope(view, ids) {
14075
14225
  const entry = new Set(entryScopeIds(view));
@@ -14091,6 +14241,7 @@ var CONTEXT_NEEDS = {
14091
14241
  "selection.node": "a selected node",
14092
14242
  "selection.several": "two selected nodes or more",
14093
14243
  "selection.entryScope": "a selected top-level node or group",
14244
+ "selection.oneScope": "selected nodes that share one scope",
14094
14245
  "selection.edge": "one selected connection",
14095
14246
  "selection.edges": "selected connections",
14096
14247
  diagnostics: "diagnostics to show",
@@ -14109,7 +14260,14 @@ var TARGET_NEEDS = {
14109
14260
  failure: "a failed command"
14110
14261
  };
14111
14262
  function busyReason(busy) {
14112
- return busy.kind === "run" ? "A run is in progress" : `${busy.running.label} is running`;
14263
+ switch (busy.kind) {
14264
+ case "run":
14265
+ return "A run is in progress";
14266
+ case "notify":
14267
+ return `${busy.running.label} is running`;
14268
+ case "edit":
14269
+ return "An edit is in progress";
14270
+ }
14113
14271
  }
14114
14272
  function runsOn(action, ctx, target) {
14115
14273
  if (action.requiredTarget?.includes("runId")) return `run:${target.runId}`;
@@ -14135,6 +14293,8 @@ function keySatisfied(ctx, key) {
14135
14293
  if (key === "selection.several") return (ctx.selection?.nodes.length ?? 0) > 1;
14136
14294
  if (key === "selection.entryScope")
14137
14295
  return ctx.view !== void 0 && ctx.selection !== void 0 && inEntryScope(ctx.view, ctx.selection.nodes).length > 0;
14296
+ if (key === "selection.oneScope")
14297
+ return ctx.view !== void 0 && ctx.selection !== void 0 && inOneScope(ctx.view, ctx.selection.nodes);
14138
14298
  if (key === "selection.edge") return wiresAlone(ctx) === 1;
14139
14299
  if (key === "selection.edges") return wiresAlone(ctx) > 0;
14140
14300
  if (key === "diagnostics") return ctx.diagnostics !== void 0 && ctx.diagnostics.length > 0;
@@ -14163,7 +14323,7 @@ function busyLabelOf(action, ctx, busy) {
14163
14323
  return ctx.generating ? label[ctx.generating] : void 0;
14164
14324
  }
14165
14325
  if (busy === void 0 || action.binding.kind !== "command") return void 0;
14166
- return busy.kind === "run" || busy.running.path === action.binding.path ? action.label : void 0;
14326
+ return busy.kind === "run" || busy.kind === "notify" && busy.running.path === action.binding.path ? action.label : void 0;
14167
14327
  }
14168
14328
  function actionState(action, ctx, busy) {
14169
14329
  return {
@@ -14250,6 +14410,15 @@ function rowActions(resolved, panelId) {
14250
14410
  }
14251
14411
 
14252
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
+ }
14253
14422
  function createClipboardStore() {
14254
14423
  let clip = null;
14255
14424
  return {
@@ -14293,20 +14462,7 @@ function createActionRunner(ports, store, options = {}) {
14293
14462
  } catch (error) {
14294
14463
  const message = error instanceof Error ? error.message : String(error);
14295
14464
  ports.presenter.notify("error", message);
14296
- return {
14297
- success: false,
14298
- errors: [
14299
- {
14300
- moduleKey: "",
14301
- instanceId: "",
14302
- inputName: "",
14303
- message,
14304
- reason: rejectionReason(error)
14305
- }
14306
- ],
14307
- created: [],
14308
- ties: []
14309
- };
14465
+ return refusedBatch(message, rejectionReason(error));
14310
14466
  }
14311
14467
  if (!result.success) {
14312
14468
  for (const err of result.errors) ports.presenter.notify("error", err.message);
@@ -14325,8 +14481,14 @@ function createActionRunner(ports, store, options = {}) {
14325
14481
  async function applyActions(actions) {
14326
14482
  const editor = ports.editor;
14327
14483
  if (!editor) return;
14484
+ if (edits > 0) return heldEdit();
14328
14485
  return asEdit(() => applyWith(editor, actions));
14329
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
+ }
14330
14492
  function askConfirm(spec) {
14331
14493
  const confirm = ports.presenter.confirm;
14332
14494
  return confirm ? confirm(spec) : Promise.resolve(false);
@@ -14363,8 +14525,14 @@ function createActionRunner(ports, store, options = {}) {
14363
14525
  }
14364
14526
  function busyOf(action, ctx, target) {
14365
14527
  const binding = action.binding;
14366
- if (binding.kind !== "command") return void 0;
14367
- 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
+ }
14368
14536
  }
14369
14537
  function cwdOf(action, ctx) {
14370
14538
  return (action.requiredContext ?? []).includes("root") ? ctx.root : void 0;
@@ -14659,6 +14827,7 @@ export {
14659
14827
  answering,
14660
14828
  resolveContributions,
14661
14829
  rowActions,
14830
+ counted,
14662
14831
  Bundle,
14663
14832
  InputMode,
14664
14833
  Reason,
@@ -14671,7 +14840,9 @@ export {
14671
14840
  CommandDetachedError,
14672
14841
  CommandUnobservedError,
14673
14842
  COMMANDS,
14843
+ isCommandPath,
14674
14844
  toArgv,
14845
+ commandPathOf,
14675
14846
  reasonWire,
14676
14847
  SCHEMAS,
14677
14848
  isBoundPath,
@@ -14705,4 +14876,4 @@ export {
14705
14876
  AutosaveEndedError,
14706
14877
  autosave
14707
14878
  };
14708
- //# sourceMappingURL=chunk-A3ATETIA.mjs.map
14879
+ //# sourceMappingURL=chunk-MVOO7T3B.mjs.map