@creator-notes/cnotes 0.125.6 → 0.126.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.
@@ -1,58 +1,21 @@
1
1
  /**
2
2
  * What `canvas update-section` and the MCP tool `cnotes_canvas_update_section`
3
- * send for a frame edit, decided in one place for both.
4
- *
5
- * A move and every other edit are different server actions. Only
6
- * `moveSectionWithContents` carries the cards inside the frame; x/y on
7
- * `updateSectionNode` relocate the empty rectangle and leave its cards where
8
- * they were (the server keeps that meaning for the browser's resize handles).
9
- * So x/y always go to the move action, alone and as a pair.
3
+ * send for a frame edit, decided in one place for both. The rule itself lives
4
+ * in lib/mcp-spec.ts (planSectionUpdate), where the remote connector in the app
5
+ * reads it too; this wrapper turns a refusal into the CLI's ValidationError.
10
6
  */
11
7
  import { ValidationError } from "./errors.js";
8
+ import { MCP_SECTION_WORDING, planSectionUpdate, } from "./mcp-spec.js";
9
+ export { MCP_SECTION_WORDING };
12
10
  export const CLI_SECTION_WORDING = {
13
11
  x: "--x",
14
12
  y: "--y",
15
13
  size: "--width/--height",
16
14
  label: "--name/--color",
17
15
  };
18
- export const MCP_SECTION_WORDING = {
19
- x: "x",
20
- y: "y",
21
- size: "width/height",
22
- label: "name/colorHex",
23
- };
24
16
  export function buildSectionUpdateRequest(input, wording) {
25
- const { sectionId, name, x, y, width, height, colorHex, ripple } = input;
26
- const isMove = x !== undefined || y !== undefined;
27
- const isResize = width !== undefined || height !== undefined;
28
- const isRelabel = name !== undefined || colorHex !== undefined;
29
- if (isMove && (isResize || isRelabel)) {
30
- const rest = [isResize ? wording.size : null, isRelabel ? wording.label : null]
31
- .filter(Boolean)
32
- .join(" and ");
33
- throw new ValidationError(`A move is its own call: send ${wording.x} and ${wording.y} on their own, then ${rest} in a second call.`, "Only the move takes the cards inside the frame with it.");
34
- }
35
- if (x !== undefined && y !== undefined) {
36
- return {
37
- kind: "move",
38
- body: { action: "moveSectionWithContents", nodeId: sectionId, positionX: x, positionY: y },
39
- };
40
- }
41
- if (isMove) {
42
- const got = x === undefined ? wording.y : wording.x;
43
- const missing = x === undefined ? wording.x : wording.y;
44
- throw new ValidationError(`A move needs both ${wording.x} and ${wording.y}: got ${got} only.`, `Read the frame's current position from the canvas status and pass it as ${missing} to keep that axis unchanged.`);
45
- }
46
- const body = { action: "updateSectionNode", nodeId: sectionId };
47
- if (name !== undefined)
48
- body.name = name;
49
- if (width !== undefined)
50
- body.width = width;
51
- if (height !== undefined)
52
- body.height = height;
53
- if (colorHex !== undefined)
54
- body.colorHex = colorHex;
55
- if (ripple === false)
56
- body.ripple = false;
57
- return { kind: "update", body };
17
+ const plan = planSectionUpdate(input, wording);
18
+ if (!plan.ok)
19
+ throw new ValidationError(plan.message, plan.hint);
20
+ return plan.value;
58
21
  }
@@ -116,6 +116,18 @@ export function briefIsEmpty(brief) {
116
116
  brief.changes.length === 0 &&
117
117
  (brief.lessons?.preferred.length ?? 0) === 0);
118
118
  }
119
+ /**
120
+ * The one line every brief ends on. Agents chose a board shape by habit: the
121
+ * skill listed shapes and no step named the request, and two rounds of skill
122
+ * text changed nothing on boards. So the instruction is printed where the
123
+ * agent already reads, at the moment it applies.
124
+ */
125
+ export const BEFORE_WRITING = "Before you write: name the kind of request and find its row in the cnotes skill (references/situations.md). Most requests need no board.";
126
+ /**
127
+ * The line a run ends on. Nothing asked an agent what was worth keeping, so a
128
+ * correction or a decision made in passing was lost with the session.
129
+ */
130
+ export const BEFORE_STOPPING = "Before you stop: if you were corrected, a decision was made or a fact changed and no note holds it, write that one note now (cnotes skill, references/situations.md, When to write unasked).";
119
131
  /** Text form, shared by `operations begin` and `cnotes brief`. */
120
132
  export function renderBrief(brief, now = Date.now()) {
121
133
  const clip = (s, n) => (s.length > n ? s.slice(0, n - 3) + "..." : s);