@dreamlake/dreamlake-cli 0.104.5 → 0.104.7
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/dist/api/content.d.ts +6 -0
- package/dist/api/content.js +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/note-events.js +7 -7
- package/dist/api/note-facade.js +8 -8
- package/dist/api/note-linger.js +4 -4
- package/dist/api/note-presence.js +1 -1
- package/dist/api/note-reading.js +3 -3
- package/dist/api/note-write.js +6 -6
- package/dist/api/notes.js +3 -3
- package/dist/cli/agents/index.js +4 -4
- package/dist/cli/artifact/index.js +6 -2
- package/dist/cli/artifact/rename.d.ts +9 -0
- package/dist/cli/artifact/rename.js +45 -0
- package/dist/cli/failure-report.js +3 -3
- package/dist/cli/help-examples.generated.js +38 -37
- package/dist/cli/index.js +2 -2
- package/dist/cli/notes/api-transport.js +3 -3
- package/dist/cli/notes/archive-command.js +8 -8
- package/dist/cli/notes/document.js +12 -12
- package/dist/cli/notes/edit-commands.js +7 -7
- package/dist/cli/notes/files-commands.js +6 -6
- package/dist/cli/notes/html-read.js +3 -3
- package/dist/cli/notes/index.js +126 -126
- package/dist/cli/notes/linger.js +2 -2
- package/dist/cli/notes/move-command.js +21 -21
- package/dist/cli/notes/rm-command.js +10 -10
- package/dist/cli/notes/select-command.js +3 -3
- package/dist/cli/notes/suggest-diff.js +2 -2
- package/dist/cli/notes/transfer-command.js +1 -1
- package/dist/cli/notes/version-commands.js +8 -8
- package/dist/cli/ownership/metadata-transfer.js +2 -2
- package/dist/cli/project/index.js +4 -4
- package/dist/cli/project/move.js +2 -2
- package/dist/cli/project/stream.js +1 -1
- package/dist/cli/session-affiliation.js +1 -1
- package/dist/cli/sessions/affiliation.js +4 -4
- package/dist/cli/sessions/api.js +1 -1
- package/dist/cli/sessions/control.js +1 -1
- package/dist/cli/sessions/index.js +2 -2
- package/dist/cli/share.js +3 -3
- package/dist/cli/tasks/index.js +4 -4
- package/dist/cli/update/index.js +3 -3
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -5,15 +5,15 @@ export function noteTransport(c) {
|
|
|
5
5
|
return {
|
|
6
6
|
request: async (method, path, options) => {
|
|
7
7
|
if (method === 'HEAD')
|
|
8
|
-
throw new RequestNotSent('
|
|
8
|
+
throw new RequestNotSent('Memos JSON transport does not support HEAD');
|
|
9
9
|
const { body, timeoutMs, ...request } = options ?? {};
|
|
10
10
|
if (body !== undefined)
|
|
11
|
-
throw new RequestNotSent('
|
|
11
|
+
throw new RequestNotSent('Memos collaboration transport requires JSON');
|
|
12
12
|
return requestJson(c.remote, path, { token: c.token, method, ...request, timeoutMs: timeoutMs ?? undefined });
|
|
13
13
|
},
|
|
14
14
|
raw: async (method, path, options) => {
|
|
15
15
|
if (method !== 'GET' && method !== 'HEAD')
|
|
16
|
-
throw new RequestNotSent('
|
|
16
|
+
throw new RequestNotSent('Memos streaming transport requires GET or HEAD');
|
|
17
17
|
return requestRaw(requestUrl(c.remote, path, options?.query), { token: c.token, method, headers: options?.headers, signal: options?.signal, timeoutMs: options?.timeoutMs ?? undefined, followRedirects: false });
|
|
18
18
|
},
|
|
19
19
|
};
|
|
@@ -24,15 +24,15 @@ export async function runNotesArchive(ref, archived, opts) {
|
|
|
24
24
|
}
|
|
25
25
|
const note = await requestJson(c.remote, `/notes/${seg(id)}`, { token });
|
|
26
26
|
if (note.id !== id || !note.namespaceSlug) {
|
|
27
|
-
fail("server did not return the
|
|
27
|
+
fail("server did not return the memo's owning namespace");
|
|
28
28
|
return 1;
|
|
29
29
|
}
|
|
30
30
|
if (asserted && asserted !== note.namespaceSlug) {
|
|
31
|
-
fail(`
|
|
31
|
+
fail(`memo ${id} is in '${note.namespaceSlug}', not --namespace '${asserted}'`);
|
|
32
32
|
return 1;
|
|
33
33
|
}
|
|
34
34
|
if (note.permissions?.rename === false) {
|
|
35
|
-
fail('you do not have permission to archive this
|
|
35
|
+
fail('you do not have permission to archive this memo');
|
|
36
36
|
return 1;
|
|
37
37
|
}
|
|
38
38
|
const api = notesApi(noteTransport({ remote: c.remote, token }), note.namespaceSlug);
|
|
@@ -40,7 +40,7 @@ export async function runNotesArchive(ref, archived, opts) {
|
|
|
40
40
|
if (opts.json)
|
|
41
41
|
emitJson(result);
|
|
42
42
|
else
|
|
43
|
-
process.stdout.write(`✓ ${archived ? 'archived' : 'unarchived'}
|
|
43
|
+
process.stdout.write(`✓ ${archived ? 'archived' : 'unarchived'} memo ${id}\n`);
|
|
44
44
|
return 0;
|
|
45
45
|
}
|
|
46
46
|
catch (error) {
|
|
@@ -50,10 +50,10 @@ export async function runNotesArchive(ref, archived, opts) {
|
|
|
50
50
|
export function registerArchiveCommands(notes) {
|
|
51
51
|
for (const action of ['archive', 'unarchive']) {
|
|
52
52
|
withConnFlags(notes.command(action).allowExcessArguments(false))
|
|
53
|
-
.description(action === 'archive' ? 'archive a
|
|
54
|
-
.argument('<note>', '
|
|
55
|
-
.option('--namespace <slug>', 'whose
|
|
56
|
-
.option('--json', 'emit the updated
|
|
53
|
+
.description(action === 'archive' ? 'archive a memo without deleting it or removing its filings' : 'unarchive a memo and restore its folder path')
|
|
54
|
+
.argument('<note>', 'memo id, slug or exact title')
|
|
55
|
+
.option('--namespace <slug>', 'whose memos for lookup; with an id, asserts the owner')
|
|
56
|
+
.option('--json', 'emit the updated memo metadata')
|
|
57
57
|
.action(async (note, opts) => { process.exitCode = await runNotesArchive(note, action === 'archive', opts); });
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -17,7 +17,7 @@ function format(value) {
|
|
|
17
17
|
export function tokens(result, note) {
|
|
18
18
|
if (!result || result.note !== note || !/^sha256:[a-f0-9]{64}$/.test(result.hash)
|
|
19
19
|
|| typeof result.revision !== "string" || !result.revision || /[\r\n]/.test(result.revision)) {
|
|
20
|
-
throw new Error("server did not return the
|
|
20
|
+
throw new Error("server did not return the Memos v2 contract; upgrade the server or explicitly use --legacy");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
function printTokens(result) {
|
|
@@ -127,7 +127,7 @@ export function documentWriteError(error) {
|
|
|
127
127
|
return 1;
|
|
128
128
|
}
|
|
129
129
|
if (error instanceof CommandIdentityUnsupported) {
|
|
130
|
-
fail(`${error.message}; the write may have been applied: inspect the
|
|
130
|
+
fail(`${error.message}; the write may have been applied: inspect the memo before resubmitting, and upgrade the server before relying on --command-id`);
|
|
131
131
|
return 4;
|
|
132
132
|
}
|
|
133
133
|
// The core turns a PATCH 503 into a typed outcome above, so a raw 503 here came from the
|
|
@@ -141,7 +141,7 @@ export function documentWriteError(error) {
|
|
|
141
141
|
const reason = error.status === 412 ? "the original revision or RTC identities are no longer valid for this request"
|
|
142
142
|
: error.status === 422 ? "the patch was rejected; inspect the server explanation and preserve the original snapshot and draft"
|
|
143
143
|
: "the realtime acknowledgment is unavailable; the result may be ambiguous";
|
|
144
|
-
fail(`${reason}; keep the original baseline and draft, inspect the
|
|
144
|
+
fail(`${reason}; keep the original baseline and draft, inspect the memo before resubmitting (${error.message})`);
|
|
145
145
|
return error.status === 412 ? 3 : error.status === 422 ? 5 : 4;
|
|
146
146
|
}
|
|
147
147
|
return report(error);
|
|
@@ -172,7 +172,7 @@ export async function runDocumentRead(ref, opts) {
|
|
|
172
172
|
const selectedFormat = format(opts.format ?? "diff");
|
|
173
173
|
const target = ref ?? opts.note;
|
|
174
174
|
if (!target || (ref && opts.note && ref !== opts.note))
|
|
175
|
-
throw new Error("give one
|
|
175
|
+
throw new Error("give one memo id, slug or name");
|
|
176
176
|
if ((opts.at !== undefined && (!opts.at.trim() || opts.at === "*" || /[\r\n]/.test(opts.at))))
|
|
177
177
|
throw new Error("--at requires an exact retained revision");
|
|
178
178
|
if (opts.at && (opts.since !== undefined || opts.ifMatch !== undefined))
|
|
@@ -194,7 +194,7 @@ export async function runDocumentRead(ref, opts) {
|
|
|
194
194
|
const lines = parseLines(opts.lines);
|
|
195
195
|
const focused = focusedRead(await readDocumentSnapshot(c, id, opts.at), lines);
|
|
196
196
|
if (opts.ifMatch && focused.revision !== opts.ifMatch) {
|
|
197
|
-
fail("
|
|
197
|
+
fail("memo changed since the acknowledged revision; keep the original draft and baseline");
|
|
198
198
|
return 3;
|
|
199
199
|
}
|
|
200
200
|
if (opts.json)
|
|
@@ -222,13 +222,13 @@ export async function runDocumentRead(ref, opts) {
|
|
|
222
222
|
break;
|
|
223
223
|
}
|
|
224
224
|
if (page.sourceType !== 'markdown')
|
|
225
|
-
throw new Error('annotated Markdown requires a Markdown
|
|
225
|
+
throw new Error('annotated Markdown requires a Markdown memo; use --view html for HTML source');
|
|
226
226
|
if (opts.ifMatch && page.revision !== opts.ifMatch) {
|
|
227
|
-
fail("
|
|
227
|
+
fail("memo changed since the acknowledged revision; keep the original draft and baseline");
|
|
228
228
|
return 3;
|
|
229
229
|
}
|
|
230
230
|
if (hash !== undefined && (hash !== page.hash || total !== page.total))
|
|
231
|
-
throw new Error('
|
|
231
|
+
throw new Error('Memo reading view changed during pagination');
|
|
232
232
|
hash = page.hash;
|
|
233
233
|
total = page.total;
|
|
234
234
|
at = page.revision;
|
|
@@ -254,14 +254,14 @@ export async function runDocumentRead(ref, opts) {
|
|
|
254
254
|
const response = await requestRaw(url, { token: c.token, timeoutMs: 30000, followRedirects: false,
|
|
255
255
|
headers: { Accept: "text/html", ...(opts.ifMatch ? { "If-Match": opts.ifMatch } : {}) } });
|
|
256
256
|
if (!/^text\/(?:html|plain)(?:;|$)/i.test(response.headers.get("content-type") ?? ""))
|
|
257
|
-
throw new Error("server did not return
|
|
257
|
+
throw new Error("server did not return Memos HTML; upgrade the server");
|
|
258
258
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
259
259
|
const html = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
260
260
|
const snapshot = validateHtmlSnapshot(html, id, { section: opts.section, toc: opts.toc, tag: opts.tag });
|
|
261
261
|
if (opts.at && snapshot.revision !== opts.at)
|
|
262
262
|
throw new Error("server did not return the requested pinned revision");
|
|
263
263
|
if (opts.ifMatch && snapshot.revision !== opts.ifMatch) {
|
|
264
|
-
fail("
|
|
264
|
+
fail("memo changed since the acknowledged revision; keep the original draft and baseline");
|
|
265
265
|
return 3;
|
|
266
266
|
}
|
|
267
267
|
process.stdout.write(bytes);
|
|
@@ -278,12 +278,12 @@ export async function runDocumentRead(ref, opts) {
|
|
|
278
278
|
if (opts.at && result.revision !== opts.at)
|
|
279
279
|
throw new Error("server did not return the requested pinned revision");
|
|
280
280
|
if (opts.ifMatch && result.revision !== opts.ifMatch) {
|
|
281
|
-
fail("
|
|
281
|
+
fail("memo changed since the acknowledged revision; keep the original draft and baseline");
|
|
282
282
|
return 3;
|
|
283
283
|
}
|
|
284
284
|
if (opts.since !== undefined) {
|
|
285
285
|
if (result.format !== selectedFormat || typeof result.patch !== "string" || !/^sha256:[a-f0-9]{64}$/.test(result.base ?? ""))
|
|
286
|
-
throw new Error("invalid incremental
|
|
286
|
+
throw new Error("invalid incremental Memos v2 response");
|
|
287
287
|
}
|
|
288
288
|
else {
|
|
289
289
|
validateSourceHash(result);
|
|
@@ -160,7 +160,7 @@ export function insertAtElement(source, css, text, position) {
|
|
|
160
160
|
/** The note to act on. `--note` per the documented CLI shape. */
|
|
161
161
|
function requireNote(opts) {
|
|
162
162
|
if (!opts.note) {
|
|
163
|
-
fail("say which
|
|
163
|
+
fail("say which memo: --note <id-or-slug>");
|
|
164
164
|
return null;
|
|
165
165
|
}
|
|
166
166
|
return opts.note;
|
|
@@ -250,7 +250,7 @@ async function mutate(opts, apply) {
|
|
|
250
250
|
if (!ref)
|
|
251
251
|
return 1;
|
|
252
252
|
if (opts.ifMatch?.replace(/^W\//, '').replace(/^"|"$/g, '').startsWith('rtc:')) {
|
|
253
|
-
fail('This legacy edit requires the quoted ETag from
|
|
253
|
+
fail('This legacy edit requires the quoted ETag from memos read --legacy --json, not an rtc: revision. Preserve the draft and read the legacy baseline, or use memos patch --base-revision for a modern merge edit.');
|
|
254
254
|
return 1;
|
|
255
255
|
}
|
|
256
256
|
const c = await ctx(opts);
|
|
@@ -502,7 +502,7 @@ export async function runNotesInsert(noteOrOpts, maybeOpts) {
|
|
|
502
502
|
let opts = typeof noteOrOpts === "object" && noteOrOpts !== null ? noteOrOpts : (maybeOpts ?? {});
|
|
503
503
|
if (typeof noteOrOpts === "string") {
|
|
504
504
|
if (opts.note !== undefined && opts.note !== noteOrOpts) {
|
|
505
|
-
fail(`two
|
|
505
|
+
fail(`two memos given: '${noteOrOpts}' and --note '${opts.note}' — give one`);
|
|
506
506
|
return 1;
|
|
507
507
|
}
|
|
508
508
|
opts = { ...opts, note: noteOrOpts };
|
|
@@ -734,15 +734,15 @@ export async function runNotesGrep(query, opts) {
|
|
|
734
734
|
// because a bounded answer that looks complete is how "replace them all"
|
|
735
735
|
// quietly replaces some of them.
|
|
736
736
|
if (!hits.length)
|
|
737
|
-
process.stderr.write(`no matches in ${notesSearched}
|
|
737
|
+
process.stderr.write(`no matches in ${notesSearched} memos\n`);
|
|
738
738
|
if (truncated) {
|
|
739
|
-
process.stderr.write("note: a
|
|
739
|
+
process.stderr.write("note: a memo held more matches than were returned — narrow the query\n");
|
|
740
740
|
}
|
|
741
741
|
if (partial.size) {
|
|
742
|
-
process.stderr.write(`note: ${partial.size}
|
|
742
|
+
process.stderr.write(`note: ${partial.size} memo(s) too large to index in full; their tails were not searched\n`);
|
|
743
743
|
}
|
|
744
744
|
if (stale) {
|
|
745
|
-
process.stderr.write(`note: ${stale} open
|
|
745
|
+
process.stderr.write(`note: ${stale} open memo(s) could not be flushed first; their newest edits are missing\n`);
|
|
746
746
|
}
|
|
747
747
|
return 0;
|
|
748
748
|
}
|
|
@@ -29,7 +29,7 @@ function filesBase(c, id) {
|
|
|
29
29
|
/** Resolve the note every file command needs. */
|
|
30
30
|
async function target(opts) {
|
|
31
31
|
if (!opts.note) {
|
|
32
|
-
fail("say which
|
|
32
|
+
fail("say which memo: --note <id-or-slug>");
|
|
33
33
|
return null;
|
|
34
34
|
}
|
|
35
35
|
const c = await ctx(opts);
|
|
@@ -56,7 +56,7 @@ function reportFile(err, recovery) {
|
|
|
56
56
|
}
|
|
57
57
|
catch { }
|
|
58
58
|
if (operationId)
|
|
59
|
-
process.stderr.write(`operation ${operationId} — inspect with
|
|
59
|
+
process.stderr.write(`operation ${operationId} — inspect with memos files status ${operationId} --note ${recovery.note}${recovery.namespace ? ` --namespace ${JSON.stringify(recovery.namespace)}` : ""}\n`);
|
|
60
60
|
process.stderr.write("Do not resend attachment bytes after an uncertain result; inspect the original operation first.\n");
|
|
61
61
|
}
|
|
62
62
|
const status = err?.status;
|
|
@@ -301,7 +301,7 @@ export async function runFilesCat(ref, opts) {
|
|
|
301
301
|
// Refused here rather than at the server, so the reason names the local
|
|
302
302
|
// alternative instead of an HTTP status.
|
|
303
303
|
fail(`${row.path} is ${row.contentType}; printing it as text would corrupt it — ` +
|
|
304
|
-
"use '
|
|
304
|
+
"use 'memos files download' instead");
|
|
305
305
|
return EXIT_NO_FILE;
|
|
306
306
|
}
|
|
307
307
|
const res = await requestJson(t.c.remote, `${filesBase(t.c, t.id)}/${seg(row.id)}/text`, { token: t.c.token });
|
|
@@ -454,7 +454,7 @@ export async function runFilesRm(ref, opts) {
|
|
|
454
454
|
return emitJson(res), 0;
|
|
455
455
|
process.stdout.write(res.purged
|
|
456
456
|
? `✓ purged ${row.path} — the bytes are gone\n`
|
|
457
|
-
: `✓ trashed ${row.path} — restore with '
|
|
457
|
+
: `✓ trashed ${row.path} — restore with 'memos files restore ${row.id}'\n`);
|
|
458
458
|
return 0;
|
|
459
459
|
}
|
|
460
460
|
catch (e) {
|
|
@@ -495,7 +495,7 @@ export async function resolveFile(c, noteId, ref, opts = {}) {
|
|
|
495
495
|
catch (error) {
|
|
496
496
|
if (error.status !== 404)
|
|
497
497
|
throw error;
|
|
498
|
-
fail(/^[a-f0-9]{24}$/i.test(ref) ? `no file with id ${ref}` : `no file at '${ref}' — '
|
|
498
|
+
fail(/^[a-f0-9]{24}$/i.test(ref) ? `no file with id ${ref}` : `no file at '${ref}' — 'memos files list --note …' shows what is there`);
|
|
499
499
|
return null;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
@@ -534,7 +534,7 @@ export async function runFilesPreview(ref, opts) {
|
|
|
534
534
|
// said rather than left to be discovered by sending the wrong one.
|
|
535
535
|
process.stderr.write(res.kind === "shared"
|
|
536
536
|
? "shared link — opens without signing in, until you revoke it\n"
|
|
537
|
-
: "session link — whoever opens it must be signed in and able to read the
|
|
537
|
+
: "session link — whoever opens it must be signed in and able to read the memo\n");
|
|
538
538
|
if (opts.open) {
|
|
539
539
|
const cmd = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
540
540
|
const { spawn } = await import("node:child_process");
|
|
@@ -17,7 +17,7 @@ function attributeValue(value) {
|
|
|
17
17
|
export function validateHtmlSnapshot(html, note, scope = {}) {
|
|
18
18
|
const root = /^<!doctype html>\s*<html\b([^>]*)>/i.exec(html);
|
|
19
19
|
if (!root || !/<\/html>\s*$/i.test(html))
|
|
20
|
-
throw new Error("server did not return a complete
|
|
20
|
+
throw new Error("server did not return a complete Memos HTML snapshot");
|
|
21
21
|
const attributes = new Map();
|
|
22
22
|
const pattern = /\s+([a-zA-Z][a-zA-Z0-9-]*)="([^"]*)"/g;
|
|
23
23
|
let end = 0;
|
|
@@ -37,7 +37,7 @@ export function validateHtmlSnapshot(html, note, scope = {}) {
|
|
|
37
37
|
|| !/^sha256:[a-f0-9]{64}$/.test(hash ?? "") || source === undefined
|
|
38
38
|
|| attributes.get("data-offset-unit") !== "unicode-code-point"
|
|
39
39
|
|| !["markdown", "html"].includes(attributes.get("data-source-type") ?? "")) {
|
|
40
|
-
throw new Error("server did not return the
|
|
40
|
+
throw new Error("server did not return the Memos HTML metadata contract; upgrade the server");
|
|
41
41
|
}
|
|
42
42
|
const returnedScope = attributes.get("data-scope");
|
|
43
43
|
let sourceHash = hash;
|
|
@@ -78,7 +78,7 @@ export function annotatedMarkdown(html) {
|
|
|
78
78
|
const attrs = (raw) => new Map(Array.from(raw.matchAll(/\s+([a-zA-Z][a-zA-Z0-9-]*)="([^"]*)"/g), m => [m[1], attributeValue(m[2])]));
|
|
79
79
|
const root = attrs(/^<!doctype html>\s*<html\b([^>]*)>/i.exec(html)[1]);
|
|
80
80
|
if (root.get('data-source-type') !== 'markdown')
|
|
81
|
-
throw new Error('annotated Markdown requires a Markdown
|
|
81
|
+
throw new Error('annotated Markdown requires a Markdown memo; use --view html for HTML source');
|
|
82
82
|
const source = root.get('data-source');
|
|
83
83
|
const origin = Number(root.get('data-source-start') ?? 0);
|
|
84
84
|
const points = Array.from(source);
|