@creator-notes/cnotes 0.120.2 → 0.121.1

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.120.2",
3
+ "version": "0.121.1",
4
4
  "description": "CreatorNotes CLI: create notes, build canvases, search knowledge from the terminal",
5
5
  "author": {
6
6
  "name": "CreatorNotes",
@@ -3,8 +3,9 @@ import { randomBytes } from "node:crypto";
3
3
  import { loadConfig, saveConfig, setServerConfig, removeServerConfig, getServerConfig, } from "../lib/auth-store.js";
4
4
  import { validateServerUrl, unofficialServerWarning, allowedCallbackOrigins, } from "../lib/server-url.js";
5
5
  import { readStdin } from "../lib/stdin.js";
6
- import { EXIT_CODES, handleError } from "../lib/errors.js";
6
+ import { ApiError, EXIT_CODES, handleError } from "../lib/errors.js";
7
7
  import { outputJson } from "../lib/output.js";
8
+ import { ApiClient } from "../lib/api-client.js";
8
9
  import { registerAuthKeysCommands } from "./auth-keys.js";
9
10
  export function registerAuthCommands(program) {
10
11
  const auth = program
@@ -109,6 +110,11 @@ Exit codes:
109
110
  2 signed out
110
111
 
111
112
  \`cnotes whoami\` and \`cnotes auth status\` are the same command.
113
+
114
+ When signed in, it asks the server which key this is. On a child key
115
+ (\`cnotes auth keys create\`) it prints the agent the key was minted for, the
116
+ name History shows on that agent's changes, and the account it acts for.
117
+ If the server cannot be asked, it prints the saved login and says why.
112
118
  `;
113
119
  /**
114
120
  * Print who is signed in. Exit 2 when there is no token, so a script can
@@ -116,17 +122,46 @@ Exit codes:
116
122
  * `cnotes auth status` and `cnotes whoami` both call this.
117
123
  */
118
124
  function registerAuthStatus(command, program) {
119
- command.addHelpText("after", AUTH_STATUS_HELP).action(() => {
125
+ command.addHelpText("after", AUTH_STATUS_HELP).action(async () => {
120
126
  const json = program.opts().json ?? false;
121
127
  try {
122
- showAuthStatus(json);
128
+ await showAuthStatus(json);
123
129
  }
124
130
  catch (error) {
125
131
  handleError(error, json);
126
132
  }
127
133
  });
128
134
  }
129
- function showAuthStatus(json) {
135
+ /** Ask the server which key this is; a short wait, so `whoami` stays quick offline. */
136
+ async function fetchKeyIdentity(serverUrl, token, workspaceId) {
137
+ let timer;
138
+ const timeout = new Promise((_, reject) => {
139
+ timer = setTimeout(() => reject(new Error("no answer within 2 s")), 2_000);
140
+ timer.unref();
141
+ });
142
+ try {
143
+ const api = new ApiClient(serverUrl, token, workspaceId ?? undefined);
144
+ const identity = await Promise.race([api.get("/api/auth/whoami"), timeout]);
145
+ return { identity };
146
+ }
147
+ catch (error) {
148
+ if (error instanceof ApiError)
149
+ return { error: `HTTP ${error.status}: ${error.message}` };
150
+ return { error: error instanceof Error ? error.message : String(error) };
151
+ }
152
+ finally {
153
+ clearTimeout(timer);
154
+ }
155
+ }
156
+ function describeKey(key) {
157
+ const pin = key.workspaceId ? `, pinned to workspace ${key.workspaceId}` : "";
158
+ if (key.kind === "child")
159
+ return `child key${pin}`;
160
+ if (key.kind === "oauth")
161
+ return `connector token "${key.name ?? ""}"${pin}`;
162
+ return `CLI key "${key.name ?? ""}"${pin}`;
163
+ }
164
+ async function showAuthStatus(json) {
130
165
  const config = loadConfig();
131
166
  const serverUrl = process.env.CNOTES_SERVER || config.currentServer;
132
167
  const sc = getServerConfig(config, serverUrl);
@@ -149,18 +184,32 @@ function showAuthStatus(json) {
149
184
  return;
150
185
  }
151
186
  const workspaceId = process.env.CNOTES_WORKSPACE?.trim() || sc?.workspaceId || null;
152
- const email = sc?.email || (envToken ? "(from CNOTES_TOKEN)" : "unknown");
187
+ const checked = await fetchKeyIdentity(serverUrl, token, workspaceId);
188
+ const identity = "identity" in checked ? checked.identity : null;
189
+ // The server's answer wins: under CNOTES_TOKEN, or a child key, the saved
190
+ // login's email belongs to some other key.
191
+ const email = identity?.email || sc?.email || (envToken ? "(from CNOTES_TOKEN)" : "unknown");
153
192
  if (json) {
154
193
  outputJson({
155
194
  authenticated: true,
156
195
  server: serverUrl,
157
196
  email,
158
197
  workspaceId,
198
+ agentName: identity?.agentName ?? null,
199
+ key: identity?.key ?? null,
200
+ ...("error" in checked ? { keyCheckError: checked.error } : {}),
159
201
  });
160
202
  return;
161
203
  }
162
204
  console.log(`Server: ${serverUrl}`);
163
205
  console.log(`Email: ${email}`);
206
+ if (identity?.agentName) {
207
+ console.log(`Agent: ${identity.agentName} (History shows this name on its changes)`);
208
+ }
209
+ if (identity?.key)
210
+ console.log(`Key: ${describeKey(identity.key)}`);
211
+ else if ("error" in checked)
212
+ console.log(`Key: not checked (${checked.error})`);
164
213
  console.log(`Workspace: ${workspaceId || "(not selected)"}`);
165
214
  }
166
215
  /** Read a small JSON body from an HTTP POST (login callback). */
@@ -7,7 +7,7 @@ import { resolveBaseConfig, resolveConfig } from "../lib/config.js";
7
7
  import { ApiError, CliError, EXIT_CODES, handleError, ValidationError } from "../lib/errors.js";
8
8
  import { parseJsonOption, readFileSafe } from "../lib/fs-utils.js";
9
9
  import { loadConfig, setActiveAgentRunId, registerAgentRun, unregisterAgentRun, isOwnedAgentRun, } from "../lib/auth-store.js";
10
- import { outputJson, outputTable, outputQuiet, truncate, timeAgo } from "../lib/output.js";
10
+ import { authorLabel, outputJson, outputTable, outputQuiet, truncate, timeAgo } from "../lib/output.js";
11
11
  import { readHeadlineWarnings, reportHeadlineWarnings } from "../lib/headline-warnings.js";
12
12
  import { formatDoneParts } from "../lib/done-parts.js";
13
13
  import { parseSharedCanvasLink, sameServerOrigin } from "../lib/share-link.js";
@@ -901,7 +901,7 @@ Examples:
901
901
  "";
902
902
  return [
903
903
  timeAgo(op.startedAt),
904
- truncate(op.actorName || "—", 18),
904
+ truncate(authorLabel({ name: op.actorName, agentName: op.agentName }), 32),
905
905
  truncate(op.operationType, 22),
906
906
  op.status,
907
907
  String(op.eventCount ?? 0),
@@ -1,7 +1,7 @@
1
1
  import { ApiClient } from "../lib/api-client.js";
2
2
  import { resolveConfig } from "../lib/config.js";
3
3
  import { handleError, ValidationError } from "../lib/errors.js";
4
- import { outputJson, outputTable, timeAgo, truncate } from "../lib/output.js";
4
+ import { authorLabel, outputJson, outputTable, timeAgo, truncate } from "../lib/output.js";
5
5
  const DURATION_UNITS = {
6
6
  m: 60_000,
7
7
  h: 3_600_000,
@@ -108,9 +108,10 @@ Examples:
108
108
  item.note.displayId,
109
109
  `v${item.versionNumber}`,
110
110
  truncate(item.changeDescription || "(no description)", 50),
111
+ truncate(authorLabel(item.author), 32),
111
112
  timeAgo(item.createdAtRaw),
112
113
  ]);
113
- outputTable(["NOTE", "V#", "CHANGE", "WHEN"], rows);
114
+ outputTable(["NOTE", "V#", "CHANGE", "BY", "WHEN"], rows);
114
115
  const typeSummary = Object.entries(data.summary.byType)
115
116
  .map(([type, count]) => `${type}: ${count}`)
116
117
  .join(", ");
@@ -3,7 +3,7 @@ import { ApiClient } from "../lib/api-client.js";
3
3
  import { resolveConfig } from "../lib/config.js";
4
4
  import { handleError, ValidationError, EXIT_CODES } from "../lib/errors.js";
5
5
  import { readFileSafe } from "../lib/fs-utils.js";
6
- import { outputJson, outputTable, timeAgo } from "../lib/output.js";
6
+ import { authorLabel, outputJson, outputTable, timeAgo } from "../lib/output.js";
7
7
  import { readHeadlineWarnings, reportHeadlineWarnings } from "../lib/headline-warnings.js";
8
8
  import { pendingProposalLines } from "../lib/draft-view.js";
9
9
  import { resolveNoteId } from "../lib/resolve-note.js";
@@ -44,9 +44,10 @@ Examples:
44
44
  String(v.versionNumber || ""),
45
45
  v.isLatest ? "*" : "",
46
46
  String(v.description || v.changeDescription || ""),
47
+ authorLabel(v.author),
47
48
  v.createdAt ? timeAgo(v.createdAt) : "",
48
49
  ]);
49
- outputTable(["VERSION", "LATEST", "DESCRIPTION", "CREATED"], rows);
50
+ outputTable(["VERSION", "LATEST", "DESCRIPTION", "BY", "CREATED"], rows);
50
51
  }
51
52
  catch (error) {
52
53
  handleError(error, cfg.json);
@@ -220,6 +220,8 @@ const REASON_HINTS = {
220
220
  builder_unknown: undefined,
221
221
  not_the_reviewer: undefined,
222
222
  prepare_needs_key: undefined,
223
+ // The sentence says the next round is a person's and how to hand it over.
224
+ agent_rounds: undefined,
223
225
  // Review requests and note batches: the same key with a different body.
224
226
  // Re-fetching changes nothing; the key is what has to change.
225
227
  idempotency_key_reused: "That idempotency key already went with a different body. Use a new key for this one; to get the earlier result back, send exactly what was sent with that key.",
@@ -148,6 +148,17 @@ export function outputJson(data, fields) {
148
148
  export function outputQuiet(value) {
149
149
  console.log(value);
150
150
  }
151
+ /**
152
+ * A change's author the way History words it: "Deniss via Anti-entropy Bot"
153
+ * when a bot's child key made it, else the person (PM-139).
154
+ */
155
+ export function authorLabel(author) {
156
+ const person = author?.name?.trim() || "";
157
+ const agent = author?.agentName?.trim() || "";
158
+ if (agent)
159
+ return `${person || "Someone"} via ${agent}`;
160
+ return person || "—";
161
+ }
151
162
  /**
152
163
  * Print a simple table with aligned columns.
153
164
  */
@@ -69,6 +69,11 @@ export function inPlaceStatusLines(s) {
69
69
  else if (p.isReviewer && p.isOwner && p.status === "open" && p.message) {
70
70
  out.push(`Another agent of yours, under its own key, may prepare the answer for you to give: cnotes draft prepare ${p.displayId} --accept|--send-back --note "<why>".`);
71
71
  }
72
+ if (s.agentRounds && p.status === "open") {
73
+ out.push(s.agentRounds >= 3
74
+ ? "Sent back three times between agents with nobody looking: the next send-back is a person's."
75
+ : `Sent back ${s.agentRounds} of 3 times between agents; after three, the next round goes to a person.`);
76
+ }
72
77
  if (p.intent)
73
78
  out.push(`Why: ${p.intent}`);
74
79
  if (p.message) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator-notes/cnotes",
3
- "version": "0.120.2",
3
+ "version": "0.121.1",
4
4
  "description": "CLI for CreatorNotes — create notes, build canvases, search knowledge from the terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -144,6 +144,7 @@ After you create a canvas or finish changing one, end your reply with its link,
144
144
  | Using any other canvas command: read, add, edit, move, remove, edges, templates, milestones, digest | [references/canvas.md](references/canvas.md) |
145
145
  | Running two agents at once, bracketing canvas edits, verifying attribution, reading the timeline | [references/operations.md](references/operations.md) |
146
146
  | Reworking notes or a board other people read, or asked to draft | [references/drafts.md](references/drafts.md) |
147
+ | Another agent works in the same workspace: handing work over, reviewing another agent's proposal, overlaps, settling it, when to stop | [references/agents-together.md](references/agents-together.md) |
147
148
  | Reviewing (propose the fix, or comment), addressing comments, requesting or answering a review, checking what teammates shared | [references/reviews-and-comments.md](references/reviews-and-comments.md) |
148
149
  | Hitting exit `8`, or asked for another workspace | [references/billing.md](references/billing.md) |
149
150
  | Planning focus blocks, handling images, setup, theme, config, or reporting a CLI problem | [references/more-commands.md](references/more-commands.md) |
@@ -0,0 +1,64 @@
1
+ # Working with other agents
2
+
3
+ Read this when another agent works in the same workspace as you: a second session of yours, a teammate's agent, or a bot in the same Slack, Teams or Discord channel as you. CreatorNotes is where you find each other's work, hand it over and settle it. A post in a Slack thread (or Teams, Discord, a GitHub comment) is not: some bots never see other bots' posts (Claude in Slack filters them out), and the next agent, in a terminal with no access to that thread, never sees it at all.
4
+
5
+ ## Contents
6
+
7
+ - [Have your own key](#have-your-own-key)
8
+ - [Start by reading what waits](#start-by-reading-what-waits)
9
+ - [Hand work over as a proposal](#hand-work-over-as-a-proposal)
10
+ - [Review another agent's proposal](#review-another-agents-proposal)
11
+ - [When two proposals overlap](#when-two-proposals-overlap)
12
+ - [Settle it in a note](#settle-it-in-a-note)
13
+ - [When to stop](#when-to-stop)
14
+
15
+ ## Have your own key
16
+
17
+ CreatorNotes tells agents apart by key. The agent that built a proposal is its key: that key can never prepare or give the answer to it. Two agents on one login key count as one agent, so a reviewer on the builder's key is refused.
18
+
19
+ - An agent you start gets a named key from you: `cnotes auth keys create --name "Codex (Slack)" --expires 8h -w <workspace> -q`, handed over as `CNOTES_TOKEN`. Its runs show the name in History ("Deniss via Codex (Slack)").
20
+ - Two agents on one machine each set `CNOTES_TOKEN`, and each pins its own proposal with `CNOTES_PROPOSAL=<id>` (or `none` to work live). A proposal id saved on another machine works too.
21
+
22
+ ## Start by reading what waits
23
+
24
+ `cnotes operations begin` lists, before you write anything:
25
+
26
+ - **Waiting on you**: proposals asked of the person you act for, who built each ("built by you via Codex (Slack)"), whether another agent already prepared an answer, and which reword the same notes.
27
+ - **Your proposals that overlap another**: yours, not yet asked, that reword a note another open proposal also rewords.
28
+
29
+ With `-q` these lines go to stderr. Read them first: the work you were about to start may already be proposed, or already reviewed. You only ever see proposals your person could already see.
30
+
31
+ ## Hand work over as a proposal
32
+
33
+ Hand another agent work as a proposal, never as a post in Slack or another channel outside CreatorNotes. Open it (`cnotes draft open "<name>" --intent "<the problem>"`), write into it, then ask a person: `cnotes draft ask --reviewer <email|me> --headline "..."`. The person asked is always a person; their agents review it for them. Then stop. Details: [drafts.md](drafts.md).
34
+
35
+ To point another agent at anything else (a finding, a note to check), write it in a note and give the display id: "my results are in OBSERVATION-123". In a Slack thread, post that id, never the finding itself.
36
+
37
+ ## Review another agent's proposal
38
+
39
+ What you may do depends on whose proposal it is:
40
+
41
+ - **Built by another agent of your own person:** you cannot accept or send it back; your person gives every answer to their own agents' work. Prepare the answer instead, after you read it (`cnotes draft status <PROPOSAL-n>` and its rewordings): `cnotes draft prepare <PROPOSAL-n> --accept --note "<why>"` or `--send-back --note "<what should change>"`. Your person sees "<your key's name> recommends landing it" with your line and gives it with one tap. A later write into the proposal clears what you prepared.
42
+ - **Built by a teammate's agent and asked of your person:** you may accept it or send it back under your person's key, as they would: `cnotes draft accept <PROPOSAL-n> --note "<why>"` or `cnotes draft send-back <PROPOSAL-n> --note "<what>"`. Decide only when your person told you how; otherwise prepare.
43
+
44
+ ## When two proposals overlap
45
+
46
+ `draft ask` prints "Overlaps: PROPOSAL-7 ... also rewords DECISION-1, built by ...", `draft status` lists it as a `proposal-overlap` warning, and `operations begin` marks it. It never blocks. Read the other one and decide which holds:
47
+
48
+ - **They agree:** say in your ask which should land first.
49
+ - **Yours repeats it:** fold what is new into the other, or dismiss yours.
50
+ - **They conflict:** write a Question for the person naming both, with your lean, and stop.
51
+
52
+ ## Settle it in a note
53
+
54
+ When the agents agree on something, one agent writes it down; the others check it. Say "I'll write it" first (in the proposal's ask, a canvas comment, or the Slack thread you share) so two agents do not write it twice.
55
+
56
+ - An outcome is a **Decision** that cites what it rests on (the proposals, the findings) with typed links. It counts as agreed only when the person versions it.
57
+ - A choice only the person can make is a **Question** with the options and your lean.
58
+ - The other agent reads the note and fixes it with an edit, never a second note.
59
+
60
+ ## When to stop
61
+
62
+ - **Three send-backs between agents is the cap.** Between two people, after three send-backs made by agents with no person in between, the fourth is refused (`agent_rounds`). Write a Question for your person that names what the two sides disagree on, with your lean, and stop. A person sending it back or asking for it in the browser starts the count again. Accepting stays open.
63
+ - **Ask, then stop.** After `draft ask` or `draft prepare`, your part is done until a person answers.
64
+ - **Nothing lands without a person** you act for or under their key; never press Accept in a browser for work you built.
@@ -102,6 +102,8 @@ CNOTES_TOKEN=$KEY CNOTES_WORKSPACE=<workspaceId> cnotes operations begin --promp
102
102
 
103
103
  A child key cannot mint keys, list or revoke them, or reach another workspace. `cnotes auth keys revoke <yourKeyId>` revokes every child it minted, and `cnotes auth keys list` marks which keys are children.
104
104
 
105
+ To trace a change back to the agent that made it, read the BY column (in JSON, `author.agentName`) of `cnotes timeline`, `cnotes versions list <note>` and `cnotes canvas activity <canvas>`: a change made under a child key reads "Deniss via Seat 3 · Notion PM". Under a child key, `cnotes whoami` prints the agent's name and the account it acts for.
106
+
105
107
  ## Writing a good `--prompt`
106
108
 
107
109
  The prompt is the timeline row's headline, and the server lints it like every headline: start with a past-tense verb and name the specific object, in the user's terms for that object. An imperative ("Re-cite the notes ...") is accepted but warns `not_verb_first`.