@creator-notes/cnotes 0.80.0 → 0.82.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.
Files changed (79) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +1 -0
  3. package/dist/commands/auth-keys.js +2 -2
  4. package/dist/commands/auth-keys.js.map +1 -1
  5. package/dist/commands/brief.js +1 -1
  6. package/dist/commands/brief.js.map +1 -1
  7. package/dist/commands/canvas-milestone.js +3 -3
  8. package/dist/commands/canvas-milestone.js.map +1 -1
  9. package/dist/commands/canvas.js +43 -43
  10. package/dist/commands/canvas.js.map +1 -1
  11. package/dist/commands/deps.js +3 -3
  12. package/dist/commands/deps.js.map +1 -1
  13. package/dist/commands/draft.d.ts.map +1 -1
  14. package/dist/commands/draft.js +301 -141
  15. package/dist/commands/draft.js.map +1 -1
  16. package/dist/commands/feedback.js +3 -3
  17. package/dist/commands/feedback.js.map +1 -1
  18. package/dist/commands/files.js +3 -3
  19. package/dist/commands/files.js.map +1 -1
  20. package/dist/commands/focus.js +3 -3
  21. package/dist/commands/focus.js.map +1 -1
  22. package/dist/commands/init.js +1 -1
  23. package/dist/commands/init.js.map +1 -1
  24. package/dist/commands/notes.js +12 -12
  25. package/dist/commands/notes.js.map +1 -1
  26. package/dist/commands/operations.js +4 -4
  27. package/dist/commands/operations.js.map +1 -1
  28. package/dist/commands/quality.js +1 -1
  29. package/dist/commands/quality.js.map +1 -1
  30. package/dist/commands/relationships.d.ts +5 -0
  31. package/dist/commands/relationships.d.ts.map +1 -1
  32. package/dist/commands/relationships.js +13 -8
  33. package/dist/commands/relationships.js.map +1 -1
  34. package/dist/commands/review.d.ts.map +1 -1
  35. package/dist/commands/review.js +10 -7
  36. package/dist/commands/review.js.map +1 -1
  37. package/dist/commands/schema.js +1 -1
  38. package/dist/commands/schema.js.map +1 -1
  39. package/dist/commands/search.js +2 -2
  40. package/dist/commands/search.js.map +1 -1
  41. package/dist/commands/shared.js +1 -1
  42. package/dist/commands/shared.js.map +1 -1
  43. package/dist/commands/theme.js +5 -5
  44. package/dist/commands/theme.js.map +1 -1
  45. package/dist/commands/timeline.js +1 -1
  46. package/dist/commands/timeline.js.map +1 -1
  47. package/dist/commands/types.js +4 -4
  48. package/dist/commands/types.js.map +1 -1
  49. package/dist/commands/upgrade.js +1 -1
  50. package/dist/commands/upgrade.js.map +1 -1
  51. package/dist/commands/versions.js +2 -2
  52. package/dist/commands/versions.js.map +1 -1
  53. package/dist/commands/workspace.d.ts.map +1 -1
  54. package/dist/commands/workspace.js +90 -9
  55. package/dist/commands/workspace.js.map +1 -1
  56. package/dist/lib/api-client.d.ts +19 -1
  57. package/dist/lib/api-client.d.ts.map +1 -1
  58. package/dist/lib/api-client.js +32 -2
  59. package/dist/lib/api-client.js.map +1 -1
  60. package/dist/lib/config.d.ts +14 -0
  61. package/dist/lib/config.d.ts.map +1 -1
  62. package/dist/lib/config.js +20 -5
  63. package/dist/lib/config.js.map +1 -1
  64. package/dist/lib/draft-view.d.ts +306 -0
  65. package/dist/lib/draft-view.d.ts.map +1 -0
  66. package/dist/lib/draft-view.js +358 -0
  67. package/dist/lib/draft-view.js.map +1 -0
  68. package/dist/lib/errors.d.ts +6 -0
  69. package/dist/lib/errors.d.ts.map +1 -1
  70. package/dist/lib/errors.js +64 -1
  71. package/dist/lib/errors.js.map +1 -1
  72. package/dist/lib/urls.d.ts +15 -0
  73. package/dist/lib/urls.d.ts.map +1 -1
  74. package/dist/lib/urls.js +20 -0
  75. package/dist/lib/urls.js.map +1 -1
  76. package/dist/mcp-server.js +5 -1
  77. package/dist/mcp-server.js.map +1 -1
  78. package/package.json +1 -1
  79. package/skills/cnotes/SKILL.md +86 -60
