@dreamlake/dreamlake-cli 0.104.8 → 0.105.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 (108) hide show
  1. package/dist/api/index.d.ts +27 -17
  2. package/dist/api/index.js +25 -16
  3. package/dist/api/memo-character-plan.d.ts +2 -0
  4. package/dist/api/memo-character-plan.js +2 -0
  5. package/dist/api/memo-editing.d.ts +2 -0
  6. package/dist/api/memo-editing.js +2 -0
  7. package/dist/api/memo-edits.d.ts +63 -0
  8. package/dist/api/memo-edits.js +206 -0
  9. package/dist/api/memo-events.d.ts +44 -0
  10. package/dist/api/memo-events.js +65 -0
  11. package/dist/api/memo-facade.d.ts +294 -0
  12. package/dist/api/memo-facade.js +382 -0
  13. package/dist/api/memo-files.d.ts +111 -0
  14. package/dist/api/memo-files.js +110 -0
  15. package/dist/api/memo-html-read.d.ts +2 -0
  16. package/dist/api/memo-html-read.js +2 -0
  17. package/dist/api/memo-html.d.ts +2 -0
  18. package/dist/api/memo-html.js +2 -0
  19. package/dist/api/memo-linger.d.ts +85 -0
  20. package/dist/api/memo-linger.js +271 -0
  21. package/dist/api/memo-presence.d.ts +109 -0
  22. package/dist/api/memo-presence.js +75 -0
  23. package/dist/api/memo-reading.d.ts +55 -0
  24. package/dist/api/memo-reading.js +43 -0
  25. package/dist/api/memo-toc.d.ts +2 -0
  26. package/dist/api/memo-toc.js +2 -0
  27. package/dist/api/memo-write.d.ts +119 -0
  28. package/dist/api/memo-write.js +221 -0
  29. package/dist/api/memos.d.ts +344 -0
  30. package/dist/api/memos.js +231 -0
  31. package/dist/api/note-character-plan.d.ts +2 -2
  32. package/dist/api/note-character-plan.js +2 -2
  33. package/dist/api/note-editing.d.ts +2 -2
  34. package/dist/api/note-editing.js +2 -2
  35. package/dist/api/note-edits.d.ts +2 -59
  36. package/dist/api/note-edits.js +2 -205
  37. package/dist/api/note-events.d.ts +2 -41
  38. package/dist/api/note-events.js +2 -64
  39. package/dist/api/note-facade.d.ts +2 -268
  40. package/dist/api/note-facade.js +2 -376
  41. package/dist/api/note-files.d.ts +2 -102
  42. package/dist/api/note-files.js +2 -107
  43. package/dist/api/note-html-read.d.ts +2 -2
  44. package/dist/api/note-html-read.js +2 -2
  45. package/dist/api/note-html.d.ts +2 -2
  46. package/dist/api/note-html.js +2 -2
  47. package/dist/api/note-linger.d.ts +2 -83
  48. package/dist/api/note-linger.js +2 -270
  49. package/dist/api/note-presence.d.ts +2 -100
  50. package/dist/api/note-presence.js +2 -73
  51. package/dist/api/note-reading.d.ts +2 -51
  52. package/dist/api/note-reading.js +2 -42
  53. package/dist/api/note-toc.d.ts +2 -2
  54. package/dist/api/note-toc.js +2 -2
  55. package/dist/api/note-write.d.ts +2 -110
  56. package/dist/api/note-write.js +2 -217
  57. package/dist/api/notes.d.ts +2 -335
  58. package/dist/api/notes.js +2 -230
  59. package/dist/api/open-resources.js +3 -3
  60. package/dist/cli/folders/index.d.ts +1 -1
  61. package/dist/cli/folders/index.js +4 -4
  62. package/dist/cli/index.js +2 -2
  63. package/dist/cli/{notes → memos}/api-transport.d.ts +1 -1
  64. package/dist/cli/{notes → memos}/api-transport.js +1 -1
  65. package/dist/cli/{notes → memos}/archive-command.d.ts +1 -1
  66. package/dist/cli/{notes → memos}/archive-command.js +5 -5
  67. package/dist/cli/{notes → memos}/character-plan.d.ts +3 -1
  68. package/dist/cli/{notes → memos}/character-plan.js +7 -5
  69. package/dist/cli/{notes → memos}/document.d.ts +9 -9
  70. package/dist/cli/{notes → memos}/document.js +12 -12
  71. package/dist/cli/{notes → memos}/edit-commands.d.ts +8 -8
  72. package/dist/cli/{notes → memos}/edit-commands.js +14 -14
  73. package/dist/cli/{notes → memos}/events.d.ts +3 -3
  74. package/dist/cli/{notes → memos}/events.js +2 -2
  75. package/dist/cli/{notes → memos}/files-commands.d.ts +2 -2
  76. package/dist/cli/{notes → memos}/files-commands.js +5 -5
  77. package/dist/cli/{notes → memos}/index.d.ts +16 -16
  78. package/dist/cli/{notes → memos}/index.js +53 -53
  79. package/dist/cli/{notes → memos}/linger.d.ts +3 -3
  80. package/dist/cli/{notes → memos}/linger.js +5 -5
  81. package/dist/cli/{notes → memos}/move-command.d.ts +5 -5
  82. package/dist/cli/{notes → memos}/move-command.js +6 -6
  83. package/dist/cli/{notes → memos}/rm-command.d.ts +2 -2
  84. package/dist/cli/{notes → memos}/rm-command.js +2 -2
  85. package/dist/cli/{notes → memos}/select-command.d.ts +1 -1
  86. package/dist/cli/{notes → memos}/select-command.js +4 -4
  87. package/dist/cli/{notes → memos}/suggest-diff.d.ts +1 -1
  88. package/dist/cli/{notes → memos}/suggest-diff.js +2 -2
  89. package/dist/cli/{notes → memos}/transfer-command.d.ts +2 -2
  90. package/dist/cli/{notes → memos}/transfer-command.js +2 -2
  91. package/dist/cli/share.d.ts +1 -1
  92. package/dist/cli/share.js +1 -1
  93. package/dist/cli/update/index.js +3 -3
  94. package/dist/cli/version.d.ts +1 -1
  95. package/dist/cli/version.js +1 -1
  96. package/package.json +9 -9
  97. /package/dist/cli/{notes → memos}/editing.d.ts +0 -0
  98. /package/dist/cli/{notes → memos}/editing.js +0 -0
  99. /package/dist/cli/{notes → memos}/html-read.d.ts +0 -0
  100. /package/dist/cli/{notes → memos}/html-read.js +0 -0
  101. /package/dist/cli/{notes → memos}/html.d.ts +0 -0
  102. /package/dist/cli/{notes → memos}/html.js +0 -0
  103. /package/dist/cli/{notes → memos}/media-commands.d.ts +0 -0
  104. /package/dist/cli/{notes → memos}/media-commands.js +0 -0
  105. /package/dist/cli/{notes → memos}/toc.d.ts +0 -0
  106. /package/dist/cli/{notes → memos}/toc.js +0 -0
  107. /package/dist/cli/{notes → memos}/version-commands.d.ts +0 -0
  108. /package/dist/cli/{notes → memos}/version-commands.js +0 -0
