@creator-notes/cnotes 0.141.0 → 0.146.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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/commands/auth.js +7 -5
- package/dist/commands/canvas.js +9 -2
- package/dist/commands/init.js +62 -31
- package/dist/commands/notes.js +19 -13
- package/dist/commands/workspace.js +5 -3
- package/dist/lib/api-client.js +3 -0
- package/dist/lib/errors.js +3 -2
- package/dist/lib/rubrics.js +12 -8
- package/dist/lib/trial-notice.js +33 -0
- package/dist/lib/urls.js +24 -0
- package/dist/lib/workspace-choice.js +83 -0
- package/dist/mcp-server.js +3 -4
- package/package.json +1 -1
- package/skills/cnotes/SKILL.md +2 -2
- package/skills/cnotes/references/billing.md +9 -12
- package/skills/cnotes/references/notes.md +1 -1
- package/skills/cnotes/references/output.md +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -58,15 +58,17 @@ export function registerAuthCommands(program) {
|
|
|
58
58
|
if (!res.ok) {
|
|
59
59
|
throw new Error(`Token validation failed: HTTP ${res.status}`);
|
|
60
60
|
}
|
|
61
|
-
//
|
|
62
|
-
|
|
61
|
+
// Whose key this is, so `init` and `whoami` name the person, not "unknown".
|
|
62
|
+
const who = await fetchKeyIdentity(serverUrl, token, null);
|
|
63
|
+
const email = "identity" in who && who.identity.email ? who.identity.email : "unknown";
|
|
64
|
+
setServerConfig(config, serverUrl, { token, email });
|
|
63
65
|
config.currentServer = serverUrl;
|
|
64
66
|
saveConfig(config);
|
|
65
67
|
if (json) {
|
|
66
|
-
outputJson({ status: "authenticated", server: serverUrl });
|
|
68
|
+
outputJson({ status: "authenticated", server: serverUrl, ...(email !== "unknown" && { email }) });
|
|
67
69
|
}
|
|
68
70
|
else {
|
|
69
|
-
console.log(`Authenticated with ${serverUrl}`);
|
|
71
|
+
console.log(`Authenticated with ${serverUrl}${email !== "unknown" ? ` as ${email}` : ""}`);
|
|
70
72
|
}
|
|
71
73
|
return;
|
|
72
74
|
}
|
|
@@ -133,7 +135,7 @@ function registerAuthStatus(command, program) {
|
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
/** Ask the server which key this is; a short wait, so `whoami` stays quick offline. */
|
|
136
|
-
async function fetchKeyIdentity(serverUrl, token, workspaceId) {
|
|
138
|
+
export async function fetchKeyIdentity(serverUrl, token, workspaceId) {
|
|
137
139
|
let timer;
|
|
138
140
|
const timeout = new Promise((_, reject) => {
|
|
139
141
|
timer = setTimeout(() => reject(new Error("no answer within 2 s")), 2_000);
|
package/dist/commands/canvas.js
CHANGED
|
@@ -1246,7 +1246,12 @@ spec and run the same command again.
|
|
|
1246
1246
|
if (arrangeError) {
|
|
1247
1247
|
console.error(`⚠ Placed below ${intoSection}, but the section could not arrange itself: ${arrangeError}`);
|
|
1248
1248
|
}
|
|
1249
|
-
|
|
1249
|
+
// The canvas's link, on every reply: it is what the agent hands its person
|
|
1250
|
+
// to look at (the raw --x/--y path always carried it; this one did not).
|
|
1251
|
+
const link = await resolveCanvasLink(api, { serverUrl: resolveConfig(program.opts()).serverUrl, workspaceId }, canvasId);
|
|
1252
|
+
if (link)
|
|
1253
|
+
data.url = link;
|
|
1254
|
+
return { data, item, link };
|
|
1250
1255
|
};
|
|
1251
1256
|
const placedWhere = (section) => section ? `into ${section} (the section re-arranged itself)` : "below existing content, clear of everything";
|
|
1252
1257
|
canvas
|
|
@@ -1271,7 +1276,7 @@ Examples:
|
|
|
1271
1276
|
try {
|
|
1272
1277
|
const position = rawPosition(opts);
|
|
1273
1278
|
if (!position) {
|
|
1274
|
-
const { data, item } = await placeSingleItem(api, canvasId, cfg.workspaceId, { type: "note", noteId: opts.note }, opts.section);
|
|
1279
|
+
const { data, item, link } = await placeSingleItem(api, canvasId, cfg.workspaceId, { type: "note", noteId: opts.note }, opts.section);
|
|
1275
1280
|
if (cfg.quiet) {
|
|
1276
1281
|
outputQuiet(String(item.id));
|
|
1277
1282
|
}
|
|
@@ -1280,6 +1285,8 @@ Examples:
|
|
|
1280
1285
|
}
|
|
1281
1286
|
else {
|
|
1282
1287
|
console.log(`Added note ${opts.note} ${placedWhere(opts.section)}`);
|
|
1288
|
+
if (link)
|
|
1289
|
+
console.log(`Link: ${link}`);
|
|
1283
1290
|
}
|
|
1284
1291
|
return;
|
|
1285
1292
|
}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { spawnSync } from "child_process";
|
|
2
|
-
import { loadConfig, getServerConfig, setWorkspaceId, } from "../lib/auth-store.js";
|
|
2
|
+
import { loadConfig, getServerConfig, setServerConfig, setWorkspaceId, } from "../lib/auth-store.js";
|
|
3
3
|
import { ApiClient } from "../lib/api-client.js";
|
|
4
4
|
import { CliError, EXIT_CODES, handleError } from "../lib/errors.js";
|
|
5
5
|
import { BRAND } from "../lib/brand.js";
|
|
6
|
-
import { browserLogin } from "./auth.js";
|
|
6
|
+
import { browserLogin, fetchKeyIdentity } from "./auth.js";
|
|
7
7
|
import { fetchAndSelectWorkspace } from "./workspace.js";
|
|
8
|
+
import { canWrite, chooseWorkspace, firstWriteLines, workspaceId, workspaceName } from "../lib/workspace-choice.js";
|
|
8
9
|
import { buildClaudeConfig } from "./mcp.js";
|
|
9
10
|
import { bold, dim, green, cyan, CHECK, ARROW, WARN } from "../lib/style.js";
|
|
10
11
|
import { installMcpConfig, getConfigPath } from "../lib/install-mcp.js";
|
|
@@ -117,8 +118,9 @@ Agent path (no terminal, or --non-interactive):
|
|
|
117
118
|
Keep the key on stdin. Do not pass it as --token.
|
|
118
119
|
Then run \`cnotes init\` again.
|
|
119
120
|
|
|
120
|
-
One workspace is selected for you
|
|
121
|
-
|
|
121
|
+
One workspace is selected for you, and so is the only one the key can
|
|
122
|
+
write to when the others are read-only. Several writable workspaces: init
|
|
123
|
+
prints \`cnotes workspace select <id>\` for each and exits 1.
|
|
122
124
|
|
|
123
125
|
Exit 0 and the line "You're all set." means setup is finished.
|
|
124
126
|
Next, run \`cnotes brief "<what you are here to do>"\`.
|
|
@@ -337,46 +339,72 @@ async function runInitNonInteractive() {
|
|
|
337
339
|
process.exitCode = EXIT_CODES.AUTH;
|
|
338
340
|
return;
|
|
339
341
|
}
|
|
342
|
+
// A key login that could not ask whose key it is (a slow first answer)
|
|
343
|
+
// stored "unknown": ask once more here, and keep the answer.
|
|
344
|
+
if (!sc.email || sc.email === "unknown") {
|
|
345
|
+
const who = await fetchKeyIdentity(serverUrl, sc.token, sc.workspaceId ?? null);
|
|
346
|
+
if ("identity" in who && who.identity.email) {
|
|
347
|
+
sc.email = who.identity.email;
|
|
348
|
+
setServerConfig(config, serverUrl, sc);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
340
351
|
console.log(` ${CHECK} Authenticated as ${bold(sc.email || "unknown")}`);
|
|
341
|
-
// ──
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
352
|
+
// ── The workspace: the only one, or the only one this key can write to, is
|
|
353
|
+
// chosen; several are the person's to choose between (workspace-choice.ts) ──
|
|
354
|
+
let active = null;
|
|
355
|
+
let others = [];
|
|
356
|
+
try {
|
|
357
|
+
const api = new ApiClient(serverUrl, sc.token);
|
|
358
|
+
const data = await api.get("/api/workspaces");
|
|
359
|
+
const workspaces = data.workspaces || data;
|
|
360
|
+
const list = Array.isArray(workspaces) ? workspaces : [];
|
|
361
|
+
const choice = chooseWorkspace(list);
|
|
362
|
+
if (!sc.workspaceId) {
|
|
348
363
|
if (list.length === 0) {
|
|
349
364
|
console.log(` ${WARN} No workspaces yet. Create one at ${cyan(serverUrl)}, then re-run ${cyan(`${cli} init`)}.`);
|
|
350
365
|
process.exitCode = 1;
|
|
351
366
|
return;
|
|
352
367
|
}
|
|
353
|
-
if (
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
console.log(` ${WARN} You have multiple workspaces — pick one and run it:`);
|
|
361
|
-
for (const w of list) {
|
|
362
|
-
const id = String(w._id || w.id || "");
|
|
363
|
-
console.log(` ${cyan(`${cli} workspace select ${id}`)} ${dim(String(w.name || ""))}`);
|
|
368
|
+
if (!choice.pick) {
|
|
369
|
+
console.log(` ${WARN} You have several workspaces. Ask your user which one, then run its line:`);
|
|
370
|
+
for (const w of choice.ordered) {
|
|
371
|
+
const note = canWrite(w) ? "" : " (read-only: this key cannot write here)";
|
|
372
|
+
console.log(` ${cyan(`${cli} workspace select ${workspaceId(w)}`)} ${dim(workspaceName(w) + note)}`);
|
|
364
373
|
}
|
|
365
374
|
process.exitCode = 1;
|
|
366
375
|
return;
|
|
367
376
|
}
|
|
377
|
+
active = choice.pick;
|
|
378
|
+
setWorkspaceId(config, serverUrl, workspaceId(active));
|
|
379
|
+
const why = list.length > 1 && canWrite(active) ? dim(" (the one this key can write to)") : "";
|
|
380
|
+
console.log(` ${CHECK} Workspace ${bold(`"${workspaceName(active)}"`)} selected${why}`);
|
|
368
381
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
382
|
+
else {
|
|
383
|
+
active = list.find((w) => workspaceId(w) === sc.workspaceId) ?? null;
|
|
384
|
+
console.log(` ${CHECK} Workspace ${active ? `${bold(`"${workspaceName(active)}"`)} is active` : "is active"}`);
|
|
385
|
+
}
|
|
386
|
+
others = choice.ordered.filter((w) => w !== active);
|
|
387
|
+
}
|
|
388
|
+
catch (err) {
|
|
389
|
+
console.log(` ${WARN} Could not reach the workspace API: ${dim(err instanceof Error ? err.message : String(err))}`);
|
|
390
|
+
// Preserve the typed exit code when we have one — e.g. an expired token
|
|
391
|
+
// surfaces as HTTP 401 → AUTH (2), so the agent knows to re-run the
|
|
392
|
+
// sign-in handoff rather than retry blindly.
|
|
393
|
+
process.exitCode = err instanceof CliError ? err.exitCode : 1;
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
// The active workspace can only be read: say so before anything is written,
|
|
397
|
+
// with the one that can be written if there is one.
|
|
398
|
+
if (active && !canWrite(active)) {
|
|
399
|
+
console.log(` ${WARN} ${bold(`"${workspaceName(active)}"`)} is read-only for you: this key cannot write to it.`);
|
|
400
|
+
for (const w of others.filter(canWrite)) {
|
|
401
|
+
console.log(` To write, switch to ${bold(`"${workspaceName(w)}"`)}: ${cyan(`${cli} workspace select ${workspaceId(w)}`)}`);
|
|
376
402
|
}
|
|
377
403
|
}
|
|
378
404
|
else {
|
|
379
|
-
|
|
405
|
+
for (const w of others.filter((o) => !canWrite(o))) {
|
|
406
|
+
console.log(` ${dim(`Also yours to read (read-only): "${workspaceName(w)}". Add`)} ${cyan(`-w ${workspaceId(w)}`)} ${dim("to a command to read it.")}`);
|
|
407
|
+
}
|
|
380
408
|
}
|
|
381
409
|
// ── Install the agent skill(s) (best-effort, no prompt) ──
|
|
382
410
|
for (const target of SKILL_TARGETS.filter(hasAgentConfigDir)) {
|
|
@@ -404,7 +432,10 @@ async function runInitNonInteractive() {
|
|
|
404
432
|
console.log(` ${dim("Tip: run")} ${cyan("npm install -g @creator-notes/cnotes")} ${dim("once to drop the npx prefix.")}`);
|
|
405
433
|
}
|
|
406
434
|
console.log();
|
|
407
|
-
|
|
435
|
+
// What the first write needs, said before it is refused for lacking it.
|
|
436
|
+
for (const line of firstWriteLines(cli, active))
|
|
437
|
+
console.log(line ? ` ${line}` : "");
|
|
438
|
+
console.log();
|
|
408
439
|
}
|
|
409
440
|
// ── Skill install ───────────────────────────────────────────
|
|
410
441
|
async function maybeInstallSkill() {
|
package/dist/commands/notes.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiClient, resolveActiveAgentRun } from "../lib/api-client.js";
|
|
2
|
+
import { noteUrl, placeNextLine } from "../lib/urls.js";
|
|
2
3
|
import { resolveConfig } from "../lib/config.js";
|
|
3
4
|
import { CliError, handleError, NotFoundError, ValidationError, EXIT_CODES } from "../lib/errors.js";
|
|
4
5
|
import { parseJsonOption } from "../lib/fs-utils.js";
|
|
@@ -11,7 +12,7 @@ import { explainTruncation, listNotes, SERVER_LIST_CAP } from "../lib/notes-list
|
|
|
11
12
|
import { formatLinkedItemHeading, groupLinkedByRelation, parseExpandArgs, projectExpandPayload, renderExpandContentOnly, } from "../lib/expand-notes.js";
|
|
12
13
|
import { noteBatchIdempotencyKey, resolveNoteBatchItems } from "../lib/note-batch.js";
|
|
13
14
|
import { describeUnresolvedMentions, lintNarratedVerbMentions, lintPlainTextDisplayIdsBatch, hasGenericMention, fetchRelationshipTypeOptions, } from "../lib/mention-lint.js";
|
|
14
|
-
import {
|
|
15
|
+
import { attachTypes, gradableIds, loadRubricMap, rubricsForTypes, } from "../lib/rubrics.js";
|
|
15
16
|
import { DECISION_CARD_RULE, } from "../lib/decision-citation.js";
|
|
16
17
|
import { registerNotesImport } from "./notes-import.js";
|
|
17
18
|
import { orderByDisplayId } from "../lib/mcp-spec.js";
|
|
@@ -592,10 +593,10 @@ Examples:
|
|
|
592
593
|
|
|
593
594
|
Output (--json):
|
|
594
595
|
Returns an object, not an array. Created notes are under the "results" key
|
|
595
|
-
(not "notes"/"ok"); each carries displayId, title, type
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
to
|
|
596
|
+
(not "notes"/"ok"); each carries displayId, title, type and url. The
|
|
597
|
+
top-level "rubrics" array holds each used type's rubric once, for types that
|
|
598
|
+
have one: read it before revising, since a filter down to .results[] leaves
|
|
599
|
+
it out. "next" says how to put the notes on a canvas. "selfCheck" is the
|
|
599
600
|
command that grades the new notes against those rubrics; run it and revise
|
|
600
601
|
anything below 4 before ending the operation. Read results with:
|
|
601
602
|
cnotes notes create --json --notes '…' | jq -r '.results[] | "\\(.displayId) \\(.type)"'
|
|
@@ -744,22 +745,22 @@ Output (--json):
|
|
|
744
745
|
emitUnresolved();
|
|
745
746
|
return;
|
|
746
747
|
}
|
|
747
|
-
// Echo
|
|
748
|
-
//
|
|
749
|
-
//
|
|
750
|
-
// displayId). Zero LLM — stored validationPrompt only. Non-fatal.
|
|
748
|
+
// Echo the rubric of each type just used, once, under `rubrics`; each
|
|
749
|
+
// result carries its `type` to look it up by. Zero LLM: the stored
|
|
750
|
+
// validationPrompt only. Non-fatal.
|
|
751
751
|
const rubricMap = await loadRubricMap(api, cfg.workspaceId);
|
|
752
752
|
const typeByKey = new Map(notes.map((n) => [n.key, n.type]));
|
|
753
753
|
const rawResults = (data.results || []);
|
|
754
|
-
|
|
754
|
+
// Each new note's link, and what is left to do for a person to see it:
|
|
755
|
+
// a note just created is on no canvas (the first-run walk, 29 Nov 2026).
|
|
756
|
+
const results = attachTypes(rawResults, typeByKey).map((r) => r.displayId ? { ...r, url: noteUrl(cfg.serverUrl, cfg.workspaceId, String(r.displayId)) } : r);
|
|
757
|
+
const next = alreadyExists ? null : placeNextLine(results.filter((r) => r.displayId).map((r) => String(r.displayId)));
|
|
755
758
|
const rubrics = rubricsForTypes(notes.map((n) => n.type), rubricMap);
|
|
756
759
|
// The self-check closes the loop the rubric echo opens. The command
|
|
757
760
|
// does not grade and does not spend credits: it returns a
|
|
758
761
|
// gradeRequest (rubric + content) for each new note. The agent grades
|
|
759
762
|
// that payload and records it with `cnotes quality record`.
|
|
760
|
-
const gradable = results
|
|
761
|
-
.filter((r) => r.rubric && r.displayId)
|
|
762
|
-
.map((r) => String(r.displayId));
|
|
763
|
+
const gradable = gradableIds(results, rubricMap);
|
|
763
764
|
const selfCheck = gradable.length > 0
|
|
764
765
|
? `cnotes quality ${gradable.join(" ")} --fail-below 4 --json`
|
|
765
766
|
: null;
|
|
@@ -768,6 +769,7 @@ Output (--json):
|
|
|
768
769
|
results,
|
|
769
770
|
...(rubrics.length > 0 ? { rubrics } : {}),
|
|
770
771
|
...(selfCheck ? { selfCheck } : {}),
|
|
772
|
+
...(next ? { next } : {}),
|
|
771
773
|
...(mentionWarnings.length > 0 ? { mentionWarnings } : {}),
|
|
772
774
|
...(plainTextIdWarnings.length > 0 ? { plainTextIdWarnings } : {}),
|
|
773
775
|
};
|
|
@@ -786,7 +788,11 @@ Output (--json):
|
|
|
786
788
|
}
|
|
787
789
|
for (const r of results) {
|
|
788
790
|
console.log(` ${r.displayId}: ${r.title || "(untitled)"}`);
|
|
791
|
+
if ("url" in r && r.url)
|
|
792
|
+
console.log(` ${r.url}`);
|
|
789
793
|
}
|
|
794
|
+
if (next)
|
|
795
|
+
console.log(`\n${next}`);
|
|
790
796
|
if (rubrics.length > 0) {
|
|
791
797
|
console.log("");
|
|
792
798
|
for (const { type, rubric } of rubrics) {
|
|
@@ -4,6 +4,7 @@ import { clearProposalById, loadConfig, setWorkspaceId } from "../lib/auth-store
|
|
|
4
4
|
import { handleError, ApiError, AuthError, CliError, EXIT_CODES, NetworkError, ValidationError } from "../lib/errors.js";
|
|
5
5
|
import { outputJson, outputTable, timeAgo } from "../lib/output.js";
|
|
6
6
|
import { blockedWorkspaceNotes, workspaceListState } from "../lib/billing-block.js";
|
|
7
|
+
import { chooseWorkspace, workspaceRole } from "../lib/workspace-choice.js";
|
|
7
8
|
import { isNotFound } from "../lib/proposal-in-place.js";
|
|
8
9
|
import { draftLink, draftOfLine, spokenDetail } from "../lib/draft-view.js";
|
|
9
10
|
import { registerWorkspaceCheck } from "./workspace-check.js";
|
|
@@ -104,8 +105,9 @@ export async function fetchAndSelectWorkspace(serverUrl, token, currentWorkspace
|
|
|
104
105
|
const { select } = await import("@inquirer/prompts");
|
|
105
106
|
chosenId = await select({
|
|
106
107
|
message: "Select a workspace to activate:",
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
// Writable first; one the key can only read says so.
|
|
109
|
+
choices: chooseWorkspace(list).ordered.map((w) => {
|
|
110
|
+
const state = [workspaceListState(w), workspaceRole(w)].filter(Boolean).join(" · ");
|
|
109
111
|
const active = (w._id || w.id) === currentWorkspaceId ? " (active)" : "";
|
|
110
112
|
return {
|
|
111
113
|
name: `${String(w.name || "(unnamed)")}${state ? ` · ${state}` : ""}${active}`,
|
|
@@ -203,7 +205,7 @@ Examples:
|
|
|
203
205
|
return [
|
|
204
206
|
String(w._id || w.id || ""),
|
|
205
207
|
String(w.name || ""),
|
|
206
|
-
[active, state].filter(Boolean).join(" "),
|
|
208
|
+
[active, state, workspaceRole(w)].filter(Boolean).join(" "),
|
|
207
209
|
];
|
|
208
210
|
});
|
|
209
211
|
outputTable(["ID", "NAME", "STATE"], rows);
|
package/dist/lib/api-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { ApiError, asCliError, CliError, EXIT_CODES, isPermanentNetworkError, isRefusedBeforeSend } from "./errors.js";
|
|
3
|
+
import { noteTrialStarted } from "./trial-notice.js";
|
|
3
4
|
import { loadConfig, getActiveAgentRunId, getServerConfig } from "./auth-store.js";
|
|
4
5
|
import { inPlaceProposalId, resolveProposal } from "./config.js";
|
|
5
6
|
import { detectAgentClient } from "./agent-client.js";
|
|
@@ -187,6 +188,8 @@ export class ApiClient {
|
|
|
187
188
|
}
|
|
188
189
|
const res = await fetch(url, init);
|
|
189
190
|
if (res.ok || !isRetryable(res.status) || (!replaySafe && res.status !== 429)) {
|
|
191
|
+
// A write that started the workspace's free trial says so (trial-notice.ts).
|
|
192
|
+
noteTrialStarted(res.headers);
|
|
190
193
|
return res;
|
|
191
194
|
}
|
|
192
195
|
// Retryable server error — wait and retry
|
package/dist/lib/errors.js
CHANGED
|
@@ -439,8 +439,9 @@ function hintForStatus(status, message, resource) {
|
|
|
439
439
|
// re-auth — not the full `cnotes init` setup that AuthError suggests.
|
|
440
440
|
if (status === 401)
|
|
441
441
|
return "Run `cnotes auth login` to authenticate.";
|
|
442
|
-
if (status === 403)
|
|
443
|
-
return "
|
|
442
|
+
if (status === 403) {
|
|
443
|
+
return "This key cannot do that in the active workspace. `cnotes workspace list` shows each workspace and marks the read-only ones; `cnotes workspace select <id>` switches.";
|
|
444
|
+
}
|
|
444
445
|
if (status === 404) {
|
|
445
446
|
// Prefer a server-provided `resource` field; fall back to regex on the
|
|
446
447
|
// error message. Regex is best-effort because server messages vary.
|
package/dist/lib/rubrics.js
CHANGED
|
@@ -50,16 +50,20 @@ export function allWorkspaceRubrics(map) {
|
|
|
50
50
|
.sort((a, b) => a.type.localeCompare(b.type));
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* (several default types ship without one).
|
|
53
|
+
* Give each create result its `type`. `typeByKey` maps the batch item key →
|
|
54
|
+
* type string from the create request; a result with no key keeps the type
|
|
55
|
+
* the server sent. The rubric is not copied here: it is in the reply's
|
|
56
|
+
* `rubrics` list, once per type (rubricsForTypes).
|
|
58
57
|
*/
|
|
59
|
-
export function
|
|
58
|
+
export function attachTypes(results, typeByKey) {
|
|
60
59
|
return results.map((r) => {
|
|
61
60
|
const type = (r.key ? typeByKey.get(String(r.key)) : undefined) ?? String(r.type ?? "");
|
|
62
|
-
|
|
63
|
-
return { ...r, type, rubric };
|
|
61
|
+
return { ...r, type };
|
|
64
62
|
});
|
|
65
63
|
}
|
|
64
|
+
/** The display ids of the new notes whose type has a rubric: what the self-check grades. */
|
|
65
|
+
export function gradableIds(results, map) {
|
|
66
|
+
return results
|
|
67
|
+
.filter((r) => r.displayId && typeof r.type === "string" && map.has(r.type.toLowerCase()))
|
|
68
|
+
.map((r) => String(r.displayId));
|
|
69
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one line the CLI prints when a write started the workspace's free trial.
|
|
3
|
+
*
|
|
4
|
+
* The owner's first CLI or API write to a free workspace starts its 7-day Pro
|
|
5
|
+
* trial on the server and goes through (lib/auth/server.ts,
|
|
6
|
+
* startTrialOnFirstWrite); the response says so in a header whose value is
|
|
7
|
+
* when the trial ends. Nobody asked for that trial, so the agent is told on
|
|
8
|
+
* stderr, in words it can pass to its person, and stdout stays the command's
|
|
9
|
+
* own output.
|
|
10
|
+
*/
|
|
11
|
+
/** Must match TRIAL_STARTED_HEADER in lib/auth/server.ts. */
|
|
12
|
+
export const TRIAL_STARTED_HEADER = "X-CN-Trial-Started";
|
|
13
|
+
/** The stderr line for a response that started a trial, or null when it did not. */
|
|
14
|
+
export function trialStartedNotice(headerValue) {
|
|
15
|
+
if (!headerValue)
|
|
16
|
+
return null;
|
|
17
|
+
const ends = new Date(headerValue);
|
|
18
|
+
const when = Number.isNaN(ends.getTime()) ? "in 7 days" : `on ${ends.toISOString().slice(0, 10)}`;
|
|
19
|
+
return (`note: this write started the workspace's free 7-day Pro trial (no card needed). It ends ${when}. ` +
|
|
20
|
+
"After that, CLI and API writes need Pro; reading always works. Tell your user. " +
|
|
21
|
+
"`cnotes upgrade` shows where to subscribe.");
|
|
22
|
+
}
|
|
23
|
+
/** Print the notice once per process: one command can make several writes. */
|
|
24
|
+
let printed = false;
|
|
25
|
+
export function noteTrialStarted(headers) {
|
|
26
|
+
if (printed)
|
|
27
|
+
return;
|
|
28
|
+
const line = trialStartedNotice(headers.get(TRIAL_STARTED_HEADER));
|
|
29
|
+
if (!line)
|
|
30
|
+
return;
|
|
31
|
+
printed = true;
|
|
32
|
+
process.stderr.write(`${line}\n`);
|
|
33
|
+
}
|
package/dist/lib/urls.js
CHANGED
|
@@ -15,6 +15,30 @@ export function canvasUrl(serverUrl, workspaceId, canvasId) {
|
|
|
15
15
|
const origin = serverUrl.replace(/\/+$/, "");
|
|
16
16
|
return `${origin}/${workspaceId}?canvasId=${canvasId}`;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Where a person opens one note: the workspace with the note open over it.
|
|
20
|
+
*
|
|
21
|
+
* <origin>/<workspaceId>?noteId=<displayId>
|
|
22
|
+
*
|
|
23
|
+
* A note just created is on no canvas, so this is the only link there is to
|
|
24
|
+
* give for it (the app's own shape: components/mention-shared/open-far-note.ts).
|
|
25
|
+
*/
|
|
26
|
+
export function noteUrl(serverUrl, workspaceId, displayId) {
|
|
27
|
+
const origin = serverUrl.replace(/\/+$/, "");
|
|
28
|
+
return `${origin}/${encodeURIComponent(workspaceId)}?noteId=${encodeURIComponent(displayId)}`;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What `notes create` says next: the notes exist and are on no canvas, which
|
|
32
|
+
* is where a person looks. Null when nothing was created.
|
|
33
|
+
*/
|
|
34
|
+
export function placeNextLine(displayIds) {
|
|
35
|
+
if (displayIds.length === 0)
|
|
36
|
+
return null;
|
|
37
|
+
const many = displayIds.length > 1;
|
|
38
|
+
return (`${many ? "These notes are" : "This note is"} on no canvas yet. To put ${many ? "one" : "it"} where a person will see it: ` +
|
|
39
|
+
`cnotes canvas add-node <canvasId> --note ${displayIds[0]} --intent "<past-tense headline>" ` +
|
|
40
|
+
"(`cnotes canvas list` shows the canvases; `cnotes canvas place` lays out several at once). Its reply carries the canvas link.");
|
|
41
|
+
}
|
|
18
42
|
/**
|
|
19
43
|
* True when `ref` is a canvas *display id* (e.g. "CANVAS-12") rather than a raw
|
|
20
44
|
* Convex id. Only the Convex id resolves in `?canvasId`, so a click-through
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which workspace a fresh key works in, and what `init` says about it.
|
|
3
|
+
*
|
|
4
|
+
* A key's workspaces (GET /api/workspaces) are not alike: a person who read a
|
|
5
|
+
* public workspace is a reader there and owns an Inbox of their own. Listing
|
|
6
|
+
* the two side by side left an agent to guess, and the one its person had been
|
|
7
|
+
* looking at was the one it could not write to (the first-run walk, 29 Nov
|
|
8
|
+
* 2026). The key's one writable workspace is chosen for it, a read-only one
|
|
9
|
+
* is labelled, and init's closing lines say what the first write needs.
|
|
10
|
+
*/
|
|
11
|
+
export function workspaceId(row) {
|
|
12
|
+
return String(row._id || row.id || "");
|
|
13
|
+
}
|
|
14
|
+
export function workspaceName(row) {
|
|
15
|
+
return String(row.name || "(unnamed)");
|
|
16
|
+
}
|
|
17
|
+
/** A key's rows say `permission`; a session's say `userPermission`. */
|
|
18
|
+
function role(row) {
|
|
19
|
+
return row.userPermission ?? row.permission;
|
|
20
|
+
}
|
|
21
|
+
/** Whether this key can write there: an editor or an admin. A row with no role is taken as writable, as before roles were listed. */
|
|
22
|
+
export function canWrite(row) {
|
|
23
|
+
const r = role(row);
|
|
24
|
+
return r === undefined || r === null || r === "editor" || r === "admin";
|
|
25
|
+
}
|
|
26
|
+
/** The label a list shows beside a workspace the key can only read. */
|
|
27
|
+
export function workspaceRole(row) {
|
|
28
|
+
return canWrite(row) ? "" : "read-only";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The only workspace, or the only one the key can write to, is chosen.
|
|
32
|
+
* Several writable ones (or several read-only and none writable) are the
|
|
33
|
+
* person's to choose between. A draft is written through its parent and is
|
|
34
|
+
* never a choice.
|
|
35
|
+
*/
|
|
36
|
+
export function chooseWorkspace(rows) {
|
|
37
|
+
const choices = rows.filter((row) => !row.draftOfWorkspaceId);
|
|
38
|
+
const writable = choices.filter(canWrite);
|
|
39
|
+
const readOnly = choices.filter((row) => !canWrite(row));
|
|
40
|
+
const pick = writable.length === 1 ? writable[0] : choices.length === 1 ? choices[0] : null;
|
|
41
|
+
return { pick, writable, readOnly, ordered: [...writable, ...readOnly] };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Whether the first write to this workspace starts its free trial: a free
|
|
45
|
+
* workspace the key can write to whose one-time trial is unused. The server
|
|
46
|
+
* decides (it also needs the key's owner to own the workspace); this is only
|
|
47
|
+
* what init says ahead of time.
|
|
48
|
+
*/
|
|
49
|
+
export function freePlanStartsTrial(row) {
|
|
50
|
+
if (!canWrite(row))
|
|
51
|
+
return false;
|
|
52
|
+
if (row.plan !== "free")
|
|
53
|
+
return false;
|
|
54
|
+
if (row.subscriptionStatus === "trialing" || row.subscriptionStatus === "grandfathered")
|
|
55
|
+
return false;
|
|
56
|
+
return !row.trialStartedAt;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Init's closing lines: what the first write needs and the two commands that
|
|
60
|
+
* put a first note on a canvas, or for a read-only workspace the commands
|
|
61
|
+
* that read it. Plain text; the caller indents and colours.
|
|
62
|
+
*/
|
|
63
|
+
export function firstWriteLines(cli, row) {
|
|
64
|
+
if (row && !canWrite(row)) {
|
|
65
|
+
return [
|
|
66
|
+
`You can read "${workspaceName(row)}" and cannot write to it.`,
|
|
67
|
+
"",
|
|
68
|
+
`${cli} canvas list its canvases`,
|
|
69
|
+
`${cli} canvas read <canvasId> one canvas as markdown`,
|
|
70
|
+
`${cli} search semantic "<words>" find notes by meaning`,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
const lines = [
|
|
74
|
+
"Before the first write:",
|
|
75
|
+
` Every write takes --intent "<past-tense headline>" (for example --intent "Added the first notes").`,
|
|
76
|
+
" It lands on the timeline as one change a person can undo.",
|
|
77
|
+
];
|
|
78
|
+
if (row && freePlanStartsTrial(row)) {
|
|
79
|
+
lines.push(" This workspace is on the free plan. If you own it, your first write starts its free 7-day Pro trial", " (no card) and goes through; the CLI prints a note when it does. Tell your user.");
|
|
80
|
+
}
|
|
81
|
+
lines.push("", "A first note on a canvas:", ` ${cli} notes create --notes '{"key":"A","type":"Note","markdown":"# Title\\n\\nBody"}' --intent "Added a first note"`, ` ${cli} canvas list canvas ids (Home is the default canvas)`, ` ${cli} canvas add-node <canvasId> --note <displayId> --intent "Placed the first note"`, `Each reply carries a "url": give it to your user to open.`, "", `${cli} brief this workspace's standing rules and what it holds`, `${cli} --help every command`);
|
|
82
|
+
return lines;
|
|
83
|
+
}
|
package/dist/mcp-server.js
CHANGED
|
@@ -34,7 +34,7 @@ import { findOverlaps, layoutItemsFrom, resolveAnchor, suggestFreeSpot } from ".
|
|
|
34
34
|
import { boardChecks } from "./lib/board-checks.js";
|
|
35
35
|
import { buildSchema } from "./lib/build-schema.js";
|
|
36
36
|
import { assertMcpLocalFileReadable, getMcpLocalFileRoots, } from "./lib/mcp-local-file.js";
|
|
37
|
-
import {
|
|
37
|
+
import { attachTypes, loadRubricMap, rubricsForTypes, } from "./lib/rubrics.js";
|
|
38
38
|
import { lintNarratedVerbMentions, lintPlainTextDisplayIds, lintPlainTextDisplayIdsBatch, hasGenericMention, fetchRelationshipTypeOptions, } from "./lib/mention-lint.js";
|
|
39
39
|
import { DECISION_CARD_RULE } from "./lib/decision-citation.js";
|
|
40
40
|
import { parseReviewRef } from "./lib/review-helpers.js";
|
|
@@ -321,11 +321,10 @@ sharedTool("cnotes_notes_create", async ({ notes, intent }) => withErrorHandling
|
|
|
321
321
|
workspaceId,
|
|
322
322
|
notes: items,
|
|
323
323
|
}));
|
|
324
|
-
//
|
|
325
|
-
// the standard. Top-level rubrics kept for backward compatibility.
|
|
324
|
+
// Each used type's rubric once, under `rubrics`; each result carries its type.
|
|
326
325
|
const typeByKey = new Map(items.map((n) => [n.key, n.type]));
|
|
327
326
|
const rawResults = (result.results || []);
|
|
328
|
-
const enriched =
|
|
327
|
+
const enriched = attachTypes(rawResults, typeByKey);
|
|
329
328
|
const rubrics = rubricsForTypes(items.map((n) => String(n.type)), rubricMap);
|
|
330
329
|
return {
|
|
331
330
|
...result,
|
package/package.json
CHANGED
package/skills/cnotes/SKILL.md
CHANGED
|
@@ -61,7 +61,7 @@ When the writes belong together but cannot be one command (several notes and new
|
|
|
61
61
|
6. **Place declaratively, edit in place.** `canvas place` / `canvas arrange`, never hand-computed x/y. Add to a section with `place --into SECTION-n`; 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.
|
|
62
62
|
7. **Content changes are versions.** `cnotes versions create` changes a note's body; fetch the current body first and edit that, since people edit between sessions. `notes update` changes metadata only (type, tags, pin, archive).
|
|
63
63
|
8. **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 ([references/drafts.md](references/drafts.md)).
|
|
64
|
-
9. **Ask before spending something the user cannot get back:** `cnotes
|
|
64
|
+
9. **Ask before spending something the user cannot get back:** `cnotes feedback submit` files a report in their name, `cnotes types dimension backfill --yes` spends one model call per existing note. The owner's first write to a free workspace starts its one-time 7-day trial by itself (no card): when a write prints `note: this write started … trial` on stderr, say so in your reply, with the date it ends ([references/billing.md](references/billing.md)).
|
|
65
65
|
10. **Timeline headlines start with a past-tense verb and name the object** ("Shipped the public comic canvas", never "V1"): the `--intent`, an `operations begin --prompt`, a version `--description`, a milestone. A run headline (`--intent`, `--prompt`) is also a title: at most 80 characters, no ", so…" clause, detail after a blank line. The server refuses a run or milestone headline that breaks this. A milestone body, the lines after the headline, is at most 280 characters.
|
|
66
66
|
|
|
67
67
|
### Decisions
|
|
@@ -95,7 +95,7 @@ Every command follows one contract. Detail, including which key holds a note bod
|
|
|
95
95
|
| `7` | permission denied | `cnotes workspace current` |
|
|
96
96
|
| `8` | subscription required (writes on a free workspace) | [references/billing.md](references/billing.md); offer `cnotes upgrade`, never run it unasked |
|
|
97
97
|
|
|
98
|
-
Reads return data (`notes list/get/search` emit a bare array; one note is `.[0]`); writes return an envelope (`notes create` returns `{ results, relationshipsCreated, rubrics?, hints? }`). Errors go to stderr as `{ error, code, exitCode, hint }`; read the hint before retrying. Display IDs (`DECISION-12`, `CANVAS-406`, `SECTION-7`) work everywhere a command takes an id.
|
|
98
|
+
Reads return data (`notes list/get/search` emit a bare array; one note is `.[0]`); writes return an envelope (`notes create` returns `{ results, relationshipsCreated, rubrics?, next?, hints? }`). Errors go to stderr as `{ error, code, exitCode, hint }`; read the hint before retrying. Display IDs (`DECISION-12`, `CANVAS-406`, `SECTION-7`) work everywhere a command takes an id.
|
|
99
99
|
|
|
100
100
|
## Getting started
|
|
101
101
|
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
# Paid actions and workspaces
|
|
2
2
|
|
|
3
|
-
Read this when a write fails with exit `8` (`subscription_required`) or the user wants another workspace.
|
|
3
|
+
Read this when a write fails with exit `8` (`subscription_required`), a write prints `note: this write started … trial`, or the user wants another workspace.
|
|
4
4
|
|
|
5
5
|
## Paid actions (writes need Pro)
|
|
6
6
|
|
|
7
|
-
Reads work on any plan. **CLI/API writes
|
|
7
|
+
Reads work on any plan. **CLI/API writes need the target workspace on Pro or in its free trial**; a refused write is exit `8`, `serverCode: "subscription_required"`. There are three distinct cases, and only two of them need a human. Do not collapse them into "tell the user to go pay."
|
|
8
8
|
|
|
9
|
-
**Wall 1: free workspace
|
|
9
|
+
**Wall 1: a free workspace. The owner's first write starts the trial by itself.**
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
When the key's owner owns the workspace and its one-time trial is unused, the first CLI or API write **goes through and starts the free 7-day Pro trial** (no credit card). You do nothing and nothing is refused. The CLI prints one line on stderr when that happens:
|
|
12
12
|
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
cnotes upgrade -w <id> # target a specific workspace
|
|
13
|
+
```
|
|
14
|
+
note: this write started the workspace's free 7-day Pro trial (no card needed). It ends on 2026-12-06. ...
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
**
|
|
19
|
-
|
|
20
|
-
> "This workspace is on the free plan, so I can't write to it. Want me to start your free 7-day Pro trial (no credit card)?"
|
|
17
|
+
**Tell the user in your reply** when you see it: nobody asked for the trial, it is one-time, and after it ends CLI and API writes need Pro. Say when it ends.
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
`cnotes upgrade` still exists and starts the same trial without writing anything (`-w <id>` targets a workspace). You only meet exit `8` on a free workspace when the caller is not its owner (below) or the trial is used (Wall 2).
|
|
23
20
|
|
|
24
21
|
**Wall 2: trial already used. A human must pay.**
|
|
25
22
|
|
|
@@ -27,7 +24,7 @@ On yes: run `cnotes upgrade`, then retry the write. That's the whole flow.
|
|
|
27
24
|
|
|
28
25
|
**Wall 3: they want an ADDITIONAL workspace. Human pays at checkout.**
|
|
29
26
|
|
|
30
|
-
`cnotes workspace create` **buys a new workspace**, it is not the fix for a blocked write on the current one (that's Wall 1). Only reach for it when the user actually asks for another workspace.
|
|
27
|
+
`cnotes workspace create` **buys a new workspace**, it is not the fix for a blocked write on the current one (that's Wall 1 or 2). Only reach for it when the user actually asks for another workspace.
|
|
31
28
|
|
|
32
29
|
```bash
|
|
33
30
|
cnotes workspace create "Acme Research" --json # returns { checkoutUrl, sessionId }
|
|
@@ -121,7 +121,7 @@ cnotes notes create --notes '[
|
|
|
121
121
|
# On validation failure the response lists every bad item by index + key + field
|
|
122
122
|
# (and `details.items` in --json mode), so you can fix the whole batch in one shot.
|
|
123
123
|
# Same batch again in the same run returns the first notes (alreadyExists: true), not a copy; after a reset or 5xx (`mayHaveCommitted: true`) re-run with the printed `--idempotency-key`.
|
|
124
|
-
# Each .results[] item carries .type
|
|
124
|
+
# Each .results[] item carries .type; each used type's rubric is under the top-level .rubrics, once. Keep both when filtering JSON.
|
|
125
125
|
# Where the deployment turns the rubric check on, each item also carries
|
|
126
126
|
# .quality: {level 1-4, label, missing[], nextStep, unsure}. `missing` quotes the
|
|
127
127
|
# rubric clauses the note does not yet do, weakest first. Fix those with
|
|
@@ -5,7 +5,7 @@ The one contract every command follows is in the core skill (the flag table and
|
|
|
5
5
|
## Reads return data, writes return an envelope
|
|
6
6
|
|
|
7
7
|
- `notes list`, `notes get` and `notes search` emit a bare array, so one note is `.[0]`. `notes get --expand` is the exception: an object `{ notes, linked, truncated, cap, omitted, notice }` (notes.md).
|
|
8
|
-
- `notes create` returns `{ results, relationshipsCreated, rubrics?, hints? }`; read new notes from `results`. Each row carries `type`, `
|
|
8
|
+
- `notes create` returns `{ results, relationshipsCreated, rubrics?, hints? }`; read new notes from `results`. Each row carries `type`, `url`, and `quality` where the workspace grades on save; each used type's rubric is in `rubrics`, once.
|
|
9
9
|
- `canvas create` returns `{ canvas: { id, displayId, url } }` with `id`, `displayId` and `url` mirrored at the top level; after `create --spec` the placement is under `layout`, and `displayId` can still be null until `canvas get` reads it.
|
|
10
10
|
- `canvas place` returns `{ items, edges, bbox, successCount, notes?, arrangedSections? }`. It is best-effort, not transactional (HTTP 207): read `items[].error` and `edges[].error` before assuming success. A `quote` item adds `quoteNoteDisplayId`, `noteDisplayId`, `versionNumber` and `placed`.
|
|
11
11
|
- A note body comes back under `markdown` from `canvas read` and under `content` from `notes get --json`; read the key for the command you ran. A `canvas read` whose JSON starts with `level: "cards"` or `"frames"` is a map of a long board: each frame lists its cards under `lines`, with no bodies; `next` names the commands that open a frame, chosen notes or (`--full`) every body. `notes get --content-only` prints the raw markdown with no envelope, the right read for a transcript.
|