@@ -0,0 +1,306 @@
1
+ import type { DraftRow } from "./draft-ref.js";
2
+ import type { WorkspaceOverrides } from "./config.js";
3
+ /** The sentence every draft surface ends on while it waits for a person. */
4
+ export declare const PERSON_LANDS_IT = "Nothing lands until a person approves it in the browser.";
5
+ /** Printed when a draft is opened or resumed. */
6
+ export declare const PRIVATE_UNTIL_APPROVED = "Only you can see it. Nothing lands until a person approves it in the browser.";
7
+ /** Who the draft waits on, and the one sentence the CLI, pill and strip show. */
8
+ export interface DraftDecision {
9
+ state: "awaiting_person" | "changes_requested" | "waiting_on_reviewer";
10
+ reviewerName: string | null;
11
+ reviewerUserId: string | null;
12
+ rationale: string | null;
13
+ at: number | null;
14
+ requestId: string | null;
15
+ line: string;
16
+ }
17
+ /**
18
+ * What the CLI knows about a decision. `requestId` is null when the owner
19
+ * holds no live round of their own (nobody was asked, not even themselves);
20
+ * left out, the CLI does not know, and says only what it does.
21
+ */
22
+ export type DecisionFacts = Pick<DraftDecision, "state" | "reviewerName" | "rationale"> & {
23
+ requestId?: string | null;
24
+ };
25
+ /**
26
+ * What the CLI's reader does next, or null when a person already has the
27
+ * draft. Sent back: fix it and ask again, because the send-back ended the
28
+ * reviewer's round and with it their view of the draft. Nobody asked: ask,
29
+ * because until then only the owner can open the draft or its proposal.
30
+ * Both end at "stop": what lands is a person's call.
31
+ */
32
+ export declare function nextStep(decision: Pick<DecisionFacts, "state" | "reviewerName" | "requestId">): string | null;
33
+ /**
34
+ * Where the draft stands and what to do about it, in the CLI's own words. The
35
+ * CLI's reader is usually an agent, so this is built from the decision's
36
+ * state, not copied from the server's `line`: it says where the decision is
37
+ * made, points at `draft ask` when nobody has the draft, and never tells its
38
+ * reader to press a button or run a command that decides the draft.
39
+ */
40
+ export declare function decisionSentence(decision: DecisionFacts, onBoard?: boolean): string;
41
+ /**
42
+ * A 404 from a draft route when the caller named no draft means the active
43
+ * workspace is not one of their open drafts, and says so. A 404 about
44
+ * something else in the request (the reviewer of an ask, a note, a proposal)
45
+ * keeps the server's sentence, which says what to fix: it names its
46
+ * `resource`, or reads "<Thing> not found".
47
+ */
48
+ export declare function notADraft(error: unknown, named: boolean): unknown;
49
+ /**
50
+ * The draft record with `decision.line` in the CLI's words, for --json output:
51
+ * an agent parsing JSON reads that line as surely as one reading the terminal.
52
+ */
53
+ export declare function spokenDetail<T extends Pick<DraftDetail, "decision" | "branch">>(detail: T): T;
54
+ export interface DraftRound {
55
+ requestId: string;
56
+ status: string;
57
+ outcome: "approved" | "changes_requested" | null;
58
+ rationale: string | null;
59
+ createdAt: number;
60
+ submittedAt: number | null;
61
+ canvasViewId: string;
62
+ }
63
+ /** Set when the draft is a proposed version of a shared canvas. */
64
+ export interface DraftBranch {
65
+ branchCanvasId: string;
66
+ sourceCanvasId: string;
67
+ baseLabel: string | null;
68
+ branchedAt: number | null;
69
+ }
70
+ export interface DraftMerge {
71
+ mergeId: string;
72
+ mergedAt: number;
73
+ undoneAt: number | null;
74
+ appliedEdits: number;
75
+ /** The person who approved it in the browser; null for merges made before that rule. */
76
+ acceptedByName: string | null;
77
+ /** Ids the shared workspace already held, re-minted at merge (mentions rewritten). */
78
+ renamed: {
79
+ from: string;
80
+ to: string;
81
+ }[];
82
+ }
83
+ /** `GET /api/workspace-drafts/<id>`. */
84
+ export interface DraftDetail {
85
+ draft: DraftRow;
86
+ noteCount: number;
87
+ canvasCount: number;
88
+ pendingEditCount: number;
89
+ firstCanvasId: string | null;
90
+ round: DraftRound | null;
91
+ decision: DraftDecision;
92
+ role: "owner" | "reviewer";
93
+ branch: DraftBranch | null;
94
+ merge: DraftMerge | null;
95
+ }
96
+ export interface Finding {
97
+ code: string;
98
+ blocking: boolean;
99
+ displayId: string;
100
+ title: string;
101
+ message: string;
102
+ fix: string;
103
+ }
104
+ export interface DraftChecks {
105
+ findings: Finding[];
106
+ blocking: number;
107
+ warnings: number;
108
+ notesChecked: number;
109
+ editsChecked: number;
110
+ revision?: string;
111
+ }
112
+ /** `GET /api/workspace-drafts/<id>/checks`. */
113
+ export interface ChecksResponse {
114
+ checks: DraftChecks;
115
+ round: DraftRound | null;
116
+ /** The first blocking check as one sentence, or null when none blocks. */
117
+ blockedBy: string | null;
118
+ decision: DraftDecision;
119
+ }
120
+ export interface EditRow {
121
+ editId: string;
122
+ noteId: string;
123
+ noteDisplayId: string;
124
+ title: string;
125
+ currentTitle: string;
126
+ baseVersionNumber: number;
127
+ currentVersionNumber: number;
128
+ conflict: boolean;
129
+ status: "pending" | "applied" | "discarded";
130
+ changeDescription: string | null;
131
+ appliedVersionNumber: number | null;
132
+ updatedAt: number;
133
+ }
134
+ /**
135
+ * Where a person decides the draft, in the browser. A proposed version of a
136
+ * shared board is decided on that board, in the shared workspace, which opens
137
+ * with the proposal drawn over it. Any other draft is decided from the draft
138
+ * itself, opened at its first canvas.
139
+ */
140
+ export declare function draftLink(serverUrl: string, detail: Pick<DraftDetail, "draft" | "firstCanvasId" | "branch">): string;
141
+ /** "Draft of Private · Pricing rethink · Rework tiers for teams" (the intent only when set). */
142
+ export declare function draftOfLine(parentName: string, name: string, intent: string | null | undefined): string;
143
+ /** What V2 changes on its live board, counted (convex/lib/canvasBranch.ts). */
144
+ export interface BranchCounts {
145
+ added: number;
146
+ removed: number;
147
+ moved: number;
148
+ resized: number;
149
+ edited: number;
150
+ linksAdded: number;
151
+ linksRemoved: number;
152
+ conflicts: number;
153
+ }
154
+ /** One change V2 makes to the live board, keyed to live ids where they exist. */
155
+ export interface BranchChangeRow {
156
+ kind: "added" | "removed" | "modified";
157
+ entityTable: string;
158
+ liveId: string | null;
159
+ branchId: string | null;
160
+ groups: string[];
161
+ conflict: null | {
162
+ reason: string;
163
+ message: string;
164
+ };
165
+ label: string;
166
+ noteId?: string;
167
+ }
168
+ /** `GET /api/workspace-drafts/<id>/branch`: the copy against the live board, three ways. */
169
+ export interface BranchView {
170
+ sourceCanvasId: string;
171
+ branchCanvasId: string;
172
+ changes: BranchChangeRow[];
173
+ counts: BranchCounts;
174
+ /** Live entities changed since the branch that V2 did not touch. */
175
+ liveChangedSinceBranch: number;
176
+ fingerprint: string;
177
+ /** The live board was archived or deleted since the branch. */
178
+ sourceGone: boolean;
179
+ /** CANVAS-n of the live board; null when the route could not name it. */
180
+ sourceDisplayId: string | null;
181
+ /** CANVAS-m of the copy in the draft. */
182
+ branchDisplayId: string | null;
183
+ }
184
+ /** `POST /api/workspace-drafts` with `fromCanvas`: the board branched into the new draft. */
185
+ export interface OpenedBranch {
186
+ canvasId: string;
187
+ displayId: string;
188
+ sourceCanvasId: string;
189
+ sourceDisplayId: string;
190
+ sourceName: string;
191
+ /** "V1", "V1 plus 4 unsaved changes", or "no milestone yet". */
192
+ baseLabel: string;
193
+ copied: number;
194
+ }
195
+ /**
196
+ * The one sentence `draft open --from-canvas` prints: what was branched, at
197
+ * which version, where the copy is, and that nobody else sees it.
198
+ */
199
+ export declare function branchOpenedSentence(branch: OpenedBranch): string;
200
+ /**
201
+ * "2 added, 5 moved, 2 removed, 3 links, 1 reworded": what V2 does to the
202
+ * live board, plus the shared notes it rewords (pending proposed edits).
203
+ * Only what is non-zero is named.
204
+ */
205
+ export declare function branchCountsPhrase(counts: BranchCounts, reworded: number): string;
206
+ /**
207
+ * The branch block of `draft status`: the counts, then each conflict in the
208
+ * server's words, then what moved under it on the live board.
209
+ */
210
+ export declare function branchLines(view: BranchView, reworded: number): string[];
211
+ /** The branch block for --json: the same facts, with each conflict's card and reason. */
212
+ export declare function branchSummary(view: BranchView, reworded: number): {
213
+ line: string;
214
+ board: string | null;
215
+ copy: string | null;
216
+ sourceCanvasId: string;
217
+ branchCanvasId: string;
218
+ counts: BranchCounts;
219
+ reworded: number;
220
+ conflicts: {
221
+ label: string;
222
+ reason: string;
223
+ message: string;
224
+ }[];
225
+ liveChangedSinceBranch: number;
226
+ sourceGone: boolean;
227
+ };
228
+ /** `POST /api/workspace-drafts/<id>` with action "ask". */
229
+ export interface AskResult {
230
+ asked: true;
231
+ requestId: string;
232
+ reviewerUserId: string;
233
+ reviewerName: string;
234
+ isSelf: boolean;
235
+ anchorCanvasId: string;
236
+ /** Where the person decides; null when the server could not build it. */
237
+ link: string | null;
238
+ }
239
+ /**
240
+ * What `draft ask` prints: who decides and where. An agent is told to stop,
241
+ * because what happens next is a person's call.
242
+ */
243
+ export declare function askedLines(input: {
244
+ reviewerName: string;
245
+ link: string | null;
246
+ agent: boolean;
247
+ }): string[];
248
+ /** A key's refused merge: the server's sentence and who the draft waits on. */
249
+ export interface ApprovalRefusal {
250
+ message: string;
251
+ draftId?: string;
252
+ state?: string;
253
+ waitingOn?: string;
254
+ canvasId?: string;
255
+ }
256
+ /**
257
+ * The server's answer to `draft merge` from a key: 403 with reason
258
+ * `human_approval_required`. Null for any other error, which the caller
259
+ * reports as usual. The meta rides at the top level of the body; a nested
260
+ * `meta` is read too.
261
+ */
262
+ export declare function approvalRefusal(error: unknown): ApprovalRefusal | null;
263
+ /**
264
+ * What `draft merge` says when the server refuses a key: where the draft
265
+ * stands. Built from the refusal's data and, when it could be read, the
266
+ * draft's decision (which carries what was asked for); never the server's
267
+ * sentence, so it never offers another way to merge. What to do next is the
268
+ * hint's ({@link mergeRefusalHint}), so the two never say it twice.
269
+ */
270
+ export declare function refusalMessage(refusal: ApprovalRefusal, decision?: DraftDecision | null): string;
271
+ /**
272
+ * The hint under a refused `draft merge`. While a named person decides, the
273
+ * link is all there is to hand over. Otherwise nobody has been asked yet (or
274
+ * they sent it back), and asking is what puts the draft in front of a person:
275
+ * without an ask, anyone but its owner given only the link sees nothing of a
276
+ * branch (the ask is their read grant).
277
+ */
278
+ export declare function mergeRefusalHint(refusal: ApprovalRefusal, decision: DraftDecision | null | undefined, url: string | null): string;
279
+ /**
280
+ * Say so when a saved switch into `target` does not take effect: the `-w`
281
+ * flag and CNOTES_WORKSPACE both beat the saved active workspace. Null when
282
+ * nothing shadows it. `label` turns a workspace id into what to print, and
283
+ * `place` names the target in the closing sentence.
284
+ */
285
+ export declare function shadowNotice(target: string, overrides: WorkspaceOverrides, label?: (workspaceId: string) => string, place?: string): string | null;
286
+ /** The headline of `draft status`: where the draft stands, in one sentence. */
287
+ export declare function statusHeadline(detail: DraftDetail): string;
288
+ export interface StatusInput {
289
+ serverUrl: string;
290
+ detail: DraftDetail;
291
+ checks: ChecksResponse | null;
292
+ edits: EditRow[] | null;
293
+ /** The workspace the CLI works in now, to say how to leave a closed draft. */
294
+ activeWorkspaceId?: string;
295
+ /** For a branch draft: what V2 changes on the live board. */
296
+ branch?: BranchView | null;
297
+ /** For a branch draft whose comparison could not be read: why. */
298
+ branchError?: string | null;
299
+ }
300
+ /**
301
+ * Every line `cnotes draft status` prints. The decision comes first, because
302
+ * it is what an agent acts on: fix what was asked, or stop and hand over the
303
+ * link. Merge is never offered: a key cannot merge.
304
+ */
305
+ export declare function statusLines({ serverUrl, detail, checks, edits, activeWorkspaceId, branch, branchError, }: StatusInput): string[];
306
+ //# sourceMappingURL=draft-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft-view.d.ts","sourceRoot":"","sources":["../../src/lib/draft-view.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,4EAA4E;AAC5E,eAAO,MAAM,eAAe,6DAA6D,CAAC;AAE1F,iDAAiD;AACjD,eAAO,MAAM,sBAAsB,kFAA4C,CAAC;AAEhF,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,iBAAiB,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;IACvE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAKD;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,cAAc,GAAG,WAAW,CAAC,GAAG;IACxF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI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B,MAAM,GAAG,IAAI,CAQf;AAOD,+EAA+E;AAC/E,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAW1D;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACxB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAC1B,SAAS,EACT,MAAM,EACN,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,MAAM,EACN,WAAW,GACZ,EAAE,WAAW,GAAG,MAAM,EAAE,CAkExB"}
@@ -0,0 +1,358 @@
1
+ /**
2
+ * How the CLI shows a draft: who it waits on, the link a person opens to
3
+ * decide it, and whether a saved switch into it actually took.
4
+ *
5
+ * A draft lands in the shared workspace only when a person approves it in a
6
+ * browser. No key can merge or approve it, so every surface here ends at the
7
+ * same place: the server's one-sentence decision line and the link to hand
8
+ * that person. Pure functions, so the wording is pinned by tests.
9
+ */
10
+ import { ApiError, NotFoundError } from "./errors.js";
11
+ import { canvasUrl, proposalUrl, workspaceUrl } from "./urls.js";
12
+ import { timeAgo } from "./output.js";
13
+ /** The sentence every draft surface ends on while it waits for a person. */
14
+ export const PERSON_LANDS_IT = "Nothing lands until a person approves it in the browser.";
15
+ /** Printed when a draft is opened or resumed. */
16
+ export const PRIVATE_UNTIL_APPROVED = `Only you can see it. ${PERSON_LANDS_IT}`;
17
+ /** The command that hands a draft to the person who decides it. */
18
+ const ASK_COMMAND = "`cnotes draft ask --reviewer <email|me>`";
19
+ /** Where the draft stands: who holds it, and what they asked for. */
20
+ function standing(decision, onBoard) {
21
+ if (decision.state === "changes_requested") {
22
+ const who = decision.reviewerName ?? "the reviewer";
23
+ const why = decision.rationale?.trim();
24
+ return `Changes requested by ${who}${why ? `: ${why}${/[.!?]$/.test(why) ? "" : "."}` : "."}`;
25
+ }
26
+ if (decision.state === "waiting_on_reviewer") {
27
+ return `Waiting on ${decision.reviewerName ?? "a reviewer"} to decide in the browser. Nothing lands until they do.`;
28
+ }
29
+ if (decision.requestId === null)
30
+ return "Nobody has been asked to decide it yet.";
31
+ return onBoard
32
+ ? "Waiting for a person to accept it as the next version of the board, in the browser."
33
+ : "Waiting for a person to approve it in the browser.";
34
+ }
35
+ /**
36
+ * What the CLI's reader does next, or null when a person already has the
37
+ * draft. Sent back: fix it and ask again, because the send-back ended the
38
+ * reviewer's round and with it their view of the draft. Nobody asked: ask,
39
+ * because until then only the owner can open the draft or its proposal.
40
+ * Both end at "stop": what lands is a person's call.
41
+ */
42
+ export function nextStep(decision) {
43
+ if (decision.state === "waiting_on_reviewer")
44
+ return null;
45
+ if (decision.state === "changes_requested") {
46
+ return `Make the changes in the draft, then ask ${decision.reviewerName ?? "the reviewer"} again with ${ASK_COMMAND}, and stop.`;
47
+ }
48
+ // The owner's own live round: they asked themselves, or have it open now.
49
+ if (typeof decision.requestId === "string")
50
+ return null;
51
+ return `When no check blocks, name who decides with ${ASK_COMMAND}, then stop.`;
52
+ }
53
+ /**
54
+ * Where the draft stands and what to do about it, in the CLI's own words. The
55
+ * CLI's reader is usually an agent, so this is built from the decision's
56
+ * state, not copied from the server's `line`: it says where the decision is
57
+ * made, points at `draft ask` when nobody has the draft, and never tells its
58
+ * reader to press a button or run a command that decides the draft.
59
+ */
60
+ export function decisionSentence(decision, onBoard = false) {
61
+ return [standing(decision, onBoard), nextStep(decision)].filter(Boolean).join(" ");
62
+ }
63
+ /**
64
+ * A 404 from a draft route when the caller named no draft means the active
65
+ * workspace is not one of their open drafts, and says so. A 404 about
66
+ * something else in the request (the reviewer of an ask, a note, a proposal)
67
+ * keeps the server's sentence, which says what to fix: it names its
68
+ * `resource`, or reads "<Thing> not found".
69
+ */
70
+ export function notADraft(error, named) {
71
+ if (named || !(error instanceof ApiError) || error.status !== 404)
72
+ return error;
73
+ const resource = typeof error.body.resource === "string" ? error.body.resource : null;
74
+ if (resource !== null && resource.toLowerCase() !== "draft")
75
+ return error;
76
+ const message = typeof error.body.error === "string" ? error.body.error.trim() : "";
77
+ const thing = /^(.+) not found\.?$/i.exec(message)?.[1];
78
+ if (resource === null && thing && thing.toLowerCase() !== "draft")
79
+ return error;
80
+ return new NotFoundError("The active workspace is not one of your open drafts", "Name one (`cnotes draft status <draft>`) or run `cnotes draft list`");
81
+ }
82
+ /**
83
+ * The draft record with `decision.line` in the CLI's words, for --json output:
84
+ * an agent parsing JSON reads that line as surely as one reading the terminal.
85
+ */
86
+ export function spokenDetail(detail) {
87
+ return { ...detail, decision: { ...detail.decision, line: decisionSentence(detail.decision, Boolean(detail.branch)) } };
88
+ }
89
+ /**
90
+ * Where a person decides the draft, in the browser. A proposed version of a
91
+ * shared board is decided on that board, in the shared workspace, which opens
92
+ * with the proposal drawn over it. Any other draft is decided from the draft
93
+ * itself, opened at its first canvas.
94
+ */
95
+ export function draftLink(serverUrl, detail) {
96
+ if (detail.branch) {
97
+ return proposalUrl(serverUrl, detail.draft.parentWorkspaceId, detail.branch.sourceCanvasId, detail.draft.id);
98
+ }
99
+ if (detail.firstCanvasId)
100
+ return canvasUrl(serverUrl, detail.draft.id, detail.firstCanvasId);
101
+ return workspaceUrl(serverUrl, detail.draft.id);
102
+ }
103
+ /** "Draft of Private · Pricing rethink · Rework tiers for teams" (the intent only when set). */
104
+ export function draftOfLine(parentName, name, intent) {
105
+ const parts = [`Draft of ${parentName}`, name];
106
+ if (intent && intent.trim())
107
+ parts.push(intent.trim());
108
+ return parts.join(" · ");
109
+ }
110
+ /**
111
+ * The one sentence `draft open --from-canvas` prints: what was branched, at
112
+ * which version, where the copy is, and that nobody else sees it.
113
+ */
114
+ export function branchOpenedSentence(branch) {
115
+ const live = branch.sourceDisplayId || `"${branch.sourceName}"`;
116
+ const copy = branch.displayId || "the draft's first canvas";
117
+ const at = branch.baseLabel === "no milestone yet" ? ", which has no milestone yet" : ` at ${branch.baseLabel}`;
118
+ return `Branched ${live}${at}. Your working copy in this draft is ${copy}. The live board has not changed, and only you can see this draft.`;
119
+ }
120
+ /**
121
+ * "2 added, 5 moved, 2 removed, 3 links, 1 reworded": what V2 does to the
122
+ * live board, plus the shared notes it rewords (pending proposed edits).
123
+ * Only what is non-zero is named.
124
+ */
125
+ export function branchCountsPhrase(counts, reworded) {
126
+ const parts = [];
127
+ if (counts.added)
128
+ parts.push(`${counts.added} added`);
129
+ if (counts.moved)
130
+ parts.push(`${counts.moved} moved`);
131
+ if (counts.resized)
132
+ parts.push(`${counts.resized} resized`);
133
+ if (counts.edited)
134
+ parts.push(`${counts.edited} edited`);
135
+ if (counts.removed)
136
+ parts.push(`${counts.removed} removed`);
137
+ if (counts.linksAdded)
138
+ parts.push(count(counts.linksAdded, "link", "links"));
139
+ if (counts.linksRemoved)
140
+ parts.push(`${count(counts.linksRemoved, "link", "links")} removed`);
141
+ if (reworded)
142
+ parts.push(`${reworded} reworded`);
143
+ return parts.length > 0 ? parts.join(", ") : "no changes yet";
144
+ }
145
+ /**
146
+ * The branch block of `draft status`: the counts, then each conflict in the
147
+ * server's words, then what moved under it on the live board.
148
+ */
149
+ export function branchLines(view, reworded) {
150
+ const board = view.sourceDisplayId || "the live board";
151
+ const lines = [`V2 of ${board}: ${branchCountsPhrase(view.counts, reworded)}`];
152
+ for (const change of view.changes) {
153
+ if (change.conflict)
154
+ lines.push(` Conflict: ${change.conflict.message}`);
155
+ }
156
+ if (view.liveChangedSinceBranch > 0) {
157
+ lines.push(` ${count(view.liveChangedSinceBranch, "card", "cards")} changed on the live board since you branched.`);
158
+ }
159
+ if (view.sourceGone)
160
+ lines.push(" The live board was archived.");
161
+ return lines;
162
+ }
163
+ /** The branch block for --json: the same facts, with each conflict's card and reason. */
164
+ export function branchSummary(view, reworded) {
165
+ return {
166
+ line: branchLines(view, reworded)[0],
167
+ board: view.sourceDisplayId,
168
+ copy: view.branchDisplayId,
169
+ sourceCanvasId: view.sourceCanvasId,
170
+ branchCanvasId: view.branchCanvasId,
171
+ counts: view.counts,
172
+ reworded,
173
+ conflicts: view.changes
174
+ .filter((c) => c.conflict)
175
+ .map((c) => ({ label: c.label, reason: c.conflict.reason, message: c.conflict.message })),
176
+ liveChangedSinceBranch: view.liveChangedSinceBranch,
177
+ sourceGone: view.sourceGone,
178
+ };
179
+ }
180
+ /**
181
+ * What `draft ask` prints: who decides and where. An agent is told to stop,
182
+ * because what happens next is a person's call.
183
+ */
184
+ export function askedLines(input) {
185
+ const where = input.link ? `, in a browser: ${input.link}` : ", in a browser. cnotes draft status prints the link.";
186
+ const lines = [`Asked ${input.reviewerName}. Only a person can accept it${where}`];
187
+ if (input.agent)
188
+ lines.push(`Stop here; ${input.reviewerName} decides.`);
189
+ return lines;
190
+ }
191
+ /**
192
+ * The server's answer to `draft merge` from a key: 403 with reason
193
+ * `human_approval_required`. Null for any other error, which the caller
194
+ * reports as usual. The meta rides at the top level of the body; a nested
195
+ * `meta` is read too.
196
+ */
197
+ export function approvalRefusal(error) {
198
+ if (!(error instanceof ApiError) || error.reason !== "human_approval_required")
199
+ return null;
200
+ const body = error.body ?? {};
201
+ const meta = body.meta && typeof body.meta === "object" ? body.meta : {};
202
+ const pick = (key) => {
203
+ const value = body[key] ?? meta[key];
204
+ return typeof value === "string" && value ? value : undefined;
205
+ };
206
+ return {
207
+ message: typeof body.error === "string" && body.error ? body.error : error.message,
208
+ draftId: pick("draftId"),
209
+ state: pick("state"),
210
+ waitingOn: pick("waitingOn"),
211
+ canvasId: pick("canvasId"),
212
+ };
213
+ }
214
+ const KNOWN_STATES = ["awaiting_person", "changes_requested", "waiting_on_reviewer"];
215
+ /**
216
+ * The decision a refused `draft merge` speaks from: the draft's own when it
217
+ * could be read, else what the refusal carries. The refusal cannot say
218
+ * whether anyone holds the draft, so `requestId` stays unknown.
219
+ */
220
+ function refusalDecision(refusal, decision) {
221
+ return (decision ?? {
222
+ state: KNOWN_STATES.find((s) => s === refusal.state) ?? "awaiting_person",
223
+ reviewerName: refusal.waitingOn ?? null,
224
+ rationale: null,
225
+ });
226
+ }
227
+ /**
228
+ * What `draft merge` says when the server refuses a key: where the draft
229
+ * stands. Built from the refusal's data and, when it could be read, the
230
+ * draft's decision (which carries what was asked for); never the server's
231
+ * sentence, so it never offers another way to merge. What to do next is the
232
+ * hint's ({@link mergeRefusalHint}), so the two never say it twice.
233
+ */
234
+ export function refusalMessage(refusal, decision) {
235
+ return `A key cannot merge a draft. ${standing(refusalDecision(refusal, decision), Boolean(refusal.canvasId))}`;
236
+ }
237
+ /**
238
+ * The hint under a refused `draft merge`. While a named person decides, the
239
+ * link is all there is to hand over. Otherwise nobody has been asked yet (or
240
+ * they sent it back), and asking is what puts the draft in front of a person:
241
+ * without an ask, anyone but its owner given only the link sees nothing of a
242
+ * branch (the ask is their read grant).
243
+ */
244
+ export function mergeRefusalHint(refusal, decision, url) {
245
+ const facts = refusalDecision(refusal, decision);
246
+ if (facts.state === "waiting_on_reviewer") {
247
+ return url ? `Link to give the person who decides it: ${url}` : "The person who decides it does so in the browser.";
248
+ }
249
+ const parts = [nextStep(facts), url ? `Link: ${url}` : null].filter(Boolean);
250
+ return parts.length > 0 ? parts.join(" ") : "The person who decides it does so in the browser.";
251
+ }
252
+ /**
253
+ * Say so when a saved switch into `target` does not take effect: the `-w`
254
+ * flag and CNOTES_WORKSPACE both beat the saved active workspace. Null when
255
+ * nothing shadows it. `label` turns a workspace id into what to print, and
256
+ * `place` names the target in the closing sentence.
257
+ */
258
+ export function shadowNotice(target, overrides, label = (id) => id, place = "the draft") {
259
+ if (overrides.env && overrides.env !== target) {
260
+ return `Saved ${place} as your active workspace, but writes still go to ${label(overrides.env)} while CNOTES_WORKSPACE is set. Unset CNOTES_WORKSPACE to work in ${place}.`;
261
+ }
262
+ if (overrides.flag && overrides.flag !== target) {
263
+ return `Saved ${place} as your active workspace, but writes still go to ${label(overrides.flag)} while you pass -w ${overrides.flag}. Drop -w to work in ${place}.`;
264
+ }
265
+ return null;
266
+ }
267
+ /** "3 notes", "1 canvas". */
268
+ function count(n, one, many) {
269
+ return `${n} ${n === 1 ? one : many}`;
270
+ }
271
+ /** The headline of `draft status`: where the draft stands, in one sentence. */
272
+ export function statusHeadline(detail) {
273
+ const { draft, merge } = detail;
274
+ if (draft.status === "merged" && merge && !merge.undoneAt) {
275
+ const by = merge.acceptedByName ? ` Approved in the browser by ${merge.acceptedByName}.` : "";
276
+ return `Merged into ${draft.parentName} ${timeAgo(merge.mergedAt)}.${by}`;
277
+ }
278
+ if (draft.status === "dismissed") {
279
+ const when = draft.closedAt ? ` ${timeAgo(draft.closedAt)}` : "";
280
+ return `Dismissed${when}. Nothing from it reached ${draft.parentName}.`;
281
+ }
282
+ return decisionSentence(detail.decision, Boolean(detail.branch));
283
+ }
284
+ /**
285
+ * Every line `cnotes draft status` prints. The decision comes first, because
286
+ * it is what an agent acts on: fix what was asked, or stop and hand over the
287
+ * link. Merge is never offered: a key cannot merge.
288
+ */
289
+ export function statusLines({ serverUrl, detail, checks, edits, activeWorkspaceId, branch, branchError, }) {
290
+ const d = detail.draft;
291
+ const open = d.status === "open";
292
+ const lines = [];
293
+ lines.push(`${d.name} (${d.id})`);
294
+ lines.push(statusHeadline(detail));
295
+ if (open && branch)
296
+ lines.push(...branchLines(branch, detail.pendingEditCount));
297
+ else if (open && branchError)
298
+ lines.push(`Could not compare your copy with the live board: ${branchError}`);
299
+ lines.push("");
300
+ lines.push(` Draft of: ${d.parentName} (${d.parentWorkspaceId})`);
301
+ lines.push(` Status: ${d.status}, opened ${timeAgo(d.createdAt)}`);
302
+ lines.push(` Holds: ${count(detail.noteCount, "note", "notes")}, ${count(detail.canvasCount, "canvas", "canvases")}, ${count(detail.pendingEditCount, "proposed edit", "proposed edits")}`);
303
+ if (d.intent)
304
+ lines.push(` Intent: ${d.intent}`);
305
+ if (edits && edits.length > 0) {
306
+ lines.push(" Proposed edits of shared notes:");
307
+ for (const e of edits) {
308
+ const base = e.conflict
309
+ ? `based on v${e.baseVersionNumber}, now v${e.currentVersionNumber} (conflict)`
310
+ : `based on v${e.baseVersionNumber}`;
311
+ lines.push(` ${e.noteDisplayId} · "${e.currentTitle}" → "${e.title}" · ${base}`);
312
+ }
313
+ }
314
+ if (checks) {
315
+ const c = checks.checks;
316
+ const scope = `${count(c.notesChecked, "note", "notes")}, ${count(c.editsChecked, "proposed edit", "proposed edits")}`;
317
+ if (c.findings.length === 0) {
318
+ lines.push(` Checks: all clear (${scope})`);
319
+ }
320
+ else {
321
+ lines.push(` Checks: ${c.blocking} blocking, ${count(c.warnings, "warning", "warnings")} (${scope})`);
322
+ for (const f of c.findings) {
323
+ lines.push(` ${f.blocking ? "✗" : "·"} ${f.code} · ${f.message}`);
324
+ lines.push(` fix: ${f.fix}`);
325
+ }
326
+ }
327
+ if (checks.blockedBy)
328
+ lines.push(` Blocked: ${checks.blockedBy}`);
329
+ }
330
+ const merge = detail.merge;
331
+ if (merge) {
332
+ if (merge.undoneAt) {
333
+ lines.push(` Merged ${timeAgo(merge.mergedAt)}, undone ${timeAgo(merge.undoneAt)}.`);
334
+ }
335
+ else {
336
+ lines.push(` Applied: ${count(merge.appliedEdits, "proposed edit", "proposed edits")}`);
337
+ if (merge.renamed.length > 0) {
338
+ lines.push(" Renamed at merge (the shared workspace already had these ids; mentions were updated):");
339
+ for (const r of merge.renamed)
340
+ lines.push(` ${r.from} -> ${r.to}`);
341
+ }
342
+ lines.push(" Undo: the person who approved it can, from the merge row in History, while nothing has built on it.");
343
+ }
344
+ }
345
+ const footer = [];
346
+ if (open) {
347
+ footer.push(`Link: ${draftLink(serverUrl, detail)}`);
348
+ if (detail.decision.state === "awaiting_person")
349
+ footer.push(PERSON_LANDS_IT);
350
+ }
351
+ else if (activeWorkspaceId === d.id) {
352
+ footer.push(`This draft takes no more writes. Switch back to ${d.parentName}: cnotes workspace select ${d.parentWorkspaceId}`);
353
+ }
354
+ if (footer.length > 0)
355
+ lines.push("", ...footer);
356
+ return lines;
357
+ }
358
+ //# sourceMappingURL=draft-view.js.map