package/dist/api/notes.js CHANGED
@@ -1,230 +1,2 @@
1
- import { readNoteView } from "./note-reading.js";
2
- import { validateHtmlSnapshot, scopedSourceRange } from "./note-html-read.js";
3
- import { characterDiff } from "./note-character-plan.js";
4
- import * as editing from "./note-editing.js";
5
- import { markdownToc as outline } from "./note-toc.js";
6
- import { parse as parseHtml, select as selectHtml, textPieces } from './note-html.js';
7
- /** Notes: search, read, sections, conditional writes. Mirrors the CLI `notes` group. */
8
- import { noteFilesApi } from "./note-files.js";
9
- import { notePresenceApi } from "./note-presence.js";
10
- import { watchNote } from "./note-linger.js";
11
- import { sharingApi } from "./workspace.js";
12
- import { createHash } from "node:crypto";
13
- import { noteEdits, } from "./note-edits.js";
14
- export { noteEdits, } from "./note-edits.js";
15
- import { ApiError, isObjectId, seg } from "./client.js";
16
- import { submitNotePatch, readNoteCommand, validateCommandId, refuseNewReadingViewLines } from "./note-write.js";
17
- export function notesApi(t, namespace) {
18
- const base = `/namespaces/${seg(namespace)}/notes`;
19
- const id = (value) => {
20
- if (!isObjectId(value))
21
- throw new Error("expected a 24-hex memo id");
22
- return value;
23
- };
24
- const source = async (noteId, at) => {
25
- const value = await t.request("GET", `${base}/${id(noteId)}/body`, { query: { contract: "v2", at }, redirect: "error" });
26
- if (!value ||
27
- value.note !== noteId ||
28
- !/^sha256:[a-f0-9]{64}$/.test(value.hash ?? "") ||
29
- typeof value.revision !== "string" ||
30
- !value.revision.trim() ||
31
- /[\r\n]/.test(value.revision) ||
32
- /^sha256:/i.test(value.revision))
33
- throw new Error("server did not return the Memos v2 contract; upgrade the server");
34
- if (at !== undefined && value.revision !== at)
35
- throw new Error("server did not return the requested pinned revision");
36
- if (typeof value.content !== "string" ||
37
- value.hash !==
38
- `sha256:${createHash("sha256").update(value.content, "utf8").digest("hex")}`)
39
- throw new Error("source does not match the returned hash");
40
- return value;
41
- };
42
- /** The one v2 write. `commandId` is sent only when supplied and must be echoed; see note-write.ts. */
43
- const patch = async (noteId, input, options = {}) => {
44
- if (!input.baseRevision ||
45
- /[\r\n]/.test(input.baseRevision) ||
46
- !["exact", "merge"].includes(input.mode))
47
- throw new Error("original baseRevision and mode required");
48
- return submitNotePatch(t, `${base}/${id(noteId)}/body`, noteId, input, options);
49
- };
50
- const withCommand = (request, options) => options?.commandId === undefined ? request : { ...request, commandId: options.commandId };
51
- const api = {
52
- ...notePresenceApi(t, base),
53
- linger: (noteId, options, receive) => watchNote(t, `${base}/${id(noteId)}`, noteId, options, receive),
54
- namespace,
55
- /** Resolve the same ID, exact slug or exact title accepted by the CLI in this namespace. */
56
- resolve: async (ref) => {
57
- if (/^[a-f0-9]{24}$/i.test(ref))
58
- return ref;
59
- let offset = 0;
60
- for (;;) {
61
- const result = await t.request('GET', base, { query: { limit: 200, offset, includeArchived: true } });
62
- const hit = result.notes.find(row => row.slug === ref || row.id === ref || row.name === ref);
63
- if (hit)
64
- return hit.id;
65
- offset += result.notes.length;
66
- if (!result.notes.length || (result.total === undefined ? result.notes.length < 200 : offset >= result.total))
67
- break;
68
- }
69
- throw new ApiError(404, 'note_not_found', { namespace, ref });
70
- },
71
- /** CSS inspection is read-only; selectText publishes a separate agent selection. */
72
- selectElement: async (noteId, css) => {
73
- const body = await t.request('GET', `${base}/${id(noteId)}/body`);
74
- const document = parseHtml(body.text), element = selectHtml(document, css);
75
- return { etag: body.etag, tag: element.tag, attrs: element.attrs, outer: element.outer, inner: element.inner,
76
- text: textPieces(document, element).map(piece => piece.decoded).join('') };
77
- },
78
- source,
79
- patch,
80
- replaceContent: async (noteId, baseRevision, content, mode = "exact", options) => {
81
- const original = await source(noteId, baseRevision);
82
- refuseNewReadingViewLines(original.content, content, "content");
83
- return patch(noteId, withCommand(noteEdits(original, characterDiff(original.content, content).map((e) => ({
84
- start: e.start,
85
- end: e.end,
86
- text: e.replacementText,
87
- expected: e.expectedText,
88
- })), mode), options));
89
- },
90
- replace: async (noteId, baseRevision, text, where, mode = "exact", options) => {
91
- const original = await source(noteId, baseRevision), plan = editing.replacementPlan(original.content, text, where);
92
- return patch(noteId, withCommand(noteEdits(original, plan.map(([start, end, text]) => ({ start, end, text })), mode), options));
93
- },
94
- insert: async (noteId, baseRevision, text, where, mode = "exact", options) => {
95
- const original = await source(noteId, baseRevision), placement = editing.insertPlacement(original.content, text, where);
96
- return patch(noteId, withCommand(noteEdits(original, [{ start: placement.at, end: placement.at, text: placement.text }], mode), options));
97
- },
98
- removeText: async (noteId, baseRevision, where, mode = "exact", options) => {
99
- const original = await source(noteId, baseRevision), plan = editing.removalPlan(original.content, where);
100
- return patch(noteId, withCommand(noteEdits(original, plan.map(([start, end, text]) => ({ start, end, text })), mode), options));
101
- },
102
- findInSource: async (noteId, at, query, options = {}) => {
103
- const original = await source(noteId, at);
104
- return {
105
- ...original,
106
- matches: editing.find(original.content, query, options),
107
- };
108
- },
109
- outline: async (noteId, at) => {
110
- const original = await source(noteId, at);
111
- return {
112
- note: noteId,
113
- revision: original.revision,
114
- hash: original.hash,
115
- entries: outline(original.content),
116
- };
117
- },
118
- get: (noteId) => t.request("GET", `/notes/${id(noteId)}`),
119
- /** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
120
- archive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: true } }),
121
- unarchive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: false } }),
122
- delete: (noteId) => t.request("DELETE", `${base}/${id(noteId)}`),
123
- shared: (query = {}) => t.request("GET", "/me/notes/shared", { query }),
124
- projects: (noteId, view) => t.request("GET", `/namespaces/${seg(namespace)}/resources/note/${id(noteId)}/projects`, { query: { view } }),
125
- move: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/move`, { json: input }),
126
- share: (noteId) => sharingApi(t, namespace, "notes", id(noteId)),
127
- files: (noteId) => noteFilesApi(t, `${base}/${id(noteId)}`),
128
- media: async (form) => {
129
- const receipt = await t.request('POST', '/notes/media', { body: form, redirect: 'error' });
130
- if (!receipt || typeof receipt.url !== 'string' || !/^https?:\/\/[^\s]+$/.test(receipt.url) ||
131
- !['http:', 'https:'].includes(new URL(receipt.url).protocol) || typeof receipt.contentType !== 'string' ||
132
- !Number.isSafeInteger(receipt.sizeBytes) || receipt.sizeBytes < 0)
133
- throw new Error('invalid media upload response: expected url, contentType and sizeBytes');
134
- return receipt;
135
- },
136
- read: (noteId, query = {}, options = {}) => t.request("GET", `${base}/${id(noteId)}/body`, {
137
- query: { contract: "v2", ...query },
138
- ...(options.ifMatch === undefined ? {} : { headers: { "If-Match": options.ifMatch } }),
139
- }),
140
- readView: (noteId, options = {}) => readNoteView(t, namespace, id(noteId), options),
141
- html: async (noteId, options = {}) => {
142
- if (!t.raw)
143
- throw new Error("transport_does_not_support_streaming");
144
- const response = await t.raw("GET", `${base}/${id(noteId)}/body`, {
145
- query: {
146
- contract: "v2",
147
- view: "html",
148
- contentFormat: "literal-markdown",
149
- at: options.at,
150
- section: options.section,
151
- toc: options.toc,
152
- tag: options.tag,
153
- },
154
- headers: {
155
- Accept: "text/html",
156
- ...(options.ifMatch ? { "If-Match": options.ifMatch } : {}),
157
- },
158
- });
159
- if (!/^text\/(?:html|plain)(?:;|$)/i.test(response.headers.get("content-type") ?? ""))
160
- throw new Error("server did not return Memos HTML; upgrade the server");
161
- const bytes = new Uint8Array(await response.arrayBuffer()), html = new TextDecoder("utf-8", {
162
- fatal: true,
163
- ignoreBOM: true,
164
- }).decode(bytes);
165
- const snapshot = validateHtmlSnapshot(html, noteId, options);
166
- if (options.at && snapshot.revision !== options.at)
167
- throw new Error("server did not return the requested pinned revision");
168
- if (options.ifMatch && snapshot.revision !== options.ifMatch)
169
- throw new ApiError(412, "stale", { note: noteId });
170
- return { note: noteId, revision: snapshot.revision, html, bytes };
171
- },
172
- diff: (noteId, query) => t.request("GET", `${base}/${id(noteId)}/diff`, { query }),
173
- saveVersion: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/versions`, { json: input }),
174
- find: (query) => t.request("GET", `${base}/search`, { query }),
175
- create: (input) => t.request("POST", base, {
176
- json: input,
177
- }),
178
- edit: async (noteId, baseRevision, edits, mode = "exact", options) => patch(noteId, withCommand(noteEdits(await source(noteId, baseRevision), edits, mode), options)),
179
- /** The durable record of one command id, scoped to the calling actor; 404 `command_not_found` when none. */
180
- commandStatus: async (noteId, commandId) => readNoteCommand(t, `${base}/${id(noteId)}/commands/${seg(validateCommandId(commandId))}`, commandId),
181
- versions: (noteId, query = {}) => t.request("GET", `${base}/${id(noteId)}/versions`, { query }),
182
- version: (noteId, versionId) => t.request("GET", `${base}/${id(noteId)}/versions/${seg(versionId)}`),
183
- list: (query = {}) => t.request("GET", base, { query }),
184
- search: (q, limit = 50, offset = 0, options = {}) => t.request("GET", base, {
185
- query: { q, limit, offset, ...options },
186
- }),
187
- body: (noteId) => t.request("GET", `${base}/${id(noteId)}/body`),
188
- sections: (noteId) => t.request("GET", `${base}/${id(noteId)}/sections`),
189
- section: (noteId, anchor) => t.request("GET", `${base}/${id(noteId)}/sections/${encodeURIComponent(anchor)}`),
190
- /** Replace the whole body, refused with 412 `stale` unless `ifMatch` is the current etag. */
191
- write: (noteId, text, ifMatch) => t.request("PUT", `${base}/${id(noteId)}/body`, {
192
- json: { text },
193
- headers: { "If-Match": ifMatch },
194
- }),
195
- /** Read-then-conditional-write append; a concurrent edit refuses with 412 `stale` instead of being overwritten. */
196
- append: async (noteId, addition, ifMatch) => {
197
- const current = await t.request("GET", `${base}/${id(noteId)}/body`);
198
- const text = (current.text && !current.text.endsWith("\n")
199
- ? current.text + "\n"
200
- : current.text) + addition;
201
- return t.request("PUT", `${base}/${id(noteId)}/body`, {
202
- json: { text },
203
- headers: { "If-Match": ifMatch ?? current.etag },
204
- });
205
- },
206
- addSection: async (noteId, text, placement = {}, ifMatch) => {
207
- const etag = ifMatch ??
208
- (await t.request("GET", `${base}/${id(noteId)}/body`)).etag;
209
- return t.request("POST", `${base}/${id(noteId)}/sections`, {
210
- json: { text, ...placement },
211
- headers: { "If-Match": etag },
212
- });
213
- },
214
- removeSection: async (noteId, anchor, ifMatch) => {
215
- const etag = ifMatch ??
216
- (await t.request("GET", `${base}/${id(noteId)}/body`)).etag;
217
- return t.request("DELETE", `${base}/${id(noteId)}/sections/${seg(anchor)}`, { headers: { "If-Match": etag } });
218
- },
219
- };
220
- return Object.assign(api, {
221
- /** The full original span of one mapped element (`s1.p2`) at a revision: the scoped HTML read's absolute code-point range. */
222
- addressRange: async (noteId, address, at) => {
223
- const scoped = await api.html(noteId, { tag: address, at });
224
- const range = scopedSourceRange(scoped.html);
225
- if (!range)
226
- throw new Error(`address ${address} did not return a scoped source range`);
227
- return { ...range, revision: scoped.revision };
228
- },
229
- });
230
- }
1
+ /** @deprecated Import the canonical Memo module. */
2
+ export * from "./memos.js";
@@ -1,6 +1,6 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { ApiError } from "./client.js";
3
- import { notesApi } from "./notes.js";
3
+ import { memosApi } from "./memos.js";
4
4
  import { projectToolsApi } from "./agent.js";
