@promptctl/cc-candybar 1.28.0 → 1.30.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.
@@ -27,9 +27,11 @@ import { toString as varToString } from "../var-system/types.js";
27
27
  import { buildScope } from "../template-engine/scope.js";
28
28
  import type { ActionDecl } from "../config/action.js";
29
29
  import { resolveOptionDomain } from "../config/option-domain.js";
30
+ import { encodeLayoutOp, type LayoutOp } from "../config/layout-ops.js";
30
31
  import type { StripStyle } from "../themes/policy.js";
31
32
  import {
32
33
  effectsUrl,
34
+ VERB_APPLY_LAYOUT_OP,
33
35
  VERB_COPY,
34
36
  VERB_OPEN_VSCODE,
35
37
  VERB_RESET_CONFIG,
@@ -135,7 +137,12 @@ export type CompiledActionDecl =
135
137
  // one config-overrides key. Carries only the key — there is no value to
136
138
  // realize, so it shares copy/open's "no gate" shape at compile time (the
137
139
  // GATE is the key-membership check the reset-config verb handler applies).
138
- | { readonly kind: "reset"; readonly key: string };
140
+ | { readonly kind: "reset"; readonly key: string }
141
+ // [LAW:one-source-of-truth] brandon-layout-edit-2gc.1's structural-edit
142
+ // arms. Fully literal at compile time (the op IS the declaration — no
143
+ // template-bound option, unlike persist-option), so `op` is precomputed
144
+ // here rather than reconstructed from raw fields at every realize() call.
145
+ | { readonly kind: "layout-op"; readonly key: string; readonly op: LayoutOp };
139
146
 
140
147
  export type CompiledActions = ReadonlyMap<string, CompiledActionDecl>;
141
148
 
@@ -294,6 +301,25 @@ function compileAction(
294
301
  members: action.cycle,
295
302
  };
296
303
  }
304
+ if ("removeSegment" in action) {
305
+ return {
306
+ kind: "layout-op",
307
+ key: action.persist,
308
+ op: { op: "remove", target: action.removeSegment },
309
+ };
310
+ }
311
+ if ("insertSegment" in action) {
312
+ return {
313
+ kind: "layout-op",
314
+ key: action.persist,
315
+ op: {
316
+ op: "insert",
317
+ segment: action.insertSegment,
318
+ anchor: action.anchor,
319
+ relation: action.relation,
320
+ },
321
+ };
322
+ }
297
323
  return {
298
324
  kind: "persist-bounded",
299
325
  key: action.persist,
@@ -522,6 +548,20 @@ function realize(
522
548
  effect: { verb: VERB_RESET_CONFIG, args: [sessionId, c.key] },
523
549
  active: false,
524
550
  };
551
+ // [LAW:one-source-of-truth] The op is fixed at compile time (see
552
+ // compileAction) — the click just delivers it. `apply-layout-op`'s
553
+ // handler does read-current-append-write (see verbs/index.ts), unlike
554
+ // persist-literal's plain overwrite, so it is its own verb rather than
555
+ // VERB_SET_CONFIG. Never "active": a structural edit is a one-shot
556
+ // trigger, not a current-selection toggle.
557
+ case "layout-op":
558
+ return {
559
+ effect: {
560
+ verb: VERB_APPLY_LAYOUT_OP,
561
+ args: [sessionId, c.key, encodeLayoutOp(c.op)],
562
+ },
563
+ active: false,
564
+ };
525
565
  }
526
566
  }
527
567