@creator-notes/cnotes 0.107.15 → 0.109.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,6 +1,6 @@
1
1
  {
2
2
  "name": "creator-notes-cli",
3
- "version": "0.107.15",
3
+ "version": "0.109.0",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -19,6 +19,8 @@ import { CANVAS_GOAL_DESCRIPTION } from "../lib/canvas-goal.js";
19
19
  import { canvasActionPath, commentsListPath, parseCommentStatus, } from "../lib/canvas-paths.js";
20
20
  import { registerCanvasMilestoneCommands } from "./canvas-milestone.js";
21
21
  import { DISPLAY_ID_CORE } from "../lib/display-id.js";
22
+ import { resolveNoteBatchItems } from "../lib/note-batch.js";
23
+ import { describeUnresolvedMentions } from "../lib/mention-lint.js";
22
24
  /** A node handle the agent reads off `canvas read`: NOTE-12, SECTION-7, … */
23
25
  const NODE_DISPLAY_REF_RE = new RegExp(String.raw `^${DISPLAY_ID_CORE}$`);
24
26
  /**
@@ -1684,6 +1686,19 @@ Examples:
1684
1686
  $ echo '{"root":{"type":"stack","items":[...]}}' | cnotes canvas place <canvasId> --spec-stdin
1685
1687
  $ cnotes canvas place <canvasId> --spec ./layout.json --dry-run --json
1686
1688
 
1689
+ New notes in the same call: give the spec a "notes" array in the notes create
1690
+ shape ({key, type, markdown|markdownFile, tags?}) and place each one with a note
1691
+ leaf {"kind":"item","type":"note","noteId":"@<key>"}. Bodies cross-link with
1692
+ [@<key>: Title](relationship:<verb>); edges and anchors say "@<key>". The notes
1693
+ are created only if the layout solves, need an open run (operations begin), and
1694
+ come back under "notes" in the notes create response shape. A dry run creates
1695
+ nothing.
1696
+ {"notes":[{"key":"A","type":"Insight","markdown":"# Reviews wait on one person"}],
1697
+ "root":{"kind":"stack","axis":"horizontal","items":[
1698
+ {"kind":"item","type":"note","noteId":"@A"},
1699
+ {"kind":"item","type":"note","noteId":"DECISION-12"}]},
1700
+ "edges":[{"from":"@A","to":"DECISION-12","label":"grounds"}]}
1701
+
1687
1702
  Sections: a section container in the spec ({"kind":"section","name":…,"child":…})
1688
1703
  creates an ARRANGED section. It keeps its cards laid out as they are added, edited
1689
1704
  or removed, until someone moves a card by hand. Put more cards in it later with
@@ -1738,12 +1753,44 @@ Placement (relative to nodes already on the canvas):
1738
1753
  doc.placement = opts.placement;
1739
1754
  }
1740
1755
  warnLayoutListMisuse(doc);
1756
+ // New notes ride in the spec's own `notes` array (the `notes create`
1757
+ // batch shape), checked here exactly as `notes create` checks them,
1758
+ // and go to the server beside the layout document.
1759
+ let notes;
1760
+ if (doc && typeof doc === "object" && !Array.isArray(doc) && "notes" in doc) {
1761
+ const { notes: rawNotes, ...layout } = doc;
1762
+ if (!Array.isArray(rawNotes) || rawNotes.length === 0) {
1763
+ throw new ValidationError('"notes" must be a non-empty array of {key, type, markdown|markdownFile}');
1764
+ }
1765
+ notes = resolveNoteBatchItems(rawNotes);
1766
+ doc = layout;
1767
+ }
1741
1768
  const data = await api.post(canvasActionPath(canvasId, cfg.workspaceId), {
1742
1769
  action: "placeLayout",
1743
1770
  doc,
1771
+ ...(notes ? { notes } : {}),
1744
1772
  ...(opts.into ? { intoSection: opts.into } : {}),
1745
1773
  ...(opts.dryRun ? { dryRun: true } : {}),
1746
1774
  });
1775
+ // The notes exist once the call returns, even when placing failed:
1776
+ // never re-run a spec with notes to retry, it duplicates them.
1777
+ const createdNotes = data.notes;
1778
+ const createdRows = (createdNotes?.results || []);
1779
+ if (createdNotes) {
1780
+ for (const row of createdRows) {
1781
+ reportHeadlineWarnings(readHeadlineWarnings(row), typeof row.displayId === "string" ? row.displayId : undefined);
1782
+ if (typeof row.hint === "string" && row.hint.trim())
1783
+ console.error(`Hint: ${row.hint.trim()}`);
1784
+ }
1785
+ const unresolved = describeUnresolvedMentions(createdNotes.unresolvedMentions);
1786
+ if (unresolved) {
1787
+ console.error(`\n⚠ Some relationship mentions did not resolve. The ${createdRows.length} note(s) ` +
1788
+ `were CREATED but carry broken links:\n${unresolved}\n` +
1789
+ `Fix forward: cnotes versions create <id> --markdown-file <fixed.md>. ` +
1790
+ `Do NOT re-run place — it would duplicate the notes.`);
1791
+ process.exitCode = EXIT_CODES.VALIDATION;
1792
+ }
1793
+ }
1747
1794
  // No canvas was mutated on a dry run, so don't surface a "here's what I
1748
1795
  // built" link for it.
1749
1796
  const link = opts.dryRun
@@ -1786,6 +1833,10 @@ Placement (relative to nodes already on the canvas):
1786
1833
  }
1787
1834
  return;
1788
1835
  }
1836
+ if (createdRows.length > 0) {
1837
+ console.log(`Created ${createdRows.length} note${createdRows.length === 1 ? "" : "s"}: ` +
1838
+ createdRows.map((r) => `${r.key} → ${r.displayId}`).join(", "));
1839
+ }
1789
1840
  const placed = items.filter((r) => r.id && !r.error).length;
1790
1841
  const failed = items.filter((r) => !r.id || r.error).length;
1791
1842
  const edgesAdded = edges.filter((e) => e.id && !e.error).length;
@@ -1,13 +1,14 @@
1
1
  import { ApiClient } from "../lib/api-client.js";
2
2
  import { resolveConfig } from "../lib/config.js";
3
3
  import { handleError, NotFoundError, ValidationError, EXIT_CODES } from "../lib/errors.js";
4
- import { parseJsonOption, readFileSafe } from "../lib/fs-utils.js";
4
+ import { parseJsonOption } from "../lib/fs-utils.js";
5
5
  import { outputJson, outputTable, outputQuiet, timeAgo, truncate } from "../lib/output.js";
6
6
  import { readHeadlineWarnings, reportHeadlineWarnings } from "../lib/headline-warnings.js";
7
7
  import { resolveNoteId } from "../lib/resolve-note.js";
8
- import { formatSupersededBy, readSupersededBy } from "../lib/superseded-by.js";
8
+ import { formatNoteDimensionLines, parseDimensionFilter, readNoteDimensions } from "../lib/note-dimensions.js";
9
9
  import { formatLinkedItemHeading, groupLinkedByRelation, parseExpandArgs, projectExpandPayload, renderExpandContentOnly, } from "../lib/expand-notes.js";
10
- import { lintMentionMarkdown, describeUnresolvedMentions, lintNarratedVerbMentions, lintPlainTextDisplayIdsBatch, hasGenericMention, fetchRelationshipTypeOptions, } from "../lib/mention-lint.js";
10
+ import { resolveNoteBatchItems } from "../lib/note-batch.js";
11
+ import { describeUnresolvedMentions, lintNarratedVerbMentions, lintPlainTextDisplayIdsBatch, hasGenericMention, fetchRelationshipTypeOptions, } from "../lib/mention-lint.js";
11
12
  import { attachRubricsToResults, loadRubricMap, rubricsForTypes, } from "../lib/rubrics.js";
12
13
  import { DECISION_CARD_RULE, } from "../lib/decision-citation.js";
13
14
  export function registerNotesCommands(program) {
@@ -24,12 +25,22 @@ export function registerNotesCommands(program) {
24
25
  .option("--pinned", "Only show pinned notes")
25
26
  .option("--no-canvas", "Only notes that are on no canvas at all, at most 500 per list (combines with --type, --tags, --limit)")
26
27
  .option("--limit <n>", "Maximum number of results", "20")
28
+ .option("--dimension <key=state>", "Notes of --type by a dimension's reading, e.g. answered=open")
29
+ .option("--open", "Questions no live answer link answers yet (same as --type Question --dimension answered=open)")
30
+ .option("--answered", "Questions a live answer link answers (same as --type Question --dimension answered=answered)")
31
+ .option("--needs-me", "Open Questions whose \"Whose call\" heading names you (implies --type Question)")
27
32
  .addHelpText("after", `
28
33
  Examples:
29
34
  $ cnotes notes list --type Insight --limit 5
30
35
  $ cnotes notes list --search "auth flow" --json
31
36
  $ cnotes notes list --fields displayId,title,type --json
32
37
  $ cnotes notes list --no-canvas --type Decision --limit 50 # never made it onto a canvas
38
+ $ cnotes notes list --needs-me # Questions still waiting on you
39
+
40
+ Dimensions are readings from live links, declared per type: a Question is
41
+ answered when a link joins it to its answer ([QUESTION-12: Title](relationship:answers)
42
+ on that note, or answered-by on the Question). Write that link whenever a note
43
+ settles a Question. \`notes get\` prints each dimension under the title.
33
44
  `)
34
45
  .action(async (opts) => {
35
46
  const cfg = resolveConfig(program.opts());
@@ -40,13 +51,44 @@ Examples:
40
51
  if (notOnCanvas && (opts.search || opts.pinned)) {
41
52
  throw new ValidationError("--no-canvas combines with --type, --tags and --limit, not --search or --pinned.");
42
53
  }
54
+ const shortcuts = [opts.open, opts.answered, opts.needsMe].filter(Boolean).length;
55
+ if (opts.open && opts.answered) {
56
+ throw new ValidationError("Pass --open or --answered, not both.");
57
+ }
58
+ if (opts.answered && opts.needsMe) {
59
+ throw new ValidationError("--needs-me lists open Questions; it does not combine with --answered.");
60
+ }
61
+ if (shortcuts > 0 && opts.dimension) {
62
+ throw new ValidationError("--open, --answered and --needs-me are shortcuts for --dimension; pass one or the other.");
63
+ }
64
+ if (shortcuts > 0 && opts.type && opts.type !== "Question") {
65
+ throw new ValidationError("--open, --answered and --needs-me list Questions only; drop --type or pass --type Question.");
66
+ }
67
+ let dimension;
68
+ if (opts.dimension) {
69
+ const [key, state] = parseDimensionFilter(String(opts.dimension));
70
+ if (!key || !state)
71
+ throw new ValidationError("--dimension takes key=state, e.g. --dimension answered=open.");
72
+ if (!opts.type)
73
+ throw new ValidationError("--dimension filters one type; pass --type too.");
74
+ dimension = [key, state];
75
+ }
76
+ else if (opts.open || opts.needsMe) {
77
+ dimension = ["answered", "open"];
78
+ }
79
+ else if (opts.answered) {
80
+ dimension = ["answered", "answered"];
81
+ }
43
82
  const params = {
44
83
  workspaceId: cfg.workspaceId,
45
84
  notOnCanvas: notOnCanvas ? "true" : undefined,
46
85
  // The server applies the limit for this scan, so ask for what will show.
47
86
  limit: notOnCanvas ? String(parseInt(opts.limit, 10) || 20) : undefined,
48
87
  search: opts.search,
49
- types: opts.type,
88
+ types: shortcuts > 0 ? "Question" : opts.type,
89
+ dimension: dimension?.[0],
90
+ state: dimension?.[1],
91
+ waitsOnMe: opts.needsMe ? "true" : undefined,
50
92
  tags: opts.tags,
51
93
  onlyPinned: opts.pinned ? "true" : undefined,
52
94
  excludeDrafts: "true",
@@ -64,6 +106,12 @@ Examples:
64
106
  else if (truncated === "scan") {
65
107
  console.error("Stopped early: more notes on no canvas may exist. Narrow the list with --type or --tags to see them.");
66
108
  }
109
+ else if (truncated === "dimension-limit") {
110
+ console.error("Checked 500 notes, the most one list reads; others of this type were not checked. Narrow it with --tags to see the rest.");
111
+ }
112
+ else if (truncated === "dimension-links") {
113
+ console.error("Some notes have more links than one read covers, so a match may be missing. Check a note with `cnotes notes get`.");
114
+ }
67
115
  // The server caps results (and ignores `limit` when a search/type
68
116
  // filter is active), so apply the requested limit here. This also
69
117
  // fixes the JSON path, which previously emitted the entire result
@@ -576,96 +624,7 @@ Output (--json):
576
624
  if (items.length === 0) {
577
625
  throw new ValidationError("--notes must contain at least one item (object or non-empty array)");
578
626
  }
579
- const localErrors = [];
580
- const notes = [];
581
- items.forEach((raw, index) => {
582
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
583
- localErrors.push({ index, field: "item", message: "Item must be a JSON object" });
584
- return;
585
- }
586
- const obj = raw;
587
- const key = typeof obj.key === "string" ? obj.key.trim() : "";
588
- const type = typeof obj.type === "string" ? obj.type.trim() : "";
589
- const markdownInline = typeof obj.markdown === "string" ? obj.markdown : undefined;
590
- const markdownFile = typeof obj.markdownFile === "string" ? obj.markdownFile : undefined;
591
- if (!key) {
592
- localErrors.push({ index, field: "key", message: "key is required (non-empty string used to cross-reference items in this batch)" });
593
- }
594
- if (!type) {
595
- localErrors.push({ index, key: key || undefined, field: "type", message: "type is required (e.g. \"Insight\", \"Meeting\")" });
596
- }
597
- let markdown = markdownInline;
598
- if (!markdown && markdownFile) {
599
- try {
600
- markdown = readFileSafe(markdownFile);
601
- }
602
- catch (e) {
603
- const reason = e instanceof Error ? e.message : "could not read file";
604
- localErrors.push({ index, key: key || undefined, field: "markdownFile", message: reason });
605
- }
606
- }
607
- if (!markdown) {
608
- localErrors.push({ index, key: key || undefined, field: "markdown", message: "markdown or markdownFile is required" });
609
- }
610
- let tags;
611
- if (obj.tags !== undefined && obj.tags !== null) {
612
- if (!Array.isArray(obj.tags) || !obj.tags.every((t) => typeof t === "string")) {
613
- localErrors.push({ index, key: key || undefined, field: "tags", message: "tags must be an array of strings" });
614
- }
615
- else {
616
- tags = obj.tags;
617
- }
618
- }
619
- let changeDescription;
620
- if (obj.changeDescription !== undefined && obj.changeDescription !== null) {
621
- if (typeof obj.changeDescription !== "string") {
622
- localErrors.push({
623
- index,
624
- key: key || undefined,
625
- field: "changeDescription",
626
- message: "changeDescription must be a string",
627
- });
628
- }
629
- else {
630
- const trimmed = obj.changeDescription.trim();
631
- if (trimmed)
632
- changeDescription = trimmed;
633
- }
634
- }
635
- if (markdown) {
636
- // Pre-send mention lint: catch malformed relationship mentions
637
- // (verb-as-link-text, prose-as-target) BEFORE anything is created,
638
- // so the fix is free — nothing to undo, safe to re-run. @key is
639
- // allowed here because batch placeholders resolve server-side.
640
- for (const issue of lintMentionMarkdown(markdown, true)) {
641
- localErrors.push({
642
- index,
643
- key: key || undefined,
644
- field: "markdown",
645
- message: `bad relationship mention ${issue.raw}: ${issue.message}`,
646
- });
647
- }
648
- }
649
- if (key && type && markdown) {
650
- notes.push({
651
- key,
652
- type,
653
- markdown,
654
- tags,
655
- ...(changeDescription ? { changeDescription } : {}),
656
- });
657
- }
658
- });
659
- if (localErrors.length > 0) {
660
- const summary = `${localErrors.length} of ${items.length} item${items.length === 1 ? "" : "s"} invalid`;
661
- const lines = localErrors.map((e) => ` - item ${e.index} (${e.key ?? "?"}): ${e.field}: ${e.message}`);
662
- // Attach the structured per-item errors as `details` in the same
663
- // `{ items: [...] }` shape the server's batch-error contract uses,
664
- // so --json callers can branch on index/key/field without parsing prose.
665
- throw new ValidationError(`${summary}\n${lines.join("\n")}`, undefined, {
666
- items: localErrors,
667
- });
668
- }
627
+ const notes = resolveNoteBatchItems(items);
669
628
  // Narrated-verb lint (warn-only, computed pre-send): prose like
670
629
  // "Blocks [[CLAIM-6G2]]" files a plain `references` edge the graph
671
630
  // can't distinguish from a citation. Never blocks the write — types
@@ -1188,9 +1147,11 @@ function printNote(note, version) {
1188
1147
  const archivedAt = note.archivedAt;
1189
1148
  console.log(`Archived: ${archivedAt ? timeAgo(archivedAt) : "yes"}`);
1190
1149
  }
1191
- const supersededBy = readSupersededBy(note);
1192
- if (supersededBy) {
1193
- console.log(`Superseded by: ${formatSupersededBy(supersededBy)}`);
1150
+ // What the note is linked to under its type's declared dimensions
1151
+ // ("Answered by", "Superseded by"), and who it waits on.
1152
+ const dimensions = readNoteDimensions(note);
1153
+ for (const line of dimensions ? formatNoteDimensionLines(dimensions) : []) {
1154
+ console.log(line);
1194
1155
  }
1195
1156
  if (note.updatedAt) {
1196
1157
  console.log(`Updated: ${timeAgo(note.updatedAt)}`);
@@ -3,6 +3,7 @@ import { resolveConfig } from "../lib/config.js";
3
3
  import { handleError, NotFoundError, ValidationError } from "../lib/errors.js";
4
4
  import { outputJson, outputTable, outputQuiet } from "../lib/output.js";
5
5
  import { typeEditInDraft } from "../lib/draft-view.js";
6
+ import { formatDimensionSpec, formatBackfillOffer } from "../lib/type-dimensions.js";
6
7
  export function registerTypesCommands(program) {
7
8
  const types = program
8
9
  .command("types")
@@ -86,6 +87,12 @@ Examples:
86
87
  else {
87
88
  console.log("\nNo rubric defined for this type.");
88
89
  }
90
+ const dims = Array.isArray(match.judgedDimensions) ? match.judgedDimensions : [];
91
+ if (dims.length > 0) {
92
+ console.log("\nJudged dimensions (asked of every note of this type on each save):");
93
+ for (const d of dims)
94
+ console.log(formatDimensionSpec(d));
95
+ }
89
96
  }
90
97
  catch (error) {
91
98
  handleError(error, cfg.json);
@@ -190,4 +197,123 @@ Examples:
190
197
  handleError(error, cfg.json);
191
198
  }
192
199
  });
200
+ const dimension = types
201
+ .command("dimension")
202
+ .description("Judged dimensions: a named question a decision model answers about every note of a type, " +
203
+ "on create and on each new version. Filter by one with `cnotes notes list --type <Type> --dimension key=state`.");
204
+ dimension
205
+ .command("add")
206
+ .description("Add a judged dimension to a type, or change the one with the same key. Workspace admin or owner only")
207
+ .argument("<type>", "Type name (e.g. Decision)")
208
+ .requiredOption("--key <key>", "Stable key, lowercase with underscores (e.g. revenue_risk)")
209
+ .requiredOption("--prompt <text>", "The question, written as a statement or question about one note")
210
+ .requiredOption("--kind <kind>", "boolean (yes / no / unsure), category (one of --options) or percentage (0% to 100%)")
211
+ .option("--label <label>", "What people read (defaults from the key)")
212
+ .option("--options <list>", "Comma-separated options for a category dimension (2 to 8)")
213
+ .option("--backfill <when>", "all: also judge every existing note of the type now (one model call each). forward: only new and edited notes. Ask the person before passing all.")
214
+ .addHelpText("after", `
215
+ Examples:
216
+ $ cnotes types dimension add Decision --key revenue_risk --kind boolean \\
217
+ --prompt "This decision puts current revenue at risk if it turns out wrong."
218
+ $ cnotes types dimension add Opportunity --key stage --kind category \\
219
+ --options discovery,shaping,delivery --prompt "Which stage is this opportunity at?"
220
+ $ cnotes types dimension add Slice --key readiness --kind percentage \\
221
+ --prompt "How ready is this slice to build, from 0% to 100%?" --backfill forward
222
+
223
+ Without --backfill nothing existing is judged: the output says how many notes
224
+ have no answer and about what judging them costs. Changing the prompt, kind or
225
+ options makes earlier answers stop counting until each note is judged again.
226
+ `)
227
+ .action(async (type, opts) => {
228
+ const cfg = resolveConfig(program.opts());
229
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
230
+ try {
231
+ const inDraft = typeEditInDraft(cfg.proposal);
232
+ if (inDraft)
233
+ throw inDraft;
234
+ if (opts.backfill && opts.backfill !== "all" && opts.backfill !== "forward") {
235
+ throw new ValidationError("--backfill takes all or forward.");
236
+ }
237
+ const data = await api.post("/api/supertags/dimensions", {
238
+ workspaceId: cfg.workspaceId,
239
+ typeName: type,
240
+ key: opts.key,
241
+ label: opts.label,
242
+ prompt: opts.prompt,
243
+ kind: opts.kind,
244
+ options: opts.options ? String(opts.options).split(",").map((o) => o.trim()).filter(Boolean) : undefined,
245
+ backfill: opts.backfill,
246
+ });
247
+ if (cfg.json) {
248
+ outputJson(data);
249
+ return;
250
+ }
251
+ const dim = data.dimension;
252
+ console.log(`${data.changed ? "Saved" : "Relabelled"} dimension on ${data.typeName}:`);
253
+ console.log(formatDimensionSpec(dim));
254
+ for (const line of formatBackfillOffer(data, String(data.typeName), dim.key))
255
+ console.log(line);
256
+ }
257
+ catch (error) {
258
+ handleError(error, cfg.json);
259
+ }
260
+ });
261
+ dimension
262
+ .command("remove")
263
+ .description("Remove a judged dimension from a type and delete its answers. Workspace admin or owner only")
264
+ .argument("<type>", "Type name")
265
+ .argument("<key>", "Dimension key")
266
+ .action(async (type, key) => {
267
+ const cfg = resolveConfig(program.opts());
268
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
269
+ try {
270
+ const query = new URLSearchParams({ workspaceId: String(cfg.workspaceId), typeName: type, key });
271
+ const data = await api.delete(`/api/supertags/dimensions?${query}`);
272
+ if (cfg.json)
273
+ outputJson(data);
274
+ else
275
+ console.log(`Removed dimension ${key} from ${type}.`);
276
+ }
277
+ catch (error) {
278
+ handleError(error, cfg.json);
279
+ }
280
+ });
281
+ dimension
282
+ .command("backfill")
283
+ .description("Judge a type's existing notes on one dimension. Without --yes it only reports the count and the cost")
284
+ .argument("<type>", "Type name")
285
+ .argument("<key>", "Dimension key")
286
+ .option("--yes", "Start judging (one model call per note). Ask the person first")
287
+ .action(async (type, key, opts) => {
288
+ const cfg = resolveConfig(program.opts());
289
+ const api = new ApiClient(cfg.serverUrl, cfg.token, cfg.workspaceId);
290
+ try {
291
+ if (!opts.yes) {
292
+ const estimate = await api.get("/api/supertags/dimensions/backfill", {
293
+ workspaceId: cfg.workspaceId,
294
+ typeName: type,
295
+ key,
296
+ });
297
+ if (cfg.json) {
298
+ outputJson(estimate);
299
+ return;
300
+ }
301
+ for (const line of formatBackfillOffer(estimate, type, key))
302
+ console.log(line);
303
+ return;
304
+ }
305
+ const data = await api.post("/api/supertags/dimensions/backfill", {
306
+ workspaceId: cfg.workspaceId,
307
+ typeName: type,
308
+ key,
309
+ });
310
+ if (cfg.json)
311
+ outputJson(data);
312
+ else
313
+ console.log(`Judging ${data.unjudged} ${type} notes on ${key} in the background.`);
314
+ }
315
+ catch (error) {
316
+ handleError(error, cfg.json);
317
+ }
318
+ });
193
319
  }
@@ -6,4 +6,4 @@
6
6
  * hint (convex/lib/decisionCitation.ts); this sentence is the rule those
7
7
  * surfaces quote. Keep the skill's copy in step with it.
8
8
  */
9
- export const DECISION_CARD_RULE = "Anything settled in conversation that shapes what we build or say publicly gets its own Decision card, citing the cards it depends on (typed links such as depends-on / grounded-in). If something is stated as decided but no Decision card exists, say so and create one.";
9
+ export const DECISION_CARD_RULE = "Anything settled in conversation that shapes what we build or say publicly gets its own Decision card, citing the cards it depends on (typed links such as depends-on / grounded-in). If something is stated as decided but no Decision card exists, say so and create one. When a card settles a Question, link the Question with answers, [QUESTION-12: Title](relationship:answers), so the Question reads answered.";
@@ -0,0 +1,106 @@
1
+ import { ValidationError } from "./errors.js";
2
+ import { readFileSafe } from "./fs-utils.js";
3
+ import { lintMentionMarkdown } from "./mention-lint.js";
4
+ /**
5
+ * Resolve and check a batch of notes before anything is sent: `notes create
6
+ * --notes` and the `notes` array of a `canvas place` spec. Reads markdownFile
7
+ * into markdown and lints relationship mentions. Collects ALL errors so an
8
+ * agent can fix the whole batch in one shot rather than one item at a time,
9
+ * and throws them as one ValidationError with `details.items`.
10
+ *
11
+ * Mirror of validateBulkCreateItem in lib/api/note-batch.ts. Keep field shape
12
+ * and messages in sync with the route.
13
+ */
14
+ export function resolveNoteBatchItems(items) {
15
+ const localErrors = [];
16
+ const notes = [];
17
+ items.forEach((raw, index) => {
18
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
19
+ localErrors.push({ index, field: "item", message: "Item must be a JSON object" });
20
+ return;
21
+ }
22
+ const obj = raw;
23
+ const key = typeof obj.key === "string" ? obj.key.trim() : "";
24
+ const type = typeof obj.type === "string" ? obj.type.trim() : "";
25
+ const markdownInline = typeof obj.markdown === "string" ? obj.markdown : undefined;
26
+ const markdownFile = typeof obj.markdownFile === "string" ? obj.markdownFile : undefined;
27
+ if (!key) {
28
+ localErrors.push({ index, field: "key", message: "key is required (non-empty string used to cross-reference items in this batch)" });
29
+ }
30
+ if (!type) {
31
+ localErrors.push({ index, key: key || undefined, field: "type", message: "type is required (e.g. \"Insight\", \"Meeting\")" });
32
+ }
33
+ let markdown = markdownInline;
34
+ if (!markdown && markdownFile) {
35
+ try {
36
+ markdown = readFileSafe(markdownFile);
37
+ }
38
+ catch (e) {
39
+ const reason = e instanceof Error ? e.message : "could not read file";
40
+ localErrors.push({ index, key: key || undefined, field: "markdownFile", message: reason });
41
+ }
42
+ }
43
+ if (!markdown) {
44
+ localErrors.push({ index, key: key || undefined, field: "markdown", message: "markdown or markdownFile is required" });
45
+ }
46
+ let tags;
47
+ if (obj.tags !== undefined && obj.tags !== null) {
48
+ if (!Array.isArray(obj.tags) || !obj.tags.every((t) => typeof t === "string")) {
49
+ localErrors.push({ index, key: key || undefined, field: "tags", message: "tags must be an array of strings" });
50
+ }
51
+ else {
52
+ tags = obj.tags;
53
+ }
54
+ }
55
+ let changeDescription;
56
+ if (obj.changeDescription !== undefined && obj.changeDescription !== null) {
57
+ if (typeof obj.changeDescription !== "string") {
58
+ localErrors.push({
59
+ index,
60
+ key: key || undefined,
61
+ field: "changeDescription",
62
+ message: "changeDescription must be a string",
63
+ });
64
+ }
65
+ else {
66
+ const trimmed = obj.changeDescription.trim();
67
+ if (trimmed)
68
+ changeDescription = trimmed;
69
+ }
70
+ }
71
+ if (markdown) {
72
+ // Pre-send mention lint: catch malformed relationship mentions
73
+ // (verb-as-link-text, prose-as-target) BEFORE anything is created,
74
+ // so the fix is free — nothing to undo, safe to re-run. @key is
75
+ // allowed here because batch placeholders resolve server-side.
76
+ for (const issue of lintMentionMarkdown(markdown, true)) {
77
+ localErrors.push({
78
+ index,
79
+ key: key || undefined,
80
+ field: "markdown",
81
+ message: `bad relationship mention ${issue.raw}: ${issue.message}`,
82
+ });
83
+ }
84
+ }
85
+ if (key && type && markdown) {
86
+ notes.push({
87
+ key,
88
+ type,
89
+ markdown,
90
+ tags,
91
+ ...(changeDescription ? { changeDescription } : {}),
92
+ });
93
+ }
94
+ });
95
+ if (localErrors.length > 0) {
96
+ const summary = `${localErrors.length} of ${items.length} item${items.length === 1 ? "" : "s"} invalid`;
97
+ const lines = localErrors.map((e) => ` - item ${e.index} (${e.key ?? "?"}): ${e.field}: ${e.message}`);
98
+ // Attach the structured per-item errors as `details` in the same
99
+ // `{ items: [...] }` shape the server's batch-error contract uses,
100
+ // so --json callers can branch on index/key/field without parsing prose.
101
+ throw new ValidationError(`${summary}\n${lines.join("\n")}`, undefined, {
102
+ items: localErrors,
103
+ });
104
+ }
105
+ return notes;
106
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Note dimensions as GET /api/notes reports them on a read by id: what a note
3
+ * is linked to under the rules declared in convex/lib/noteDimensions.ts
4
+ * ("Answered by", "Superseded by"), and who a note waits on.
5
+ *
6
+ * The server sends only dimensions that say something, so nothing here
7
+ * invents a reading when a field is missing.
8
+ */
9
+ /** The fields off a raw note row, or undefined when there is nothing to read. */
10
+ export function readNoteDimensions(note) {
11
+ const dimensions = Array.isArray(note.dimensions)
12
+ ? note.dimensions
13
+ .filter((d) => !!d && typeof d === "object" && typeof d.key === "string")
14
+ .map((d) => ({
15
+ key: String(d.key),
16
+ label: typeof d.label === "string" ? d.label : String(d.key),
17
+ state: typeof d.state === "string" ? d.state : "",
18
+ ...(d.source === "judged" ? { source: "judged" } : {}),
19
+ ...(typeof d.kind === "string" ? { kind: d.kind } : {}),
20
+ ...(typeof d.value === "number" ? { value: d.value } : {}),
21
+ notes: Array.isArray(d.notes)
22
+ ? d.notes
23
+ .filter((r) => !!r && typeof r.displayId === "string")
24
+ .map((r) => ({ displayId: String(r.displayId), title: typeof r.title === "string" ? r.title : null }))
25
+ : [],
26
+ }))
27
+ : [];
28
+ const waitsOn = Array.isArray(note.waitsOn) ? note.waitsOn.filter((n) => typeof n === "string") : [];
29
+ if (dimensions.length === 0 && waitsOn.length === 0)
30
+ return undefined;
31
+ return { dimensions, waitsOn, waitsOnYou: note.waitsOnYou === true };
32
+ }
33
+ const refs = (notes) => notes.map((r) => (r.title ? `${r.displayId} (${r.title})` : r.displayId)).join(", ");
34
+ /**
35
+ * One value per dimension: the notes that fill a link dimension, or "none yet
36
+ * (open)"; a judged answer with the probability behind it ("yes (0.82)"), or a
37
+ * percentage as it is ("75%").
38
+ */
39
+ export function formatDimension(d) {
40
+ if (d.source === "judged") {
41
+ return d.kind !== "percentage" && typeof d.value === "number" ? `${d.state} (${d.value.toFixed(2)})` : d.state;
42
+ }
43
+ return d.notes.length > 0 ? refs(d.notes) : `none yet (${d.state})`;
44
+ }
45
+ /** "you", or the names a note waits on. */
46
+ export function formatWaitsOn(reading) {
47
+ if (reading.waitsOnYou)
48
+ return "you";
49
+ return reading.waitsOn.length > 0 ? reading.waitsOn.join(", ") : null;
50
+ }
51
+ /**
52
+ * The header lines for `notes get`:
53
+ * "Answered by: DECISION-9 (No-card trial)"
54
+ * "Answered by: none yet (open)"
55
+ * "Waits on: you"
56
+ * "Superseded by: DECISION-117 (Wedge pivots)"
57
+ */
58
+ export function formatNoteDimensionLines(reading) {
59
+ const lines = reading.dimensions.map((d) => `${d.label}: ${formatDimension(d)}`);
60
+ const waits = formatWaitsOn(reading);
61
+ if (waits)
62
+ lines.push(`Waits on: ${waits}`);
63
+ return lines;
64
+ }
65
+ /**
66
+ * `--dimension key=state` as [key, state], split on the FIRST "=" only: a
67
+ * percentage state is itself ">=50" or "<=25". Either part is "" when missing.
68
+ */
69
+ export function parseDimensionFilter(raw) {
70
+ const at = raw.indexOf("=");
71
+ if (at < 0)
72
+ return [raw.trim(), ""];
73
+ return [raw.slice(0, at).trim(), raw.slice(at + 1).trim()];
74
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Printing judged dimensions for `cnotes types show` and
3
+ * `cnotes types dimension add | backfill` (CANVAS-448).
4
+ */
5
+ /** " revenue_risk Revenue risk (boolean, v2) This decision puts…" */
6
+ export function formatDimensionSpec(d) {
7
+ const kind = d.kind === "category" && d.options?.length ? `category: ${d.options.join(" / ")}` : d.kind;
8
+ return ` ${d.key} ${d.label} (${kind}, v${d.version})\n ${d.prompt}`;
9
+ }
10
+ const usd = (n) => {
11
+ const x = typeof n === "number" ? n : 0;
12
+ return x < 0.01 ? "under $0.01" : `about $${x.toFixed(2)}`;
13
+ };
14
+ /**
15
+ * What adding a dimension or asking for a backfill leaves to decide: how many
16
+ * notes have no answer on the current wording, what judging them costs, and
17
+ * the command that does it. Nothing is judged until someone runs it.
18
+ */
19
+ export function formatBackfillOffer(data, type, key) {
20
+ const lines = [];
21
+ const unjudged = typeof data.unjudged === "number" ? data.unjudged : 0;
22
+ const capped = data.capped === true ? " (counted up to 2,000)" : "";
23
+ const backfill = data.backfill;
24
+ const judge = data.judge;
25
+ if (judge && judge.ok === false) {
26
+ lines.push(`Not judged here yet: ${judge.reason ?? "no decision model can run in this workspace."}`);
27
+ }
28
+ // The estimate carries the latest backfill's state; the add response carries whether one started.
29
+ if (backfill?.state === "running") {
30
+ lines.push(`Already judging existing ${type} notes in the background (${backfill.judged ?? 0} so far).`);
31
+ return lines;
32
+ }
33
+ if (backfill?.state === "stalled") {
34
+ lines.push(`The last backfill stopped after ${backfill.judged ?? 0} notes: ${backfill.reason ?? "no reason recorded."}`);
35
+ }
36
+ if (backfill?.scheduled) {
37
+ lines.push(`Judging ${backfill.notes ?? unjudged} existing ${type} notes in the background.`);
38
+ }
39
+ else if (unjudged === 0) {
40
+ lines.push(`Every existing ${type} note already has an answer on this wording.`);
41
+ }
42
+ else {
43
+ lines.push(`${unjudged} existing ${type} notes have no answer on this${capped}. New and edited notes are judged from now on.`, `To judge the existing ones too (${usd(data.estimatedCostUsd)}), ask the person, then run:`, ` cnotes types dimension backfill ${type} ${key} --yes`);
44
+ }
45
+ return lines;
46
+ }
@@ -610,7 +610,7 @@ server.tool("cnotes_canvas_bulk_add", "LOW-LEVEL: add items at raw x/y that YOU
610
610
  items: allItems,
611
611
  });
612
612
  }));