5
5
  /** Descriptors are observations only. Each resource goes through the caller's permission-checked API. */
6
6
  export function openResourcesApi(t) {
@@ -36,13 +36,13 @@ export function openResourcesApi(t) {
36
36
  }
37
37
  try {
38
38
  if (item.kind === "note") {
39
- const row = await notesApi(t, "unused").get(id);
39
+ const row = await memosApi(t, "unused").get(id);
40
40
  if (!row.namespaceSlug)
41
41
  throw new ApiError(503, "note_namespace_unavailable", {});
42
42
  results.push({
43
43
  resource: id,
44
44
  tabId: item.id,
45
- matches: await notesApi(t, row.namespaceSlug).find({
45
+ matches: await memosApi(t, row.namespaceSlug).find({
46
46
  q: input.query,
47
47
  note: id,
48
48
  limit: 20,
@@ -1,6 +1,6 @@
1
1
  /** Folder lifecycle and browsing use the shared node API. */
2
2
  import type { Command } from 'commander';
3
- import { type ConnOpts } from '../notes/index.js';
3
+ import { type ConnOpts } from '../memos/index.js';
4
4
  type Options = ConnOpts & {
5
5
  json?: boolean;
6
6
  project?: string;
@@ -3,8 +3,8 @@ import { resolveCtx } from '../compat/ctx.js';
3
3
  import { requireToken, requireNamespace } from '../compat/http.js';
4
4
  import { withConnFlags } from '../compat/flags.js';
5
5
  import { emitJson, fail, renderTable } from '../helpers.js';
6
- import { noteTransport } from '../notes/api-transport.js';
7
- import { report } from '../notes/index.js';
6
+ import { memoTransport } from '../memos/api-transport.js';
7
+ import { report } from '../memos/index.js';
8
8
  export async function runFoldersList(opts) {
9
9
  const c = resolveCtx(opts), token = requireToken(c);
10
10
  if (!token)
@@ -22,7 +22,7 @@ export async function runFoldersList(opts) {
22
22
  fail('--page must be positive; --page-size must be 1–200');
23
23
  return 1;
24
24
  }
25
- const result = await nodesApi(noteTransport({ remote: c.remote, token })).children({
25
+ const result = await nodesApi(memoTransport({ remote: c.remote, token })).children({
26
26
  ...(opts.parentId ? { parentId: opts.parentId } : { namespace: namespace, project: opts.project }),
27
27
  page, pageSize, ...(opts.includeArchived ? { includeArchived: true } : {}),
28
28
  });
@@ -47,7 +47,7 @@ export async function runFoldersArchive(id, archived, opts) {
47
47
  return 1;
48
48
  }
49
49
  try {
50
- const api = nodesApi(noteTransport({ remote: c.remote, token }));
50
+ const api = nodesApi(memoTransport({ remote: c.remote, token }));
51
51
  const result = await (archived ? api.archive(id) : api.unarchive(id));
52
52
  if (opts.json)
53
53
  emitJson(result);
package/dist/cli/index.js CHANGED
@@ -36,7 +36,7 @@ import { registerConnectionCommand } from "./connection/index.js";
36
36
  import { registerSourceCommand } from "./source/index.js";
37
37
  import { registerTasksCommand } from "./tasks/index.js";
38
38
  import { registerFoldersCommand } from "./folders/index.js";
39
- import { registerNotesCommand } from "./notes/index.js";
39
+ import { registerMemosCommand } from "./memos/index.js";
40
40
  import { registerDeclareCommand } from "./declare/index.js";
41
41
  import { registerHostsCommand } from "./hosts/index.js";
42
42
  import { registerSessionsCommand } from "./sessions/index.js";
@@ -197,7 +197,7 @@ async function main(argv) {
197
197
  registerWorkflowCommand(program);
198
198
  registerPageCommand(program);
199
199
  registerSourceCommand(program);
200
- registerNotesCommand(program);
200
+ registerMemosCommand(program);
201
201
  registerFoldersCommand(program);
202
202
  registerOwnershipCommand(program);
203
203
  registerProjectCommand(program);
@@ -1,5 +1,5 @@
1
1
  import type { Transport } from '../../api/client.js';
2
- export declare function noteTransport(c: {
2
+ export declare function memoTransport(c: {
3
3
  remote: string;
4
4
  token: string;
5
5
  }): Transport;
@@ -1,7 +1,7 @@
1
1
  /** Adapt explicit resolved CLI credentials; attribution remains owned by the CLI transport. */
2
2
  import { requestJson, requestRaw } from '../client.js';
3
3
  import { requestUrl, RequestNotSent } from '../../api/http.js';
4
- export function noteTransport(c) {
4
+ export function memoTransport(c) {
5
5
  return {
6
6
  request: async (method, path, options) => {
7
7
  if (method === 'HEAD')
@@ -1,7 +1,7 @@
1
1
  /** Archive is reversible lifecycle metadata, independent of deletion and tags. */
2
2
  import type { Command } from 'commander';
3
3
  import { type ConnOpts } from './index.js';
4
- export declare function runNotesArchive(ref: string, archived: boolean, opts: ConnOpts & {
4
+ export declare function runMemosArchive(ref: string, archived: boolean, opts: ConnOpts & {
5
5
  json?: boolean;
6
6
  }): Promise<number>;
7
7
  export declare function registerArchiveCommands(notes: Command): void;
@@ -1,12 +1,12 @@
1
- import { notesApi } from '../../api/notes.js';
1
+ import { memosApi } from '../../api/memos.js';
2
2
  import { requestJson } from '../client.js';
3
3
  import { resolveCtx } from '../compat/ctx.js';
4
4
  import { requireNamespace, requireToken } from '../compat/http.js';
5
5
  import { withConnFlags } from '../compat/flags.js';
6
6
  import { emitJson, fail } from '../helpers.js';
7
- import { noteTransport } from './api-transport.js';
7
+ import { memoTransport } from './api-transport.js';
8
8
  import { resolveNote, report, seg } from './index.js';
9
- export async function runNotesArchive(ref, archived, opts) {
9
+ export async function runMemosArchive(ref, archived, opts) {
10
10
  const c = resolveCtx(opts), token = requireToken(c);
11
11
  if (!token)
12
12
  return 1;
@@ -35,7 +35,7 @@ export async function runNotesArchive(ref, archived, opts) {
35
35
  fail('you do not have permission to archive this memo');
36
36
  return 1;
37
37
  }
38
- const api = notesApi(noteTransport({ remote: c.remote, token }), note.namespaceSlug);
38
+ const api = memosApi(memoTransport({ remote: c.remote, token }), note.namespaceSlug);
39
39
  const result = await (archived ? api.archive(id) : api.unarchive(id));
40
40
  if (opts.json)
41
41
  emitJson(result);
@@ -54,6 +54,6 @@ export function registerArchiveCommands(notes) {
54
54
  .argument('<note>', 'memo id, slug or exact title')
55
55
  .option('--namespace <slug>', 'whose memos for lookup; with an id, asserts the owner')
56
56
  .option('--json', 'emit the updated memo metadata')
57
- .action(async (note, opts) => { process.exitCode = await runNotesArchive(note, action === 'archive', opts); });
57
+ .action(async (note, opts) => { process.exitCode = await runMemosArchive(note, action === 'archive', opts); });
58
58
  }
59
59
  }
@@ -13,10 +13,12 @@ export declare const PATCH_LIMITS: Readonly<{
13
13
  maxDiffCells: 4000000;
14
14
  maxTraceCells: 250000;
15
15
  }>;
16
- export declare class NotePatchError extends Error {
16
+ export declare class MemoPatchError extends Error {
17
17
  readonly code: 'INVALID_PATCH' | 'LIMIT_EXCEEDED';
18
18
  constructor(message: string, code?: 'INVALID_PATCH' | 'LIMIT_EXCEEDED');
19
19
  }
20
20
  export declare function characterDiff(base: string, target: string, offset?: number, budget?: {
21
21
  cells: number;
22
22
  }): CharacterEdit[];
23
+ /** @deprecated Use MemoPatchError. */
24
+ export { MemoPatchError as NotePatchError };
@@ -6,18 +6,18 @@ export const PATCH_LIMITS = Object.freeze({
6
6
  maxDiffCells: 4_000_000,
7
7
  maxTraceCells: 250_000,
8
8
  });
9
- export class NotePatchError extends Error {
9
+ export class MemoPatchError extends Error {
10
10
  code;
11
11
  constructor(message, code = 'INVALID_PATCH') {
12
12
  super(message);
13
13
  this.code = code;
14
- this.name = 'NotePatchError';
14
+ this.name = 'MemoPatchError';
15
15
  }
16
16
  }
17
- function invalid(message) { throw new NotePatchError(message); }
17
+ function invalid(message) { throw new MemoPatchError(message); }
18
18
  function limit(condition, message) {
19
19
  if (condition)
20
- throw new NotePatchError(message, 'LIMIT_EXCEEDED');
20
+ throw new MemoPatchError(message, 'LIMIT_EXCEEDED');
21
21
  }
22
22
  function checkText(text) {
23
23
  if (typeof text !== 'string')
@@ -54,7 +54,7 @@ export function characterDiff(base, target, offset = 0, budget = { cells: 0 }) {
54
54
  return sparseCharacterDiff(left, right, offset + prefix, budget);
55
55
  }
56
56
  catch (error) {
57
- if (!(error instanceof NotePatchError) || error.message !== 'Character alignment trace limit exceeded')
57
+ if (!(error instanceof MemoPatchError) || error.message !== 'Character alignment trace limit exceeded')
58
58
  throw error;
59
59
  return packedCharacterDiff(left, right, offset + prefix, budget);
60
60
  }
@@ -230,3 +230,5 @@ function sparseCharacterDiff(a, b, offset, budget) {
230
230
  }
231
231
  return invalid('Character alignment failed');
232
232
  }
233
+ /** @deprecated Use MemoPatchError. */
234
+ export { MemoPatchError as NotePatchError };
@@ -1,5 +1,5 @@
1
- import type { SourceSnapshot, DocumentPatchPayload } from "../../api/note-edits.js";
2
- import { type NotePatchRequest, type NoteWriteReceipt } from "../../api/note-write.js";
1
+ import type { SourceSnapshot, DocumentPatchPayload } from "../../api/memo-edits.js";
2
+ import { type MemoPatchRequest, type MemoWriteReceipt } from "../../api/memo-write.js";
3
3
  import { ctx, type ConnOpts } from "./index.js";
4
4
  export interface DocumentReadOptions extends ConnOpts {
5
5
  at?: string;
@@ -43,8 +43,8 @@ interface Tokens {
43
43
  }
44
44
  export declare function tokens(result: Tokens, note: string): void;
45
45
  type DocumentContext = NonNullable<Awaited<ReturnType<typeof ctx>>>;
46
- export type { SourceSnapshot, SourceEdit, DocumentPatchPayload } from "../../api/note-edits.js";
47
- export { documentEdits, documentInsertion } from "../../api/note-edits.js";
46
+ export type { SourceSnapshot, SourceEdit, DocumentPatchPayload } from "../../api/memo-edits.js";
47
+ export { documentEdits, documentInsertion } from "../../api/memo-edits.js";
48
48
  /** The retained snapshot every v2 editor plans from, read through the shared core. */
49
49
  export declare function readDocumentSnapshot(c: DocumentContext, id: string, at?: string): Promise<SourceSnapshot>;
50
50
  /** Inserted text must not carry a generated reading-view header (the core's rule); whole-body writes are checked against their baseline by writePlan. */
@@ -59,14 +59,14 @@ export declare function commandIdFlag(opts: {
59
59
  /** The exact request body: `commandId` appears only when the flag was given. */
60
60
  export declare function withCommandId(payload: DocumentPatchPayload, opts: {
61
61
  commandId?: string;
62
- }): NotePatchRequest;
62
+ }): MemoPatchRequest;
63
63
  /** One submission path for every editor: the shared core verifies the receipt and the command-id echo. */
64
- export declare function submitDocumentPatch(c: DocumentContext, id: string, payload: NotePatchRequest, options?: {
64
+ export declare function submitDocumentPatch(c: DocumentContext, id: string, payload: MemoPatchRequest, options?: {
65
65
  ifMatch?: string;
66
- }): Promise<NoteWriteReceipt>;
67
- export declare function printPatchReceipt(result: NoteWriteReceipt, json?: boolean): void;
66
+ }): Promise<MemoWriteReceipt>;
67
+ export declare function printPatchReceipt(result: MemoWriteReceipt, json?: boolean): void;
68
68
  /** `dreamlake notes command-status NOTE COMMAND_ID`: the durable record behind one --command-id. */
69
- export declare function runNotesCommandStatus(ref: string, commandId: string, opts: ConnOpts & {
69
+ export declare function runMemosCommandStatus(ref: string, commandId: string, opts: ConnOpts & {
70
70
  json?: boolean;
71
71
  }): Promise<number>;
72
72
  /** The core classifies PATCH failures (see note-write.ts); this maps them to exit codes. */
@@ -1,8 +1,8 @@
1
- import { readNoteView, focusedRead } from "../../api/note-reading.js";
1
+ import { readMemoView, focusedRead } from "../../api/memo-reading.js";
2
2
  import { validateHtmlSnapshot } from "./html-read.js";
3
- import { notesApi } from "../../api/notes.js";
4
- import { COMMAND_ID_PATTERN, UncertainOutcome, CommandIdentityUnsupported, NoteWriteNotSubmitted, CommandInProgress, CommandIntentMismatch, refuseReadingView, refuseReadingViewPatch, failureInfo, provenUnsubmitted } from "../../api/note-write.js";
5
- import { noteTransport } from "./api-transport.js";
3
+ import { memosApi } from "../../api/memos.js";
4
+ import { COMMAND_ID_PATTERN, UncertainOutcome, CommandIdentityUnsupported, MemoWriteNotSubmitted, CommandInProgress, CommandIntentMismatch, refuseReadingView, refuseReadingViewPatch, failureInfo, provenUnsubmitted } from "../../api/memo-write.js";
5
+ import { memoTransport } from "./api-transport.js";
6
6
  /** V2 transports exact source and opaque revisions; the backend owns patch parsing. */
7
7
  import { createHash } from "node:crypto";
8
8
  import { readFileSync } from "node:fs";
@@ -23,10 +23,10 @@ export function tokens(result, note) {
23
23
  function printTokens(result) {
24
24
  return `note: ${result.note}\nhash: ${result.hash}\nrevision: ${result.revision}\n`;
25
25
  }
26
- export { documentEdits, documentInsertion } from "../../api/note-edits.js";
26
+ export { documentEdits, documentInsertion } from "../../api/memo-edits.js";
27
27
  /** The retained snapshot every v2 editor plans from, read through the shared core. */
28
28
  export function readDocumentSnapshot(c, id, at) {
29
- return notesApi(noteTransport(c), c.ns).source(id, at);
29
+ return memosApi(memoTransport(c), c.ns).source(id, at);
30
30
  }
31
31
  /** Inserted text must not carry a generated reading-view header (the core's rule); whole-body writes are checked against their baseline by writePlan. */
32
32
  export function canonicalInput(text, what) {
@@ -74,7 +74,7 @@ export function withCommandId(payload, opts) {
74
74
  }
75
75
  /** One submission path for every editor: the shared core verifies the receipt and the command-id echo. */
76
76
  export function submitDocumentPatch(c, id, payload, options = {}) {
77
- return notesApi(noteTransport(c), c.ns).patch(id, payload, options);
77
+ return memosApi(memoTransport(c), c.ns).patch(id, payload, options);
78
78
  }
79
79
  export function printPatchReceipt(result, json) {
80
80
  if (json)
@@ -84,7 +84,7 @@ export function printPatchReceipt(result, json) {
84
84
  process.stdout.write(`${printTokens(result)}mode: ${result.mode}\nbaseRevision: ${result.baseRevision}\n${result.commandId === null ? "" : `outcome: ${result.outcome}\ncommandId: ${result.commandId}\nreplayed: ${result.replayed}\n`}`);
85
85
  }
86
86
  /** `dreamlake notes command-status NOTE COMMAND_ID`: the durable record behind one --command-id. */
87
- export async function runNotesCommandStatus(ref, commandId, opts) {
87
+ export async function runMemosCommandStatus(ref, commandId, opts) {
88
88
  if (!COMMAND_ID_PATTERN.test(commandId)) {
89
89
  fail("command id must be 8–128 characters of A-Z a-z 0-9 . _ : -");
90
90
  return 1;
@@ -96,7 +96,7 @@ export async function runNotesCommandStatus(ref, commandId, opts) {
96
96
  const id = await resolveNote(c, ref);
97
97
  if (!id)
98
98
  return 1;
99
- const status = await notesApi(noteTransport(c), c.ns).commandStatus(id, commandId);
99
+ const status = await memosApi(memoTransport(c), c.ns).commandStatus(id, commandId);
100
100
  if (opts.json) {
101
101
  emitJson(status);
102
102
  return 0;
@@ -110,7 +110,7 @@ export async function runNotesCommandStatus(ref, commandId, opts) {
110
110
  }
111
111
  /** The core classifies PATCH failures (see note-write.ts); this maps them to exit codes. */
112
112
  export function documentWriteError(error) {
113
- if (error instanceof NoteWriteNotSubmitted) {
113
+ if (error instanceof MemoWriteNotSubmitted) {
114
114
  fail(error.message);
115
115
  return 1;
116
116
  }
@@ -133,7 +133,7 @@ export function documentWriteError(error) {
133
133
  // The core turns a PATCH 503 into a typed outcome above, so a raw 503 here came from the
134
134
  // baseline read (or note resolution): nothing was submitted and nothing is ambiguous.
135
135
  if (error instanceof HttpError && error.status === 503) {
136
- fail(provenUnsubmitted(failureInfo(error).body) ? new NoteWriteNotSubmitted().message
136
+ fail(provenUnsubmitted(failureInfo(error).body) ? new MemoWriteNotSubmitted().message
137
137
  : `patch not submitted: the original baseline could not be read, so nothing was sent; preserve the original baseline and draft (${error.message})`);
138
138
  return 1;
139
139
  }
@@ -215,7 +215,7 @@ export async function runDocumentRead(ref, opts) {
215
215
  let at = opts.at, start = 0, hash, total;
216
216
  let fallback = false;
217
217
  do {
218
- const page = await readNoteView(transport, c.ns, id, { at, start, section: opts.section, tag: opts.tag, toc: opts.toc });
218
+ const page = await readMemoView(transport, c.ns, id, { at, start, section: opts.section, tag: opts.tag, toc: opts.toc });
219
219
  // An HTML-source note has no Markdown reading view: the defaulted read falls back to exact source.
220
220
  if (page.sourceType !== 'markdown' && defaultedView && start === 0) {
221
221
  fallback = true;
@@ -45,7 +45,7 @@ export declare function elementReplacementPlan(source: string, css: string, text
45
45
  */
46
46
  export declare function elementInsertionPosition(source: string, css: string, position: string): number;
47
47
  export declare function insertAtElement(source: string, css: string, text: string, position: string): string;
48
- export declare function runNotesFind(query: string | undefined, opts: ConnOpts & {
48
+ export declare function runMemosFind(query: string | undefined, opts: ConnOpts & {
49
49
  note?: string;
50
50
  regex?: string;
51
51
  flags?: string;
@@ -54,7 +54,7 @@ export declare function runNotesFind(query: string | undefined, opts: ConnOpts &
54
54
  at?: string;
55
55
  caseSensitive?: boolean;
56
56
  }): Promise<number>;
57
- export declare function runNotesToc(opts: ConnOpts & {
57
+ export declare function runMemosToc(opts: ConnOpts & {
58
58
  note?: string;
59
59
  json?: boolean;
60
60
  html?: boolean;
@@ -86,18 +86,18 @@ type MutateOpts = ConnOpts & {
86
86
  };
87
87
  /** `notes replace|delete NOTE_ID --lines a:b …`: with a span selector and no --note, a
88
88
  * 24-hex positional is the note, not a query (Notes API: IDs are primary). */
89
- export declare function positionalNote<T extends {
89
+ export declare function positionalMemo<T extends {
90
90
  note?: string;
91
91
  lines?: string;
92
92
  line?: string;
93
93
  address?: string;
94
94
  ind?: string;
95
95
  }>(query: string | undefined, opts: T): [string | undefined, T];
96
- export declare function runNotesReplace(query: string | undefined, opts: MutateOpts & {
96
+ export declare function runMemosReplace(query: string | undefined, opts: MutateOpts & {
97
97
  html?: string;
98
98
  }): Promise<number>;
99
99
  /** `notes delete` and its contract alias `notes remove`: delete selected source, never the Note. */
100
- export declare function runNotesDelete(query: string | undefined, opts: MutateOpts): Promise<number>;
100
+ export declare function runMemosDelete(query: string | undefined, opts: MutateOpts): Promise<number>;
101
101
  /** Set an element's inner source verbatim. Markup, not escaped. */
102
102
  export declare function elementHtmlPlan(source: string, css: string, html: string): EditPlan;
103
103
  export declare function setElementHtml(source: string, css: string, html: string): string;
@@ -108,13 +108,13 @@ type InsertOpts = MutateOpts & {
108
108
  cursor?: string;
109
109
  };
110
110
  /** `notes insert [NOTE] --before|--after ADDRESS | --cursor N | --line N | --ind N | --selector CSS`; the note may be positional (IDs are primary). */
111
- export declare function runNotesInsert(noteOrOpts: string | undefined | InsertOpts, maybeOpts?: InsertOpts): Promise<number>;
111
+ export declare function runMemosInsert(noteOrOpts: string | undefined | InsertOpts, maybeOpts?: InsertOpts): Promise<number>;
112
112
  /** `dreamlake notes select "#contact" --note NOTE` */
113
- export declare function runNotesSelect(css: string, opts: ConnOpts & {
113
+ export declare function runMemosSelect(css: string, opts: ConnOpts & {
114
114
  note?: string;
115
115
  json?: boolean;
116
116
  }): Promise<number>;
117
- export declare function runNotesGrep(query: string | undefined, opts: ConnOpts & {
117
+ export declare function runMemosGrep(query: string | undefined, opts: ConnOpts & {
118
118
  includeArchived?: boolean;
119
119
  regex?: string;
120
120
  flags?: string;