@dreamlake/dreamlake-cli 0.112.1 → 0.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/memo-facade.d.ts +7 -0
- package/dist/api/memo-facade.js +2 -0
- package/dist/api/memos.d.ts +3 -0
- package/dist/api/memos.js +15 -0
- package/dist/cli/help-examples.generated.js +1 -0
- package/dist/cli/memos/cover-command.d.ts +9 -0
- package/dist/cli/memos/cover-command.js +81 -0
- package/dist/cli/memos/index.js +2 -0
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -175,6 +175,13 @@ export interface MemoHandle {
|
|
|
175
175
|
readonly namespace: string | undefined;
|
|
176
176
|
/** The id or slug the handle was opened with. */
|
|
177
177
|
readonly note: string;
|
|
178
|
+
metadata(): Promise<MemoRow & {
|
|
179
|
+
namespaceSlug: string;
|
|
180
|
+
permissions: Record<string, boolean>;
|
|
181
|
+
}>;
|
|
182
|
+
setCover(input: {
|
|
183
|
+
fileId: string | null;
|
|
184
|
+
}): Promise<MemoRow>;
|
|
178
185
|
read(options: MemoReadOptions & {
|
|
179
186
|
lines: [number, number];
|
|
180
187
|
}): Promise<MemoFocusedRead>;
|
package/dist/api/memo-facade.js
CHANGED
|
@@ -186,6 +186,8 @@ export function memoHandle(t, ref, context = {}) {
|
|
|
186
186
|
ref, note: parsed.note,
|
|
187
187
|
get namespace() { return namespace; },
|
|
188
188
|
read: read,
|
|
189
|
+
metadata: () => guarded(async (api) => api.get(await id(api))),
|
|
190
|
+
setCover: ({ fileId }) => guarded(async (api) => api.setCover(await id(api), fileId), "write"),
|
|
189
191
|
async append(input) {
|
|
190
192
|
const mode = modeOf(input.mode, "merge");
|
|
191
193
|
if (typeof input.text !== "string")
|
package/dist/api/memos.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export interface MemoSearchPage {
|
|
|
37
37
|
staleNotes: number;
|
|
38
38
|
}
|
|
39
39
|
export interface MemoRow {
|
|
40
|
+
coverFileId?: string | null;
|
|
40
41
|
id: string;
|
|
41
42
|
name: string;
|
|
42
43
|
slug: string;
|
|
@@ -143,6 +144,8 @@ export declare function memosApi(t: Transport, namespace: string): {
|
|
|
143
144
|
namespaceSlug: string;
|
|
144
145
|
permissions: Record<string, boolean>;
|
|
145
146
|
}>;
|
|
147
|
+
/** Metadata only: an image attachment ID sets the cover; null clears it. */
|
|
148
|
+
setCover: (noteId: string, coverFileId: string | null) => Promise<MemoRow>;
|
|
146
149
|
/** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
|
|
147
150
|
archive: (noteId: string) => Promise<MemoRow>;
|
|
148
151
|
unarchive: (noteId: string) => Promise<MemoRow>;
|
package/dist/api/memos.js
CHANGED
|
@@ -116,6 +116,21 @@ export function memosApi(t, namespace) {
|
|
|
116
116
|
};
|
|
117
117
|
},
|
|
118
118
|
get: (noteId) => t.request("GET", `/notes/${id(noteId)}`),
|
|
119
|
+
/** Metadata only: an image attachment ID sets the cover; null clears it. */
|
|
120
|
+
setCover: async (noteId, coverFileId) => {
|
|
121
|
+
id(noteId);
|
|
122
|
+
if (coverFileId !== null && (typeof coverFileId !== "string" || !isObjectId(coverFileId)))
|
|
123
|
+
throw new TypeError("coverFileId must be a 24-hex attachment ID or null");
|
|
124
|
+
const current = await api.get(noteId);
|
|
125
|
+
if (current.id !== noteId || current.namespaceSlug !== namespace)
|
|
126
|
+
throw new ApiError(404, "memo_owner_changed", {});
|
|
127
|
+
if (current.permissions?.rename !== true)
|
|
128
|
+
throw new ApiError(403, "forbidden", {});
|
|
129
|
+
const row = await t.request("PATCH", `${base}/${noteId}`, { json: { coverFileId }, redirect: "error" });
|
|
130
|
+
if (row?.id !== noteId || row.namespaceSlug !== namespace || row.coverFileId !== coverFileId)
|
|
131
|
+
throw new Error("Cover update unconfirmed; read memo metadata before retrying");
|
|
132
|
+
return row;
|
|
133
|
+
},
|
|
119
134
|
/** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
|
|
120
135
|
archive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: true } }),
|
|
121
136
|
unarchive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: false } }),
|
|
@@ -117,6 +117,7 @@ export const helpExamples = {
|
|
|
117
117
|
"memos files status": "# OPERATION_ID is the ID from the original response.\ndl memos files status \"$OPERATION_ID\" --note \"$MEMO_ID\" --json",
|
|
118
118
|
"memos files reconcile": "dl memos files reconcile \"$OPERATION_ID\" --note \"$MEMO_ID\" --json",
|
|
119
119
|
"memos files cancel": "dl memos files cancel \"$OPERATION_ID\" --note \"$MEMO_ID\" --json",
|
|
120
|
+
"memos cover": "# Upload or replace the header image; inspect the current attachment ID.\ndl memos cover \"$MEMO_ID\" --namespace team --file ./cover.png\ndl memos cover \"$MEMO_ID\" --namespace team --json\n# Select an existing image attachment, or clear the header while retaining it.\ndl memos cover \"$MEMO_ID\" --namespace team --file-id \"$FILE_ID\"\ndl memos cover \"$MEMO_ID\" --namespace team --remove",
|
|
120
121
|
"memos visit": "# Reuse the task's DREAMLAKE_AGENT_ID and DREAMLAKE_AGENT_NAME.\nMEMO_ID=release-plan\ndl memos visit \"$MEMO_ID\"",
|
|
121
122
|
"memos presence": "# Read the participant roster without joining. Text is the default.\nMEMO_ID=release-plan\ndl memos presence \"$MEMO_ID\"\n# Include a source-bound human selection snapshot.\ndl memos presence \"$MEMO_ID\" --selections",
|
|
122
123
|
"memos select": "export DREAMLAKE_AGENT_ID=\"review-session-42\"\nexport DREAMLAKE_AGENT_NAME=\"Codex\"\nMEMO_ID=\"your-note-id\"\ndl memos select --text \"The next step is tested in simulation.\" --note \"$MEMO_ID\"\n# Select the last occurrence of a repeated passage.\ndl memos select --text \"simulation\" --note \"$MEMO_ID\" -o -1",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { type ConnOpts } from './index.js';
|
|
3
|
+
export declare function runMemosCover(ref: string, opts: ConnOpts & {
|
|
4
|
+
file?: string;
|
|
5
|
+
fileId?: string;
|
|
6
|
+
remove?: boolean;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}): Promise<number>;
|
|
9
|
+
export declare function registerCoverCommand(memos: Command): void;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createReadStream, statSync } from 'node:fs';
|
|
2
|
+
import { extname } from 'node:path';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { memoHandle } from '../../api/memo-facade.js';
|
|
5
|
+
import { resolveCtx } from '../compat/ctx.js';
|
|
6
|
+
import { requireToken } from '../compat/http.js';
|
|
7
|
+
import { withConnFlags } from '../compat/flags.js';
|
|
8
|
+
import { emitJson, fail } from '../helpers.js';
|
|
9
|
+
import { requestJson } from '../client.js';
|
|
10
|
+
import { memoTransport } from './api-transport.js';
|
|
11
|
+
import { ctx, resolveNote } from './index.js';
|
|
12
|
+
const mime = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp', '.avif': 'image/avif', '.svg': 'image/svg+xml' };
|
|
13
|
+
export async function runMemosCover(ref, opts) {
|
|
14
|
+
if ([opts.file !== undefined, opts.fileId !== undefined, opts.remove === true].filter(Boolean).length > 1) {
|
|
15
|
+
fail('Choose only --file, --file-id or --remove');
|
|
16
|
+
return 1;
|
|
17
|
+
}
|
|
18
|
+
const c = resolveCtx(opts), token = requireToken(c);
|
|
19
|
+
if (!token)
|
|
20
|
+
return 1;
|
|
21
|
+
let uploadedId;
|
|
22
|
+
try {
|
|
23
|
+
let target = ref, namespace = opts.namespace?.trim().replace(/^@/, '') || undefined;
|
|
24
|
+
if (!/^[a-f0-9]{24}$/i.test(ref) && !ref.includes('/')) {
|
|
25
|
+
const scope = await ctx(opts);
|
|
26
|
+
if (!scope)
|
|
27
|
+
return 1;
|
|
28
|
+
const id = await resolveNote(scope, ref);
|
|
29
|
+
if (!id)
|
|
30
|
+
return 1;
|
|
31
|
+
target = id;
|
|
32
|
+
namespace = scope.ns;
|
|
33
|
+
}
|
|
34
|
+
const memo = memoHandle(memoTransport({ remote: c.remote, token }), target, { namespace });
|
|
35
|
+
const current = await memo.metadata();
|
|
36
|
+
if (memo.namespace !== current.namespaceSlug)
|
|
37
|
+
throw new Error('Memo owner changed; reopen it before updating the cover');
|
|
38
|
+
let fileId = opts.remove ? null : opts.fileId;
|
|
39
|
+
if (opts.file !== undefined) {
|
|
40
|
+
if (current.permissions?.rename !== true)
|
|
41
|
+
throw new Error('Not allowed to manage this memo');
|
|
42
|
+
const ext = extname(opts.file).toLowerCase(), contentType = mime[ext];
|
|
43
|
+
if (!contentType)
|
|
44
|
+
throw new Error('Choose a PNG, JPEG, GIF, WebP, AVIF or SVG image');
|
|
45
|
+
const stat = statSync(opts.file);
|
|
46
|
+
if (!stat.isFile())
|
|
47
|
+
throw new Error('--file must name a regular image file');
|
|
48
|
+
const bun = globalThis.Bun;
|
|
49
|
+
const bytes = bun ? bun.file(opts.file).stream() : createReadStream(opts.file);
|
|
50
|
+
const query = new URLSearchParams({ path: `covers/${randomUUID()}${ext}`, contentType });
|
|
51
|
+
const uploaded = await requestJson(c.remote, `/namespaces/${encodeURIComponent(current.namespaceSlug)}/notes/${current.id}/files/content?${query}`, {
|
|
52
|
+
method: 'PUT', token, body: bytes, redirect: 'error', headers: { 'Content-Type': contentType, ...(bun ? {} : { 'Content-Length': String(stat.size) }) },
|
|
53
|
+
});
|
|
54
|
+
if (!/^[a-f0-9]{24}$/i.test(uploaded?.id))
|
|
55
|
+
throw new Error('Upload unconfirmed; inspect memo files before retrying');
|
|
56
|
+
fileId = uploadedId = uploaded.id;
|
|
57
|
+
}
|
|
58
|
+
const row = fileId === undefined ? current : await memo.setCover({ fileId });
|
|
59
|
+
const result = { id: row.id, namespace: current.namespaceSlug, coverFileId: row.coverFileId ?? null };
|
|
60
|
+
if (opts.json)
|
|
61
|
+
emitJson(result);
|
|
62
|
+
else
|
|
63
|
+
process.stdout.write(`${result.coverFileId ?? 'No cover'}\n`);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
fail(`${error instanceof Error ? error.message : String(error)}${uploadedId ? ` (uploaded attachment ${uploadedId} retained; inspect metadata before retrying)` : ''}`);
|
|
68
|
+
return 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function registerCoverCommand(memos) {
|
|
72
|
+
withConnFlags(memos.command('cover').alias('title-image').allowExcessArguments(false))
|
|
73
|
+
.description('inspect, upload, replace or remove a memo cover image without changing its body')
|
|
74
|
+
.argument('<memo>', 'memo ID, qualified reference, slug or exact title')
|
|
75
|
+
.option('--namespace <slug>', 'lookup namespace; with an ID, asserts the owner')
|
|
76
|
+
.option('--file <path>', 'upload a new image attachment and set it as the cover')
|
|
77
|
+
.option('--file-id <id>', 'use an existing image attachment from this memo')
|
|
78
|
+
.option('--remove', 'remove the cover; keep its attachment')
|
|
79
|
+
.option('--json', 'emit cover metadata')
|
|
80
|
+
.action(async (memo, opts) => { process.exitCode = await runMemosCover(memo, opts); });
|
|
81
|
+
}
|
package/dist/cli/memos/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { collectionList } from "../collection-list.js";
|
|
|
4
4
|
import { registerVersionCommands, runSavedVersionRead } from "./version-commands.js";
|
|
5
5
|
import { registerMoveCommand } from "./move-command.js";
|
|
6
6
|
import { registerTransferCommand } from "./transfer-command.js";
|
|
7
|
+
import { registerCoverCommand } from "./cover-command.js";
|
|
7
8
|
import { registerPermalinkCommand } from "./permalink-command.js";
|
|
8
9
|
import { registerArchiveCommands } from "./archive-command.js";
|
|
9
10
|
import { registerRmCommand } from "./rm-command.js";
|
|
@@ -203,6 +204,7 @@ export function registerMemosCommand(program) {
|
|
|
203
204
|
registerRmCommand(notes);
|
|
204
205
|
registerArchiveCommands(notes);
|
|
205
206
|
registerPermalinkCommand(notes);
|
|
207
|
+
registerCoverCommand(notes);
|
|
206
208
|
registerSuggestDiffCommand(notes);
|
|
207
209
|
// Same connection flags as the other ported groups, so --debug/--remote
|
|
208
210
|
// behave identically across the CLI.
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.113.0";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.113.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"node": ">=18"
|
|
38
38
|
},
|
|
39
39
|
"optionalDependencies": {
|
|
40
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.
|
|
41
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
44
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
45
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
46
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
47
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
40
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.113.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.113.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.113.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.113.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.113.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.113.0",
|
|
46
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.113.0",
|
|
47
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.113.0"
|
|
48
48
|
}
|
|
49
49
|
}
|