@creator-notes/cnotes 0.133.3 → 0.134.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.133.3",
3
+ "version": "0.134.0",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -3,6 +3,7 @@ import { resolveConfig } from "../lib/config.js";
3
3
  import { handleError, ValidationError } from "../lib/errors.js";
4
4
  import { outputJson } from "../lib/output.js";
5
5
  import { BEFORE_WRITING, briefIsEmpty, loadSessionBrief, renderBrief } from "../lib/session-brief.js";
6
+ import { conventionBriefLines, fetchConventions } from "../lib/conventions.js";
6
7
  /**
7
8
  * `cnotes brief "<task>"`: what the workspace already knows about a task,
8
9
  * before you act on it. The same brief `operations begin --prompt` returns,
@@ -12,13 +13,15 @@ import { BEFORE_WRITING, briefIsEmpty, loadSessionBrief, renderBrief } from "../
12
13
  export function registerBriefCommand(program) {
13
14
  program
14
15
  .command("brief")
15
- .description("What the workspace already knows about a task: the most relevant notes, canvases " +
16
- "(matched by meaning through their digests) and recent changes on the topic. " +
17
- "Run it before suggesting or doing anything.")
16
+ .description("What the workspace already knows about a task: its conventions (the standing rules " +
17
+ "people set), then the most relevant notes, canvases (matched by meaning through " +
18
+ "their digests) and recent changes on the topic. Run it before suggesting or doing anything.")
18
19
  .argument("<task...>", "The task, in plain words")
19
20
  .addHelpText("after", `
20
21
  Read-only and free of credits. \`operations begin --prompt\` includes the same
21
- brief, so you only need this when you are not opening a run. The brief ends on
22
+ brief, so you only need this when you are not opening a run. It opens with
23
+ the workspace's conventions, one title each (conventions.rules in --json): the
24
+ title is the rule, and \`cnotes notes get <id>\` has the why. The brief ends on
22
25
  one line, beforeWriting in --json: name the kind of request before you write.
23
26
 
24
27
  Examples:
@@ -32,12 +35,19 @@ Examples:
32
35
  const task = words.join(" ").trim();
33
36
  if (!task)
34
37
  throw new ValidationError("Say what the task is, e.g. `cnotes brief \"reprice the Team plan\"`.");
35
- const brief = await loadSessionBrief(api, cfg.workspaceId, task);
38
+ const [brief, conventions] = await Promise.all([
39
+ loadSessionBrief(api, cfg.workspaceId, task),
40
+ fetchConventions(api, cfg.workspaceId),
41
+ ]);
36
42
  const result = brief ?? { query: task, notes: [], canvases: [], changes: [] };
37
43
  if (cfg.json) {
38
- outputJson({ ...result, beforeWriting: BEFORE_WRITING });
44
+ outputJson({ ...(conventions ? { conventions } : {}), ...result, beforeWriting: BEFORE_WRITING });
39
45
  return;
40
46
  }
47
+ // The rules hold whatever the task is, so they lead even when nothing matches it.
48
+ const conventionLines = conventionBriefLines(conventions);
49
+ if (conventionLines.length > 0)
50
+ console.log(`${conventionLines.join("\n")}\n`);
41
51
  if (briefIsEmpty(result)) {
42
52
  console.log(`Nothing in this workspace matches "${task}" yet.`);
43
53
  console.log(`\n${BEFORE_WRITING}`);
@@ -9,6 +9,7 @@ import { loadConfig, setActiveAgentRunId, registerAgentRun, unregisterAgentRun,
9
9
  import { resolveHostAgentSession } from "../lib/claude-session.js";
10
10
  import { allWorkspaceRubrics, loadRubricMap } from "../lib/rubrics.js";
11
11
  import { BEFORE_STOPPING, BEFORE_WRITING, briefIsEmpty, loadSessionBrief, renderBrief } from "../lib/session-brief.js";
12
+ import { conventionBriefLines, fetchConventions } from "../lib/conventions.js";
12
13
  import { hasLessonFlags, lessonsFromFlags, postLessons, renderRecorded } from "../lib/lessons.js";
13
14
  import { renderProposalsForCaller } from "../lib/waiting-proposals.js";
14
15
  /**
@@ -47,7 +48,7 @@ export function registerOperationsCommands(program) {
47
48
  .option("--rationale <text>", "Optional free-form rationale; shown on expand alongside the intent")
48
49
  .option("--force", "If an active run already exists on this server, end it server-side and start a fresh one")
49
50
  .option("--detached", "Open an independent run that does NOT become the active run on this server. Writes attach to it only while CNOTES_AGENT_RUN_ID=<its id> is set. Use when another agent may hold the active run on this machine.")
50
- .option("--no-brief", "Skip the session brief (the notes, canvases and recent changes most relevant to --prompt)")
51
+ .option("--no-brief", "Skip the workspace's conventions and the session brief (the notes, canvases and recent changes most relevant to --prompt)")
51
52
  .addHelpText("after", `
52
53
  Examples:
53
54
  $ cnotes operations begin --prompt "Drafted the Japan travel canvas" --json
@@ -77,6 +78,12 @@ that has a validationPrompt. Read the ones you will author BEFORE notes create
77
78
  (or run cnotes types show <Type>). Post-write rubric echoes are too late to
78
79
  guide the draft.
79
80
 
81
+ Begin also returns the workspace's conventions: the standing rules people set
82
+ for it, one title each (the title is the rule; \`cnotes notes get <id>\` has
83
+ the why). Follow them in what you write. --json carries them as
84
+ conventions.rules. A rule you are given that should hold for every later
85
+ session is a note of type Convention; see \`cnotes types show Convention\`.
86
+
80
87
  With --prompt, begin also returns a brief of what the workspace already knows
81
88
  about the task: the most relevant notes (decisions, guides, metrics, findings),
82
89
  canvases matched by meaning through their digests, and recent changes on the
@@ -152,10 +159,14 @@ start fresh, or --detached to open your own run alongside it.
152
159
  // operation, so this is the one call that already runs before authoring.
153
160
  // Put validationPrompts in the begin response so agents see the standard
154
161
  // before they draft — not as a post-write echo they can jq-filter away.
155
- // Both lookups are best-effort and independent, so run them together.
156
- const [rubricMap, brief] = await Promise.all([
162
+ // The workspace's Conventions come the same way and for the same
163
+ // reason: a rule nobody showed the agent is a rule it breaks. They do
164
+ // not depend on --prompt, since they hold whatever the task is.
165
+ // All three lookups are best-effort and independent, so run them together.
166
+ const [rubricMap, brief, conventions] = await Promise.all([
157
167
  loadRubricMap(api, cfg.workspaceId),
158
168
  opts.brief === false ? Promise.resolve(null) : loadSessionBrief(api, cfg.workspaceId, opts.prompt),
169
+ opts.brief === false ? Promise.resolve(null) : fetchConventions(api, cfg.workspaceId),
159
170
  ]);
160
171
  const typeRubrics = allWorkspaceRubrics(rubricMap);
161
172
  reportHeadlineWarnings(readHeadlineWarnings(result));
@@ -175,6 +186,7 @@ start fresh, or --detached to open your own run alongside it.
175
186
  activeRunPersisted: persisted,
176
187
  detached: Boolean(opts.detached),
177
188
  typeRubrics,
189
+ ...(conventions ? { conventions } : {}),
178
190
  ...(brief ? { brief } : {}),
179
191
  ...(opts.brief === false ? {} : { beforeWriting: BEFORE_WRITING }),
180
192
  });
@@ -202,6 +214,12 @@ start fresh, or --detached to open your own run alongside it.
202
214
  for (const line of proposalLines)
203
215
  console.log(line);
204
216
  }
217
+ const conventionLines = conventionBriefLines(conventions);
218
+ if (conventionLines.length > 0) {
219
+ console.log("");
220
+ for (const line of conventionLines)
221
+ console.log(line);
222
+ }
205
223
  if (brief && !briefIsEmpty(brief)) {
206
224
  console.log("");
207
225
  console.log("What the workspace already knows about this (read before acting):");
@@ -0,0 +1,62 @@
1
+ export const CONVENTION_TYPE = "Convention";
2
+ /** The most rules one brief prints; past it the list says more exist. */
3
+ export const CONVENTIONS_LIMIT = 40;
4
+ /** The `/api/notes` query that lists a workspace's Conventions: titles, no bodies. */
5
+ export function conventionsQuery(workspaceId) {
6
+ return {
7
+ workspaceId,
8
+ types: CONVENTION_TYPE,
9
+ excludeContent: "true",
10
+ excludeDrafts: "true",
11
+ fields: "displayId,title,type,createdAt",
12
+ // One past the cap, so "more exist" is known without a count.
13
+ limit: String(CONVENTIONS_LIMIT + 1),
14
+ };
15
+ }
16
+ /**
17
+ * The rules in an `/api/notes` answer, oldest first so the list reads the same
18
+ * from one session to the next and a new rule lands at the end. Null when
19
+ * there are none. A row that is not a titled Convention is dropped rather than
20
+ * trusted: whatever this returns is printed to an agent as a rule to follow.
21
+ */
22
+ export function conventionsFromNotes(data) {
23
+ const rows = Array.isArray(data) ? data : [];
24
+ const found = [];
25
+ for (const row of rows) {
26
+ if (!row || row.type !== CONVENTION_TYPE)
27
+ continue;
28
+ const displayId = typeof row.displayId === "string" ? row.displayId : "";
29
+ const title = typeof row.title === "string" ? row.title.replace(/\s+/g, " ").trim() : "";
30
+ if (!displayId || !title)
31
+ continue;
32
+ found.push({ displayId, title, createdAt: typeof row.createdAt === "string" ? row.createdAt : "" });
33
+ }
34
+ if (found.length === 0)
35
+ return null;
36
+ // The route answers most recently changed first, so the cap keeps those.
37
+ const kept = found.slice(0, CONVENTIONS_LIMIT);
38
+ kept.sort((a, b) => a.createdAt.localeCompare(b.createdAt) || a.displayId.localeCompare(b.displayId));
39
+ return {
40
+ rules: kept.map(({ displayId, title }) => ({ displayId, title })),
41
+ more: found.length > CONVENTIONS_LIMIT,
42
+ };
43
+ }
44
+ /** What the list is, said once above it, in the words every surface uses. */
45
+ export const CONVENTIONS_LEAD = "Conventions: standing rules people set for this workspace. Follow them in what you write; open one for the why.";
46
+ /** The workspace's Conventions, or null when it has none or the lookup failed. Never throws. */
47
+ export async function fetchConventions(api, workspaceId) {
48
+ return api
49
+ .get("/api/notes", conventionsQuery(workspaceId))
50
+ .then(conventionsFromNotes)
51
+ .catch(() => null);
52
+ }
53
+ /** The block as the brief prints it. Empty when there are none. */
54
+ export function conventionBriefLines(conventions) {
55
+ if (!conventions || conventions.rules.length === 0)
56
+ return [];
57
+ return [
58
+ CONVENTIONS_LEAD,
59
+ ...conventions.rules.map((rule) => ` ${rule.displayId} ${rule.title}`),
60
+ ...(conventions.more ? [" More exist: cnotes notes list --type Convention"] : []),
61
+ ];
62
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.133.3",
3
+ "version": "0.134.0",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@ Every note and canvas you write is context: what the next reader, a teammate or
17
17
 
18
18
  Each call costs the user a model round trip, so batch, and send independent calls together. Reads need no run.
19
19
 
20
- 1. **Read, in parallel.** `cnotes workspace current` names the workspace and its relationship types (`-w <id>` targets another for one command). `cnotes brief "<task>"` returns the notes, canvases and recent changes most relevant to the task, with what earlier runs made of each (`lesson:` under a note; `Start here` lists the notes runs keep finding useful): read a correction before relying on the note it sits on. `cnotes search "<topic>"` finds notes, canvases and images in one call; a first line `Not in the workspace: …` names words no note holds, so say that rather than answer from the nearest note. `cnotes notes get <id> --expand` loads a note with the notes it rests on; a `Checked by:` line means a person confirmed that version with a passkey, so lean on it over an unchecked note. You cannot make that mark: when a decision rests on an unchecked note, ask the person in the chat to open it and choose ⋯ › Mark as checked. Before changing a canvas, `cnotes canvas read <canvasId>` (or `read-section SECTION-n` when the request names a frame). `cnotes types show <Type>` for each type you will write: author to its rubric. A Decision or Guide you find may already settle what you were about to propose.
20
+ 1. **Read, in parallel.** `cnotes workspace current` names the workspace and its relationship types (`-w <id>` targets another for one command). `cnotes brief "<task>"` returns the workspace's conventions (standing rules people set: follow them), then the notes, canvases and recent changes most relevant to the task, with what earlier runs made of each (`lesson:` under a note; `Start here` lists the notes runs keep finding useful): read a correction before relying on the note it sits on. `cnotes search "<topic>"` finds notes, canvases and images in one call; a first line `Not in the workspace: …` names words no note holds, so say that rather than answer from the nearest note. `cnotes notes get <id> --expand` loads a note with the notes it rests on; a `Checked by:` line means a person confirmed that version with a passkey, so lean on it over an unchecked note. You cannot make that mark: when a decision rests on an unchecked note, ask the person in the chat to open it and choose ⋯ › Mark as checked. Before changing a canvas, `cnotes canvas read <canvasId>` (or `read-section SECTION-n` when the request names a frame). `cnotes types show <Type>` for each type you will write: author to its rubric. A Decision or Guide you find may already settle what you were about to propose.
21
21
  2. **Name the kind of request.** [references/situations.md](references/situations.md) sorts it into one of 13 rows by what the person will do with the result, and each row says what to write, how to lay it out and how to check it. The first row is no board: most requests want the work done or a plain answer, and at most one note.
22
22
  3. **Write once, with `--intent`.** `--intent "<headline>"` opens an agent run for that one command and closes it after, so the change lands on the timeline as one revertable run; a removal gets a before snapshot. When a run is already open, the write joins it. To add cards, create and place them together:
23
23
  ```json
@@ -95,7 +95,7 @@ The second and third questions are rarely answered in the request. Assume the ch
95
95
 
96
96
  In the middle of other work, with nobody asking for a note, write one when the next session would otherwise have to be told again:
97
97
 
98
- - **You were corrected**, by a person or by your own check. Write the rule that was right.
98
+ - **You were corrected**, by a person or by your own check. Write the rule that was right. When a person set a rule that should hold for every later session ("we write CreatorNotes as one word"), write it as a Convention: the title is the rule, the body says why and who set it. Every brief and canvas read then opens with it, for every agent in the workspace. Only a rule a person set is a Convention, never your own preference.
99
99
  - **A decision was made** with its reasons. Write a Decision, and only what the person said.
100
100
  - **A fact changed.** Write the new fact as a successor and link it to the note it replaces.
101
101
  - **The work is pausing** or the context is about to reset. Write a handoff note.