613
- server.tool("cnotes_canvas_place", "Place items on a canvas using a DECLARATIVE LAYOUT (no x/y math). The server measures every item, packs them with no overlaps, and inserts them in a single batch. PREFER THIS over cnotes_canvas_bulk_add whenever you can express the layout as stacks/grids/anchors — which is almost always. The agent should describe STRUCTURE (rows, columns, what's near what), not pixel coordinates.\n\nELEMENT CHOICE: default content to typed NOTES (the only versioned, searchable tier agents can read back); richtext = the Text element, card-sized framing only (a heading is just content '# Title', untinted), section = a named region frame, list = member notes behind a one-line frame, edges connect notes only.\n\nThe call is best-effort, NOT atomic: per-item failures are reported in the response (HTTP 207) but the items that succeeded stay on the canvas. Always inspect `items[].error` and `edges[].error` in the response.\n\nThe `doc` argument is a layout document:\n { root: <LayoutNode>, edges?: [{from, to, label?}], origin?: {x, y} }\n\n<LayoutNode> is one of:\n • { kind: 'stack', axis: 'vertical'|'horizontal', gap?: 'tight'|'medium'|'spacious'|<px>, align?: 'start'|'center'|'end', items: [<LayoutNode>...] }\n • { kind: 'grid', columns: <n>, gap?: ..., items: [<LayoutNode>...] }\n • { kind: 'anchor', to: '<displayId or canvas node id>', direction: 'right'|'left'|'above'|'below', gap?: ..., child: <LayoutNode> }\n • { kind: 'item', type: 'note'|'richtext'|'list'|'canvas'|'section', key?: '<name>', ...item-specific fields }\n\nLeaf item shapes (no x/y!):\n note: { kind:'item', type:'note', noteId:'NOTE-3', key?:'a' }\n richtext: { kind:'item', type:'richtext', content:'# Markdown OK', size?:'small'|'medium'|'large', colorHex?:'<role hex>' } // the Text element: card-sized framing only; a heading is just content '# Title' with no colorHex; colorHex is a ROLE tint (#3B82F6 evidence · #22C55E commitment · #EC4899 insight · #F59E0B warning · #EF4444 danger · #8B5CF6 people — anything else snaps to the nearest), default untinted; plain markdown, NO [NOTE-X](relationship:...) mention syntax (corrupts the card); knowledge worth keeping = a note\n list: { kind:'item', type:'list', description:'One-line frame — first paragraph becomes the title', noteIds?:['NOTE-1','NOTE-2'], viewMode?:'list'|'grid' } // description is REQUIRED and is a frame, never the content: N distinct things = N notes in noteIds\n canvas: { kind:'item', type:'canvas', linkedCanvasId:'<id>' }\n\nEdges reference endpoints by, in priority order: `@<key>` (any item with a `key` placed in the same call), the original noteId/displayId of a note placed in this call (e.g. 'NOTE-7'), or the displayId / convex id of a node already on the canvas.\n\nExample (a SWOT-like quadrant):\n {\n root: {\n kind:'stack', axis:'vertical', gap:'spacious',\n items:[\n { kind:'stack', axis:'horizontal', gap:'spacious', items:[\n { kind:'grid', columns:2, items:[\n { kind:'item', type:'note', noteId:'STR-1' },\n { kind:'item', type:'note', noteId:'STR-2' },\n ]},\n { kind:'grid', columns:2, items:[\n { kind:'item', type:'note', noteId:'WEAK-1' },\n ]},\n ]},\n { kind:'stack', axis:'horizontal', gap:'spacious', items:[ /* opportunities + threats */ ]},\n ],\n },\n }", {
613
+ server.tool("cnotes_canvas_place", "Place items on a canvas using a DECLARATIVE LAYOUT (no x/y math). The server measures every item, packs them with no overlaps, and inserts them in a single batch. PREFER THIS over cnotes_canvas_bulk_add whenever you can express the layout as stacks/grids/anchors — which is almost always. The agent should describe STRUCTURE (rows, columns, what's near what), not pixel coordinates.\n\nELEMENT CHOICE: default content to typed NOTES (the only versioned, searchable tier agents can read back); richtext = the Text element, card-sized framing only (a heading is just content '# Title', untinted), section = a named region frame, list = member notes behind a one-line frame, edges connect notes only.\n\nThe call is best-effort, NOT atomic: per-item failures are reported in the response (HTTP 207) but the items that succeeded stay on the canvas. Always inspect `items[].error` and `edges[].error` in the response.\n\nThe `doc` argument is a layout document:\n { root: <LayoutNode>, edges?: [{from, to, label?}], origin?: {x, y} }\n\n<LayoutNode> is one of:\n • { kind: 'stack', axis: 'vertical'|'horizontal', gap?: 'tight'|'medium'|'spacious'|<px>, align?: 'start'|'center'|'end', items: [<LayoutNode>...] }\n • { kind: 'grid', columns: <n>, gap?: ..., items: [<LayoutNode>...] }\n • { kind: 'anchor', to: '<displayId or canvas node id>', direction: 'right'|'left'|'above'|'below', gap?: ..., child: <LayoutNode> }\n • { kind: 'item', type: 'note'|'richtext'|'list'|'canvas'|'section', key?: '<name>', ...item-specific fields }\n\nLeaf item shapes (no x/y!):\n note: { kind:'item', type:'note', noteId:'NOTE-3', key?:'a' }\n richtext: { kind:'item', type:'richtext', content:'# Markdown OK', size?:'small'|'medium'|'large', colorHex?:'<role hex>' } // the Text element: card-sized framing only; a heading is just content '# Title' with no colorHex; colorHex is a ROLE tint (#3B82F6 evidence · #22C55E commitment · #EC4899 insight · #F59E0B warning · #EF4444 danger · #8B5CF6 people — anything else snaps to the nearest), default untinted; plain markdown, NO [NOTE-X](relationship:...) mention syntax (corrupts the card); knowledge worth keeping = a note\n list: { kind:'item', type:'list', description:'One-line frame — first paragraph becomes the title', noteIds?:['NOTE-1','NOTE-2'], viewMode?:'list'|'grid' } // description is REQUIRED and is a frame, never the content: N distinct things = N notes in noteIds\n canvas: { kind:'item', type:'canvas', linkedCanvasId:'<id>' }\n\nEdges reference endpoints by, in priority order: `@<key>` (any item with a `key` placed in the same call), the original noteId/displayId of a note placed in this call (e.g. 'NOTE-7'), or the displayId / convex id of a node already on the canvas.\n\nNEW NOTES IN THE SAME CALL: pass `notes` (the cnotes_notes_create item shape) and place each with a note leaf whose noteId is '@<key>'. Bodies cross-link with [@<key>: Title](relationship:<verb>); edges and anchors say '@<key>'. One call replaces notes_create then place, inside the same open operation. The notes are created only if the layout solves, and come back under `notes`.\n\nExample (a SWOT-like quadrant):\n {\n root: {\n kind:'stack', axis:'vertical', gap:'spacious',\n items:[\n { kind:'stack', axis:'horizontal', gap:'spacious', items:[\n { kind:'grid', columns:2, items:[\n { kind:'item', type:'note', noteId:'STR-1' },\n { kind:'item', type:'note', noteId:'STR-2' },\n ]},\n { kind:'grid', columns:2, items:[\n { kind:'item', type:'note', noteId:'WEAK-1' },\n ]},\n ]},\n { kind:'stack', axis:'horizontal', gap:'spacious', items:[ /* opportunities + threats */ ]},\n ],\n },\n }", {
614
614
  canvasId: z.string().describe("Canvas ID"),
615
615
  doc: z
616
616
  .object({
@@ -636,10 +636,22 @@ server.tool("cnotes_canvas_place", "Place items on a canvas using a DECLARATIVE
636
636
  .string()
637
637
  .optional()
638
638
  .describe("SECTION-<n> to put the items INTO: appended to its layout (end of its shortest column, or the next grid cell); the section re-arranges and resizes. A section container in the doc creates an ARRANGED section that keeps its cards laid out until a card is moved by hand; add to it later with intoSection, never by aiming origin inside the frame. The doc may not contain sections when intoSection is set."),
639
- }, async ({ canvasId, doc, intoSection }) => withErrorHandling(() => api.post(`/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`, {
639
+ notes: z
640
+ .array(z.object({
641
+ key: z.string(),
642
+ type: z.string(),
643
+ markdown: z.string(),
644
+ tags: z.array(z.string()).optional(),
645
+ changeDescription: z.string().optional(),
646
+ }))
647
+ .min(1)
648
+ .optional()
649
+ .describe("Notes to create and place in this call (cnotes_notes_create item shape); a note leaf places one with noteId '@<key>'"),
650
+ }, async ({ canvasId, doc, intoSection, notes }) => withErrorHandling(() => api.post(`/api/canvas/${encodeURIComponent(canvasId)}?workspaceId=${encodeURIComponent(workspaceId)}`, {
640
651
  action: "placeLayout",
641
652
  doc,
642
653
  ...(intoSection ? { intoSection } : {}),
654
+ ...(notes ? { notes } : {}),
643
655
  })));
644
656
  server.tool("cnotes_canvas_arrange", "Reflow EXISTING canvas nodes with the layout solver (no x/y math). Unlike cnotes_canvas_place (create-only), this MOVES nodes already on the canvas — mixed kinds welcome (note, canvas-link, richtext, list, legacy text). Prefer this over cnotes_canvas_bulk_move whenever you are reorganizing existing content into a grid/stack/section.\n\nLeaves in `doc` must be `{ kind:'item', type:'existing', nodeId:'<id or NOTE-n>', nodeType:'note'|'text'|'richtext'|'list'|'canvas' }`. Wrap them in a section container and pass `targetSectionId` (SECTION-<n>) to pack into that frame and auto-resize it in place — the SECTION-<n> id stays stable (never delete+re-add).\n\nConvenience shape for a section reflow:\n {\n targetSectionId: 'SECTION-90',\n autoResize: true,\n doc: {\n root: {\n kind: 'section', name: '<current name>', key: 'frame',\n child: {\n kind: 'grid', columns: 4, gap: 'medium',\n items: [\n { kind:'item', type:'existing', nodeId:'…', nodeType:'canvas' },\n { kind:'item', type:'existing', nodeId:'NOTE-3', nodeType:'note' }\n ]\n }\n }\n }\n }\n\nWhen targetSectionId is set and origin/placement are omitted, the server pins the layout to the frame's current origin (placement exact).", {
645
657
  canvasId: z.string().describe("Canvas ID"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.107.15",
3
+ "version": "0.109.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,13 +17,31 @@ metadata:
17
17
  4. **Write to the type's rubric.** Pick the type, run `cnotes types show <Type>`, and author to its rubric. Audience-facing prose (note bodies, banners, pre-reads) goes through [references/humanizer.md](references/humanizer.md) first; transcripts, quotes and other raw capture are stored verbatim.
18
18
  5. **Create notes in one batch.** `cnotes notes create --notes '[{"key":"A","type":"Insight","markdownFile":"./a.md"}, ...]'`. Each body starts with a `# h1` (the title). Cross-link inside the batch with `[@A: Title](relationship:<verb>)`. Detail: [references/notes.md](references/notes.md).
19
19
  6. **Grade what you wrote.** `cnotes quality <displayIds...> --fail-below 4`, then revise weak notes with `cnotes versions create <id> --description "<what changed>" --markdown-file <path>`.
20
- 7. **Lay out the canvas.** `cnotes canvas place <canvasId> --spec layout.json` packs items without overlap. Read [references/canvas-elements.md](references/canvas-elements.md) before choosing elements and [references/canvas-layout.md](references/canvas-layout.md) before writing the spec.
20
+ 7. **Lay out the canvas.** `cnotes canvas place <canvasId> --spec layout.json` packs items without overlap. A spec can carry the notes too (see the fast path below), which folds steps 5 and 7 into one call. Read [references/canvas-elements.md](references/canvas-elements.md) before choosing elements and [references/canvas-layout.md](references/canvas-layout.md) before writing the spec.
21
21
  8. **Read it back.** `cnotes canvas read <canvasId>`: every claim must appear in a note with a display ID, and the banner must make sense to someone who was not in the session.
22
22
  9. **Close the run.** `cnotes operations end`.
23
23
  10. **Link the result.** End your reply with the canvas link (see [Surfacing the canvas link](#surfacing-the-canvas-link)).
24
24
 
25
25
  Reads, and a single metadata change (`notes update`), need no run.
26
26
 
27
+ ## Fast path: a routine canvas change
28
+
29
+ Adding cards, filling or tidying a section, or linking two cards takes three steps. Each extra call costs the user a model round trip, so batch and run independent calls together.
30
+
31
+ 1. **Read and open the run at once** (two calls, in parallel): `cnotes canvas read <canvasId>` (or `cnotes canvas read-section SECTION-n` when the request names one), and `cnotes operations begin --prompt "<headline>" --json`. The begin response already carries `typeRubrics` and a brief, so skip `brief` and `types show`.
32
+ 2. **Create and place in one call.** Put the new notes in the spec's `notes` array (the `notes create` shape) and place each with `{"kind":"item","type":"note","noteId":"@<key>"}`; edges and anchors say `@<key>` too. Add `--into SECTION-n` to append to an existing frame. Each result comes back under `notes`, graded when the workspace grades: revise only notes below 4.
33
+ ```json
34
+ {"notes":[{"key":"A","type":"Insight","markdown":"# Reviews wait on one person\n..."},
35
+ {"key":"B","type":"Decision","markdown":"# Add a second reviewer\nRests on [@A: Reviews wait on one person](relationship:depends-on)."}],
36
+ "root":{"kind":"stack","axis":"horizontal","items":[
37
+ {"kind":"item","type":"note","noteId":"@A"},{"kind":"item","type":"note","noteId":"@B"}]},
38
+ "edges":[{"from":"@B","to":"@A","label":"depends on"}]}
39
+ ```
40
+ `cnotes canvas place <canvasId> --spec spec.json && cnotes operations end`
41
+ 3. **Link the canvas** from the `Link:` line.
42
+
43
+ Rearranging existing cards needs no new notes: `cnotes canvas agent-run wrap --canvas <canvasId> --prompt "<headline>" -- cnotes canvas arrange <canvasId> --section SECTION-n`. Open [references/canvas-layout.md](references/canvas-layout.md) only when the layout needs anchors, origins or several sections; the rules above and step 7 below cover the rest.
44
+
27
45
  ## Rules that hold on every task
28
46
 
29
47
  1. **The exit code is the verdict.** `0` is success. Never decide success from the body, and never re-run a write because a key looked empty: a second `notes create` duplicates the batch.
@@ -33,13 +51,13 @@ Reads, and a single metadata change (`notes update`), need no run.
33
51
  5. **Place declaratively, edit in place.** Use `canvas place` / `canvas arrange`, never hand-computed x/y. Add to a section with `place --into SECTION-n` (or `--section` on a single add); tidy one with `arrange --section SECTION-n`. Change a text card with `canvas update-text` and a frame with `canvas update-section`. Deleting and re-adding mints new ids and drops edges and `[[SECTION-n]]` mentions.
34
52
  6. **Content changes are versions.** `cnotes versions create` changes a note's body (the `# h1` is its title); fetch the current body first and edit that, since people edit between sessions. `notes update` changes metadata only (type, tags, pin, archive).
35
53
  7. **Inside a draft, propose and stop.** Shared notes change through `cnotes draft propose`; the hand-over is `cnotes draft ask`, then stop. Never merge or approve work you built. Detail: [references/drafts.md](references/drafts.md).
36
- 8. **Ask before spending something the user cannot get back:** `cnotes upgrade` uses the workspace's one-time trial, and `cnotes feedback submit` files a report in their name.
54
+ 8. **Ask before spending something the user cannot get back:** `cnotes upgrade` uses the workspace's one-time trial, `cnotes feedback submit` files a report in their name, and `cnotes types dimension backfill --yes` spends one model call per existing note.
37
55
  9. **Timeline headlines start with a past-tense verb and name the object** ("Shipped the public comic canvas", never "V1"). The server rejects milestone headlines that do not.
38
56
  10. **Canvas names use the interpunct** `·` as a separator, never a dash: "Path to Revenue · Funding strategy".
39
57
 
40
58
  ### Decisions
41
59
 
42
- Anything settled in conversation that shapes what we build or say publicly gets its own Decision card, citing the cards it depends on (typed links such as depends-on / grounded-in). If something is stated as decided but no Decision card exists, say so and create one.
60
+ Anything settled in conversation that shapes what we build or say publicly gets its own Decision card, citing the cards it depends on (typed links such as depends-on / grounded-in). If something is stated as decided but no Decision card exists, say so and create one. When a card settles a Question, link the Question with answers, [QUESTION-12: Title](relationship:answers), so the Question reads answered.
43
61
 
44
62
  Write the citation in the Decision's body, not only as a canvas edge: `[NOTE-12: Title](relationship:depends-on)` or `[[grounded-in::NOTE-12]]`. A `references` chip and an untyped `[[NOTE-12]]` do not cite a dependence. Read the rubric first with `cnotes types show Decision`.
45
63
 
@@ -104,7 +122,7 @@ After you create a canvas or finish changing one, end your reply with its link,
104
122
  | When you are | Open |
105
123
  |---|---|
106
124
  | Writing any prose a person will read | [references/humanizer.md](references/humanizer.md) |
107
- | Creating, reading or revising notes; types and rubrics; markdown rules | [references/notes.md](references/notes.md) |
125
+ | Creating, reading or revising notes; types, rubrics and dimensions; markdown rules | [references/notes.md](references/notes.md) |
108
126
  | Linking notes, reading backlinks, checking what an edit affects (`deps`) | [references/relationships.md](references/relationships.md) |
109
127
  | Deciding what goes on a canvas as a note, text card, list, frame, edge or portal; the banner; completion tests | [references/canvas-elements.md](references/canvas-elements.md) |
110
128
  | Placing or rearranging several items (`canvas place`, `arrange`) | [references/canvas-layout.md](references/canvas-layout.md) |
@@ -66,6 +66,8 @@ The schema is strict: an unknown or typo'd key anywhere in the doc (e.g. `gapp`,
66
66
 
67
67
  `richtext` IS the **text** element (the CLI's `add-text`) — the only free-form text leaf. A heading is a `richtext` leaf whose content is `"# Title"` with no `colorHex`. There is no `"type": "text"` leaf: the old heading node kind is retired and the layout engine rejects it.
68
68
 
69
+ **New notes in the same call.** A spec can carry a top-level `notes` array in the `notes create` shape (`{key, type, markdown|markdownFile, tags?, changeDescription?}`). A note leaf places one with `"noteId": "@<key>"` and takes `<key>` as its own key, so edges and anchors say `@<key>`; bodies cross-link with `[@<key>: Title](relationship:<verb>)`. The notes are checked before anything is written, created only if the layout solves, need an open run, and come back under `notes` in the `notes create` response shape. A dry run creates nothing. If placing then fails, the notes still exist: fix forward, never re-run the spec.
70
+
69
71
  Leaf enums (exact values): richtext `size` = `small` | `medium` | `large`, `colorHex` = a saturated hex (omit for no background); list `viewMode` = `list` | `grid`, list `size` = `sm` | `md` | `lg` | `xl`.
70
72
 
71
73
  A richtext `size` is not a hint — it IS the width the card paints: `small` 560px, `medium` 1120px, `large` 1680px, with the height following the content. `place` measures that box for you, which is the whole reason to prefer it over hand-picked coordinates: pitch a row of columns for `small` and then send `medium` items and every card runs 460px into its neighbour.
@@ -195,6 +195,49 @@ cnotes types update <name> [--display-name <name>] [--description <text>] [--col
195
195
  cnotes notes retype <displayId> --type <NewType>
196
196
  ```
197
197
 
198
+ ### Dimensions
199
+
200
+ A type can carry dimensions: readings every note of the type gets, shown by
201
+ `notes get` under the title and filterable with `notes list --dimension`.
202
+
203
+ - **Link dimensions** are built in and read from live links: a Question is
204
+ `answered` when a note links it with `answers` (or the Question links its
205
+ answer with `answered-by`); any note is `supersededBy` when a newer note says
206
+ `supersedes`. Write those links and the reading follows.
207
+ - **Judged dimensions** are questions you add to a type, beside its rubric. A
208
+ decision model answers each one about every note of the type on create and on
209
+ each new version. At most three per type; admin or owner only, like the rubric.
210
+
211
+ ```bash
212
+ # Add one: boolean (yes / no / unsure), category (one of --options), percentage (0% to 100%)
213
+ cnotes types dimension add Decision --key revenue_risk --kind boolean \
214
+ --prompt "This decision puts current revenue at risk if it turns out wrong."
215
+ cnotes types dimension add Opportunity --key stage --kind category \
216
+ --options discovery,shaping,delivery --prompt "Which stage is this opportunity at?"
217
+
218
+ # See a type's dimensions (also in `types show`)
219
+ cnotes types show Decision
220
+
221
+ # Filter by any dimension
222
+ cnotes notes list --type Decision --dimension revenue_risk=yes
223
+ cnotes notes list --type Slice --dimension readiness=">=50"
224
+ cnotes notes list --needs-me # open Questions whose "Whose call" names you
225
+
226
+ # Judge the existing notes too: first see the count and cost, then ask the person
227
+ cnotes types dimension backfill Decision revenue_risk # estimate only
228
+ cnotes types dimension backfill Decision revenue_risk --yes # one model call per note
229
+
230
+ cnotes types dimension remove Decision revenue_risk
231
+ ```
232
+
233
+ Write the prompt the way you would a rubric clause: one plain statement about
234
+ one note, checkable from the note's own text ("names the customer who asked",
235
+ not "is good"). Adding a dimension judges only new and edited notes. Before you
236
+ judge existing notes, tell the person how many and what it costs (the `add`
237
+ output says both) and let them choose all existing or only going forward.
238
+ Changing the prompt, kind or options makes earlier answers stop counting until
239
+ each note is judged again; a new label alone keeps them.
240
+
198
241
 
199
242
  ## Note IDs
200
243
  - Notes have **display IDs** like `MEETING-12`, `PRD-5`, `IDEA-3` — use these in commands.