@creator-notes/cnotes 0.84.0 → 0.85.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.
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Which sections a rubric requires, and whether a note's headings include them.
3
+ *
4
+ * Deterministic on purpose: no model, no credits. A rubric requires a section
5
+ * only when it says so, in either of these forms (the label is case-insensitive):
6
+ *
7
+ * Required sections: Problem; Options; Rationale
8
+ * Required sections:
9
+ * - Problem
10
+ * - Options
11
+ *
12
+ * Names are separated by semicolons so a name may contain commas. A period ends
13
+ * a name, so an explanation can follow the list on the same line. A rubric that
14
+ * never declares sections requires none: the check stays quiet instead of
15
+ * inventing headings from prose.
16
+ *
17
+ * Copied to cli/src/lib/rubric-sections.ts. Keep the two files byte-identical;
18
+ * __tests__/agent-grade.test.ts fails when they drift.
19
+ */
20
+ /** Section names a rubric declares, in declaration order, without duplicates. */
21
+ export function requiredSections(rubric) {
22
+ const names = [];
23
+ const seen = new Set();
24
+ const add = (raw) => {
25
+ const name = raw.split(".")[0]?.trim().replace(/^#+\s*/, "").trim() ?? "";
26
+ if (!name)
27
+ return;
28
+ const key = name.toLowerCase();
29
+ if (seen.has(key))
30
+ return;
31
+ seen.add(key);
32
+ names.push(name);
33
+ };
34
+ const lines = rubric.split(/\r?\n/);
35
+ for (let i = 0; i < lines.length; i++) {
36
+ const match = lines[i].match(/required sections\s*:\s*(.*)$/i);
37
+ if (!match)
38
+ continue;
39
+ const rest = match[1].trim();
40
+ if (rest) {
41
+ for (const part of rest.split(/\s*;\s*/))
42
+ add(part);
43
+ continue;
44
+ }
45
+ for (let j = i + 1; j < lines.length; j++) {
46
+ const bullet = lines[j].match(/^\s*[-*]\s+(.+)$/);
47
+ if (!bullet)
48
+ break;
49
+ add(bullet[1]);
50
+ i = j;
51
+ }
52
+ }
53
+ return names;
54
+ }
55
+ /** ATX heading texts (`#` through `######`), in order. */
56
+ export function headingTexts(markdown) {
57
+ const out = [];
58
+ for (const match of markdown.matchAll(/^#{1,6}[ \t]+(.+?)[ \t]*$/gm)) {
59
+ out.push(match[1].trim());
60
+ }
61
+ return out;
62
+ }
63
+ function norm(value) {
64
+ return value.trim().toLowerCase().replace(/\s+/g, " ").replace(/[.:]+$/, "");
65
+ }
66
+ /**
67
+ * Declared section names that do not appear as a heading in `markdown`.
68
+ * Comparison is case-insensitive. An undeclared rubric returns an empty list.
69
+ */
70
+ export function missingRequiredSections(markdown, rubric) {
71
+ const required = requiredSections(rubric);
72
+ if (required.length === 0)
73
+ return [];
74
+ const headings = new Set(headingTexts(markdown).map(norm));
75
+ return required.filter((name) => !headings.has(norm(name)));
76
+ }
77
+ //# sourceMappingURL=rubric-sections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rubric-sections.js","sourceRoot":"","sources":["../../src/lib/rubric-sections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,EAAE;QAC1B,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAC1E,IAAI,CAAC,IAAI;YAAE,OAAO;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO;QAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,KAAK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AAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAgB,EAAE,MAAc;IACtE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.84.0",
3
+ "version": "0.85.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -251,13 +251,23 @@ cnotes notes create --notes '[
251
251
  # (and `details.items` in --json mode), so you can fix the whole batch in one shot.
252
252
  # Each .results[] item carries .type + .rubric — keep them when filtering JSON.
253
253
 
254
- # THEN: grade what you just wrote and revise before ending the run. Same grader
255
- # and 1-4 ladder as the web "Check quality" (1 credit per graded note); the
256
- # create response's .selfCheck is this exact command for the new notes.
257
- cnotes quality INSIGHT-12 PAINPOINT-4 --fail-below 4 # exit 3 + next move per weak note
258
- cnotes quality --canvas CANVAS-60 # every note on a canvas
259
- cnotes quality --all --limit 200 --no-grade # free structural sweep
260
- # Structural codes: missing_title, empty_body, bare_id, unknown_type, no_rubric, superseded.
254
+ # THEN: grade what you just wrote and revise before ending the run.
255
+ # You are the grader. Grading spends no credits. `cnotes quality` does not
256
+ # call a server model. It returns a gradeRequest on each ungraded note:
257
+ # task "grade_against_rubric", the type rubric, the note content, and the
258
+ # instruction "Grade this against the rubric". The create response's
259
+ # .selfCheck is this command. Read .items[].gradeRequest (it also sits on
260
+ # .gradeRequests). Do not drop it when you keep only the display id.
261
+ cnotes quality INSIGHT-12 PAINPOINT-4 --fail-below 4 --json
262
+ # Exit 3 until you record a grade. Then:
263
+ cnotes quality record INSIGHT-12 --graded-version 4 --level 3 --criteria '[{"criterion":"Evidence","reason":"Grounded in two tickets."}]' --feedback "The pattern is named." --next-step "Say what would falsify it."
264
+ cnotes quality --canvas CANVAS-60 --json
265
+ cnotes quality --all --limit 200 --no-grade
266
+ # Structural codes (free, no credits): missing_title, empty_body, bare_id,
267
+ # unknown_type, no_rubric, superseded, missing_section.
268
+ # missing_section fires only for headings named in a rubric line
269
+ # "Required sections: Problem; Options". A rubric without that line
270
+ # requires no headings.
261
271
 
262
272
  # Update metadata only (not content — use versions for that)
263
273
  # NOTE: --title is NOT available. Title is read-only, derived from the # h1 heading in version content.
@@ -1069,7 +1079,7 @@ For any canvas you only *added to* (you already hold its id, so you didn't re-`g
1069
1079
 
1070
1080
  ### Note Types
1071
1081
  - The `--type` parameter must reference an **existing supertag** in the workspace. Free-text type strings are rejected.
1072
- - **Pick the type, then read its rubric, then write to it — in that order.** Each type carries a `validationPrompt` (its quality rubric: what a good instance contains). Once you know the type, run `cnotes types show <Type>` (or read `typeRubrics` from `cnotes operations begin --json` / `validationPrompt` from `cnotes types list --json`) and author to that rubric so the note lands well-formed instead of getting nudged after save. Example: a Decision needs the alternatives weighed, the rationale, and a revisit trigger, and it cites the cards it depends on (see [Decisions](#decisions)). `cnotes notes create --json` also puts the rubric on **each** `.results[]` item (`type` + `rubric`) and as a top-level `rubrics` array — revise in-loop if a note falls short. Do not cut the output down to only `displayId` until you have checked `.results[].rubric`.
1082
+ - **Pick the type, then read its rubric, then write to it — in that order.** Each type carries a `validationPrompt` (its quality rubric: what a good instance contains). Once you know the type, run `cnotes types show <Type>` (or read `typeRubrics` from `cnotes operations begin --json` / `validationPrompt` from `cnotes types list --json`) and author to that rubric so the note lands well-formed. Example: a Decision needs the alternatives weighed, the rationale, and a revisit trigger, and it cites the cards it depends on (see [Decisions](#decisions)). `cnotes notes create --json` also puts the rubric on **each** `.results[]` item (`type` + `rubric`) and as a top-level `rubrics` array. Do not cut the output down to only `displayId` until you have checked `.results[].rubric`. After the write, you grade: `cnotes quality` hands back `gradeRequest` (rubric + content + "Grade this against the rubric") and spends no credits. Record the grade with `cnotes quality record`. A Decision rubric that declares `Required sections:` fails the free structural check until those `##` headings are present.
1073
1083
  - If the type you need doesn't exist, create it first: `cnotes types create "MyType" --display-name "My Type"`
1074
1084
  - Type names are **case-sensitive** and use PascalCase (e.g., `Update`, `PainPoint`, `Meeting`).
1075
1085
  - The display ID prefix is **auto-derived** from the display name: spaces become hyphens, all uppercase (e.g., display name "Pain Point" → prefix `PAIN-POINT`, display name "Idea" → prefix `IDEA`).
@@ -1270,8 +1280,16 @@ cnotes canvas add-text <canvasId> --content '# Q1' --x 0 --y 0
1270
1280
  cnotes canvas place <canvasId> --spec /tmp/q1.json
1271
1281
  cnotes canvas add-edge <canvasId> --source <a> --target <b> --label "depends on"
1272
1282
 
1273
- # 3. Self-check the notes you wrote; revise (versions create) anything below 4.
1274
- cnotes quality <displayIds...> --fail-below 4
1283
+ # 3. Self-check the notes you wrote. You grade them. This spends no credits.
1284
+ # `cnotes quality --json` returns gradeRequest on each ungraded item:
1285
+ # the rubric, the note content, and "Grade this against the rubric".
1286
+ # Place the note on the ladder (1 Fragment, 2 Taking shape, 3 One move
1287
+ # from strong, 4 Strong). Write a reason for every criterion. Record it.
1288
+ # gradedBy becomes the open run id (this operation), or your agent name
1289
+ # when no run is open. Then run quality again. Exit 3 means revise with
1290
+ # versions create, record a new grade, and check once more.
1291
+ cnotes quality INSIGHT-12 --fail-below 4 --json
1292
+ cnotes quality record INSIGHT-12 --graded-version 4 --level 3 --criteria '[{"criterion":"Evidence","reason":"Grounded in two tickets."}]' --feedback "The pattern is named." --next-step "Say what would falsify it."
1275
1293
 
1276
1294
  # 4. Close the run when done.
1277
1295
  cnotes operations end