unsys-canvas 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,20 @@
1
1
  # unsys-canvas
2
2
 
3
- React package: think on an Excalidraw board with a **host-supplied** LLM (`onAsk`). See the repository README for the public API, event types, and install spec.
4
-
5
- npm cannot install this folder via `github:…#ref:subdir` (that syntax is pnpm/yarn). From a clone:
3
+ MIT React package: think on an Excalidraw board with a **host-supplied** LLM (`onAsk`). Published as [`unsys-canvas`](https://www.npmjs.com/package/unsys-canvas) (currently 0.1.2).
6
4
 
7
5
  ```bash
8
- npm install ./packages/unsys-canvas
6
+ npm install unsys-canvas
7
+ ```
8
+
9
+ Peer dependencies: `react`, `react-dom`, and `@excalidraw/excalidraw@0.18.0-c0a0ca3`.
10
+
11
+ ```ts
12
+ import { UnsysCanvas } from "unsys-canvas";
13
+ import "unsys-canvas/styles.css";
9
14
  ```
10
15
 
11
- or `npm pack` in this directory and install the `.tgz`.
16
+ The package emits raw board changes and takes only a `style` prop for theming. It has no default LLM and knows nothing about proof of work or embeddings. See the [repository README](https://github.com/dncolomer/unsys-canvas) for the public API, event types, and demo.
17
+
18
+ ## License
19
+
20
+ MIT
package/dist/core.d.ts CHANGED
@@ -139,11 +139,11 @@ interface PromptImpactLayer {
139
139
  declare const UNSYS_CANVAS_COMMANDS: readonly [{
140
140
  readonly id: "simplify";
141
141
  readonly label: "Simplify";
142
- readonly tooltip: "Replace the selected marks with a shorter, plainer rewrite. If the selection is a term, make the meaning plain.";
142
+ readonly tooltip: "Keep the original marks and place a shorter, plainer rewrite next to them. If the selection is a term, make the meaning plain.";
143
143
  readonly shortcut: "s";
144
144
  readonly needsSelection: true;
145
145
  readonly boardOnly: false;
146
- readonly replacesSelection: true;
146
+ readonly replacesSelection: false;
147
147
  }, {
148
148
  readonly id: "breakdown";
149
149
  readonly label: "Subdivide";
@@ -186,6 +186,7 @@ type UnsysCanvasHostCommand = {
186
186
  shortcut?: string;
187
187
  slash?: string;
188
188
  needsSelection?: boolean;
189
+ /** Ignored. Only Refactor may replace the selection. */
189
190
  replacesSelection?: boolean;
190
191
  run?: (ctx: {
191
192
  selectedElements: UnsysCanvasElement[];
@@ -221,9 +222,9 @@ type UnsysCanvasCommandRun = {
221
222
  };
222
223
  /**
223
224
  * Local result of a sidebar/dock command click.
224
- * Subdivide, Focus, and Next mutate now. Simplify and Refactor drop the
225
- * original marks immediately, then ask XAI. Do/run and Concepts keep the
226
- * original and ask. A click that cannot run returns a short board notice instead of going silent.
225
+ * Subdivide, Focus, and Next mutate now. Refactor drops the original marks
226
+ * immediately, then asks XAI. Simplify, Do/run, and Concepts keep the original
227
+ * and ask. A click that cannot run returns a short board notice instead of going silent.
227
228
  */
228
229
  declare function runUnsysCanvasCommand(input: {
229
230
  action: UnsysCanvasCommandId;
package/dist/core.js CHANGED
@@ -2374,11 +2374,11 @@ var UNSYS_CANVAS_COMMANDS = [
2374
2374
  {
2375
2375
  id: "simplify",
2376
2376
  label: "Simplify",
2377
- tooltip: "Replace the selected marks with a shorter, plainer rewrite. If the selection is a term, make the meaning plain.",
2377
+ tooltip: "Keep the original marks and place a shorter, plainer rewrite next to them. If the selection is a term, make the meaning plain.",
2378
2378
  shortcut: "s",
2379
2379
  needsSelection: true,
2380
2380
  boardOnly: false,
2381
- replacesSelection: true
2381
+ replacesSelection: false
2382
2382
  },
2383
2383
  {
2384
2384
  id: "breakdown",
@@ -2432,7 +2432,7 @@ function unsysCanvasCommandsFor(_guide, extras = []) {
2432
2432
  shortcut: extra.shortcut ?? "",
2433
2433
  needsSelection: extra.needsSelection ?? false,
2434
2434
  boardOnly: false,
2435
- replacesSelection: extra.replacesSelection ?? false,
2435
+ replacesSelection: false,
2436
2436
  slash: extra.slash,
2437
2437
  run: extra.run
2438
2438
  });
@@ -2533,6 +2533,11 @@ function unsysCanvasBindFanArrow(arrow, start, end, hostBounds) {
2533
2533
  { id: arrow.id, type: "arrow" }
2534
2534
  ];
2535
2535
  }
2536
+ function unsysCanvasFanNoteKind(mark) {
2537
+ if (mark === "ileConcepts") return "concepts";
2538
+ if (mark === "ileSimplify") return "simplify";
2539
+ return "breakdown";
2540
+ }
2536
2541
  function unsysCanvasFanStem(host, hostRect, end, toX, toY, mark, hostBounds) {
2537
2542
  const startX = hostRect.maxX;
2538
2543
  const startY = (hostRect.minY + hostRect.maxY) / 2;
@@ -2637,7 +2642,7 @@ function fanUnsysCanvasLabeledNodes(scene, selectedElements, chunks, mark) {
2637
2642
  x: hostRect.maxX + gapX,
2638
2643
  y: cursorY,
2639
2644
  width: innerWidth,
2640
- label: unsysCanvasNoteLabel(mark === "ileConcepts" ? "concepts" : "breakdown"),
2645
+ label: unsysCanvasNoteLabel(unsysCanvasFanNoteKind(mark)),
2641
2646
  customData: { [mark]: true }
2642
2647
  });
2643
2648
  created.push(...note.elements);
@@ -2786,7 +2791,7 @@ function runUnsysCanvasCommand(input) {
2786
2791
  target ? "Need at least two words to subdivide." : "Select text, or a labeled shape, to subdivide."
2787
2792
  );
2788
2793
  }
2789
- if (input.action === "simplify" || input.action === "refactor") {
2794
+ if (input.action === "refactor") {
2790
2795
  const stripped = removeUnsysCanvasSelection(current, selected);
2791
2796
  return {
2792
2797
  scene: withUnsysCanvasAutoLayout(stripped.scene),
@@ -2794,10 +2799,13 @@ function runUnsysCanvasCommand(input) {
2794
2799
  parts: [],
2795
2800
  selected,
2796
2801
  prompt,
2797
- ask: { kind: input.action, prompt },
2802
+ ask: { kind: "refactor", prompt },
2798
2803
  notice: null
2799
2804
  };
2800
2805
  }
2806
+ if (input.action === "simplify") {
2807
+ return idle(null, { kind: "simplify", prompt });
2808
+ }
2801
2809
  if (input.action === "concepts") {
2802
2810
  return idle(null, { kind: "concepts", prompt });
2803
2811
  }
@@ -3310,13 +3318,18 @@ function applyUnsysCanvasAskReply(input) {
3310
3318
  let next = live;
3311
3319
  if (kind === "selective-compress") {
3312
3320
  next = compressUnsysCanvasSelection(live, selected, source);
3313
- } else if (kind === "simplify" || kind === "refactor") {
3321
+ } else if (kind === "refactor") {
3314
3322
  next = replaceUnsysCanvasSelection(live, selected, {
3315
3323
  text: input.payload.text,
3316
3324
  elements: input.payload.elements,
3317
3325
  turnId: input.payload.turnId,
3318
3326
  label: noteLabel
3319
3327
  });
3328
+ } else if (kind === "simplify") {
3329
+ const text = stripLearnerFacingWrappers(String(input.payload.text || "").trim());
3330
+ if (text) {
3331
+ next = fanUnsysCanvasLabeledNodes(live, selected, [text], "ileSimplify").scene;
3332
+ }
3320
3333
  } else if (kind === "concepts") {
3321
3334
  const labels = unsysCanvasConceptLabels(source, {
3322
3335
  text: input.payload.text,