@dreamlake/dreamlake-cli 0.109.0 → 0.110.1

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.
@@ -10,6 +10,7 @@ export declare function artifactsApi(t: Transport, namespace: string): {
10
10
  description?: string;
11
11
  visibility?: ArtifactVisibility;
12
12
  share?: boolean;
13
+ shareLatestOnly?: boolean;
13
14
  }, store: VersionedContentStore) => Promise<{
14
15
  version: number;
15
16
  receipt: unknown;
@@ -32,6 +33,7 @@ export declare function artifactsApi(t: Transport, namespace: string): {
32
33
  description?: string;
33
34
  visibility?: ArtifactVisibility;
34
35
  share?: boolean;
36
+ shareLatestOnly?: boolean;
35
37
  }) => Promise<unknown>;
36
38
  delete: (id: string, permanent?: boolean) => Promise<unknown>;
37
39
  restore: (id: string) => Promise<unknown>;
@@ -40,6 +42,7 @@ export declare function artifactsApi(t: Transport, namespace: string): {
40
42
  set: (input: JsonObject) => Promise<unknown>;
41
43
  };
42
44
  share: (id: string) => {
45
+ latestOnly: (enabled: boolean) => Promise<Record<string, unknown>>;
43
46
  get: () => Promise<Record<string, unknown>>;
44
47
  create: (role?: "read" | "write") => Promise<unknown>;
45
48
  revoke: (revokeAccepted?: boolean) => Promise<unknown>;
@@ -19,6 +19,7 @@ export function artifactsApi(t, namespace) {
19
19
  : {}),
20
20
  ...(input.visibility ? { visibility: input.visibility } : {}),
21
21
  ...(input.share !== undefined ? { share: input.share } : {}),
22
+ ...(input.shareLatestOnly !== undefined ? { shareLatestOnly: input.shareLatestOnly } : {}),
22
23
  }),
23
24
  }),
24
25
  list: (query = {}) => call(t, "GET", base, undefined, query),
@@ -32,7 +33,22 @@ export function artifactsApi(t, namespace) {
32
33
  get: () => call(t, "GET", path(id) + "/meta"),
33
34
  set: (input) => call(t, "PUT", path(id) + "/meta", input),
34
35
  }),
35
- share: (id) => sharingApi(t, namespace, "artifacts", id),
36
+ share: (id) => ({
37
+ ...sharingApi(t, namespace, "artifacts", id),
38
+ latestOnly: async (enabled) => {
39
+ if (typeof enabled !== "boolean")
40
+ throw new TypeError("latestOnly requires a boolean");
41
+ const row = await call(t, "GET", path(id));
42
+ if (row.viewerCanManage !== true)
43
+ throw new Error("not allowed to manage sharing for this resource");
44
+ if (typeof row.artifactId !== "string")
45
+ throw new Error("invalid artifact metadata");
46
+ const result = await call(t, "POST", path(row.artifactId), { shareLatestOnly: enabled });
47
+ if (result.shareLatestOnly !== enabled)
48
+ throw new Error("server did not confirm latest-only sharing; read metadata before retrying");
49
+ return result;
50
+ },
51
+ }),
36
52
  };
37
53
  }
38
54
  export function scenesApi(t, namespace) {
@@ -943,6 +943,7 @@ export declare function createApi(transport: Transport): {
943
943
  description?: string;
944
944
  visibility?: import("./workspace.js").ArtifactVisibility;
945
945
  share?: boolean;
946
+ shareLatestOnly?: boolean;
946
947
  }, store: import("./storage.js").VersionedContentStore) => Promise<{
947
948
  version: number;
948
949
  receipt: unknown;
@@ -965,6 +966,7 @@ export declare function createApi(transport: Transport): {
965
966
  description?: string;
966
967
  visibility?: import("./workspace.js").ArtifactVisibility;
967
968
  share?: boolean;
969
+ shareLatestOnly?: boolean;
968
970
  }) => Promise<unknown>;
969
971
  delete: (id: string, permanent?: boolean) => Promise<unknown>;
970
972
  restore: (id: string) => Promise<unknown>;
@@ -973,6 +975,7 @@ export declare function createApi(transport: Transport): {
973
975
  set: (input: import("./common.js").JsonObject) => Promise<unknown>;
974
976
  };
975
977
  share: (id: string) => {
978
+ latestOnly: (enabled: boolean) => Promise<Record<string, unknown>>;
976
979
  get: () => Promise<Record<string, unknown>>;
977
980
  create: (role?: "read" | "write") => Promise<unknown>;
978
981
  revoke: (revokeAccepted?: boolean) => Promise<unknown>;
@@ -2227,6 +2230,7 @@ export declare function createClient(options: ClientOptions): {
2227
2230
  description?: string;
2228
2231
  visibility?: import("./workspace.js").ArtifactVisibility;
2229
2232
  share?: boolean;
2233
+ shareLatestOnly?: boolean;
2230
2234
  }, store: import("./storage.js").VersionedContentStore) => Promise<{
2231
2235
  version: number;
2232
2236
  receipt: unknown;
@@ -2249,6 +2253,7 @@ export declare function createClient(options: ClientOptions): {
2249
2253
  description?: string;
2250
2254
  visibility?: import("./workspace.js").ArtifactVisibility;
2251
2255
  share?: boolean;
2256
+ shareLatestOnly?: boolean;
2252
2257
  }) => Promise<unknown>;
2253
2258
  delete: (id: string, permanent?: boolean) => Promise<unknown>;
2254
2259
  restore: (id: string) => Promise<unknown>;
@@ -2257,6 +2262,7 @@ export declare function createClient(options: ClientOptions): {
2257
2262
  set: (input: import("./common.js").JsonObject) => Promise<unknown>;
2258
2263
  };
2259
2264
  share: (id: string) => {
2265
+ latestOnly: (enabled: boolean) => Promise<Record<string, unknown>>;
2260
2266
  get: () => Promise<Record<string, unknown>>;
2261
2267
  create: (role?: "read" | "write") => Promise<unknown>;
2262
2268
  revoke: (revokeAccepted?: boolean) => Promise<unknown>;
@@ -1,3 +1,18 @@
1
+ /** The Notes API facade (Notes API contract, "Shared rules"):
2
+ *
3
+ * const note = dl.notes(noteId) // local and synchronous; IDs are primary
4
+ * const snapshot = await note.read()
5
+ * const receipt = await note.append({ text: "\nHello\n", at: snapshot })
6
+ * const page = await dl.notes.list({ namespace: "fortyfive", limit: 20, offset: 0 })
7
+ * const created = await dl.notes.create({ namespace: "fortyfive", name: "Review", text: "# Review\n" })
8
+ *
9
+ * `notes` is callable and carries the collection operations. Every operation
10
+ * takes one named object. A handle opened by stable ID needs no namespace: the
11
+ * owner is read from the note's metadata on first use; `{ namespace }` or a
12
+ * qualified `"namespace/slug"` reference supplies lookup context for slugs.
13
+ * `at` is a snapshot or a bare revision; a content hash is never accepted in
14
+ * its place. Edits compile to the same PATCH as the CLI through note-write.ts. */
15
+ import type { MemoPresenceOptions, MemoPresenceRoster } from "./memo-presence.js";
1
16
  import { type Transport } from "./client.js";
2
17
  import { type MemoSource } from "./memo-edits.js";
3
18
  import * as editing from "./memo-editing.js";
@@ -195,7 +210,7 @@ export interface MemoHandle {
195
210
  permalink(input?: {
196
211
  slug?: string;
197
212
  }): Promise<MemoPermalink>;
198
- presence(): Promise<unknown>;
213
+ presence(options?: MemoPresenceOptions): Promise<MemoPresenceRoster>;
199
214
  /** Announce the caller once. `address`/`cursor` locations are a documented target (UnsupportedTarget today). */
200
215
  visit(input?: MemoVisitInput): Promise<unknown>;
201
216
  versions: {
@@ -1,17 +1,3 @@
1
- /** The Notes API facade (Notes API contract, "Shared rules"):
2
- *
3
- * const note = dl.notes(noteId) // local and synchronous; IDs are primary
4
- * const snapshot = await note.read()
5
- * const receipt = await note.append({ text: "\nHello\n", at: snapshot })
6
- * const page = await dl.notes.list({ namespace: "fortyfive", limit: 20, offset: 0 })
7
- * const created = await dl.notes.create({ namespace: "fortyfive", name: "Review", text: "# Review\n" })
8
- *
9
- * `notes` is callable and carries the collection operations. Every operation
10
- * takes one named object. A handle opened by stable ID needs no namespace: the
11
- * owner is read from the note's metadata on first use; `{ namespace }` or a
12
- * qualified `"namespace/slug"` reference supplies lookup context for slugs.
13
- * `at` is a snapshot or a bare revision; a content hash is never accepted in
14
- * its place. Edits compile to the same PATCH as the CLI through note-write.ts. */
15
1
  import { createHash } from "node:crypto";
16
2
  import { namespaceSeg } from "./client.js";
17
3
  import { RequestNotSent } from "./http.js";
@@ -310,7 +296,7 @@ export function memoHandle(t, ref, context = {}) {
310
296
  });
311
297
  },
312
298
  async permalink(input = {}) { return guarded(async (api) => api.permalink(await id(api), input), "write"); },
313
- async presence() { return guarded(async (api) => api.presence(await id(api))); },
299
+ async presence(options = {}) { return guarded(async (api) => api.presence(await id(api), options)); },
314
300
  async visit(input = {}) {
315
301
  if (input.address !== undefined || input.cursor !== undefined)
316
302
  throw new UnsupportedTarget("visit with a location (address/cursor)");
@@ -5,9 +5,16 @@ export interface MemoRange {
5
5
  start: number;
6
6
  end: number;
7
7
  }
8
+ export interface MemoPresenceOptions {
9
+ selections?: boolean;
10
+ }
8
11
  export interface MemoPresenceRoster {
9
12
  participants: Participant[];
10
13
  observedAt: number;
14
+ /** Absent on older servers; never infer availability from an empty array. */
15
+ status?: 'available' | 'inactive';
16
+ selectionStatus?: 'available' | 'inactive' | 'not_requested';
17
+ selectionHash?: string;
11
18
  }
12
19
  export interface MemoContributorsPage {
13
20
  sessions: {
@@ -76,6 +83,8 @@ export interface MemoSelectionReceipt {
76
83
  export declare function memoPresenceIntent(value: string | undefined): {
77
84
  summary: string;
78
85
  } | undefined;
86
+ /** Text projection for opt-in snapshots, including old-server capability gaps. */
87
+ export declare function formatMemoPresence(roster: MemoPresenceRoster): string;
79
88
  export declare function memoPresenceApi(t: Transport, base: string): {
80
89
  contributors: (id: string, options?: {
81
90
  cursor?: string;
@@ -83,11 +92,11 @@ export declare function memoPresenceApi(t: Transport, base: string): {
83
92
  }) => Promise<MemoContributorsPage>;
84
93
  /** No join or heartbeat. The optional input retains the former POST API for compatibility. */
85
94
  presence: {
86
- (id: string): Promise<MemoPresenceRoster>;
95
+ (id: string, options?: MemoPresenceOptions): Promise<MemoPresenceRoster>;
87
96
  /** @deprecated Use visit or updatePresence for explicit mutations. */
88
97
  (id: string, input: Record<string, unknown>): Promise<MemoPresenceReceipt>;
89
98
  };
90
- presenceText: (id: string) => Promise<string>;
99
+ presenceText: (id: string, options?: MemoPresenceOptions) => Promise<string>;
91
100
  updatePresence: (id: string, input: Record<string, unknown>, options?: RequestOptions) => Promise<MemoPresenceReceipt>;
92
101
  visit: (id: string, options?: {
93
102
  intent?: string;
@@ -10,20 +10,45 @@ export function memoPresenceIntent(value) {
10
10
  throw new Error('--intent requires 1–280 characters of plain text (one short sentence of purpose)');
11
11
  return { summary };
12
12
  }
13
+ /** Text projection for opt-in snapshots, including old-server capability gaps. */
14
+ export function formatMemoPresence(roster) {
15
+ const lines = [`Roster: ${roster.status ?? 'unknown'}; selections: ${roster.selectionStatus ?? 'unsupported'}`];
16
+ if (Number.isFinite(roster.observedAt))
17
+ lines.push(`Observed at: ${new Date(roster.observedAt).toISOString()}`);
18
+ if (roster.selectionHash)
19
+ lines.push(`Selection source: ${roster.selectionHash}`);
20
+ if (!roster.participants.length && roster.status === 'available')
21
+ lines.push('No participants present.');
22
+ for (const p of roster.participants) {
23
+ lines.push(`- ${p.user.kind ?? 'human'}: ${JSON.stringify(p.user.name)} (client: ${JSON.stringify(p.client)})`);
24
+ const selection = p.selection;
25
+ if (roster.selectionStatus !== 'available' || !roster.selectionHash)
26
+ continue;
27
+ if (!selection)
28
+ lines.push(' selection: none');
29
+ else if (selection.status === 'unresolved')
30
+ lines.push(' selection: unresolved');
31
+ else
32
+ lines.push(` selection: [${selection.start}, ${selection.end}) code points ${JSON.stringify(selection.text)}${selection.truncated ? ' (truncated)' : ''}`);
33
+ }
34
+ return lines.join('\n') + '\n';
35
+ }
13
36
  export function memoPresenceApi(t, base) {
14
37
  const path = (id) => `${base}/${seg(id)}`;
15
38
  const updatePresence = (id, input, options = {}) => t.request('POST', path(id) + '/presence', { ...options, json: input });
16
- const presence = (id, input) => input === undefined
17
- ? t.request('GET', path(id) + '/presence', { query: { format: 'json' } })
39
+ const presence = (id, input) => input === undefined || (Object.keys(input).every(k => k === 'selections') && (input.selections === undefined || typeof input.selections === 'boolean'))
40
+ ? t.request('GET', path(id) + '/presence', { query: { format: 'json', ...(input?.selections !== undefined ? { selections: String(input.selections) } : {}) } })
18
41
  : updatePresence(id, input);
19
42
  return {
20
43
  contributors: (id, options = {}) => t.request('GET', path(id) + '/contributors', { query: options }),
21
44
  /** No join or heartbeat. The optional input retains the former POST API for compatibility. */
22
45
  presence: presence,
23
- presenceText: async (id) => {
46
+ presenceText: async (id, options = {}) => {
47
+ if (options.selections)
48
+ return formatMemoPresence(await presence(id, { selections: true }));
24
49
  if (!t.raw)
25
50
  throw new Error('transport_does_not_support_streaming');
26
- return (await t.raw('GET', path(id) + '/presence', { query: { format: 'text' }, redirect: 'error' })).text();
51
+ return (await t.raw('GET', path(id) + '/presence', { query: { format: 'text', ...(options.selections !== undefined ? { selections: String(options.selections) } : {}) }, redirect: 'error' })).text();
27
52
  },
28
53
  updatePresence,
29
54
  visit: (id, options = {}) => {
@@ -323,10 +323,10 @@ export declare function memosApi(t: Transport, namespace: string): {
323
323
  pageSize?: number;
324
324
  }) => Promise<import("./memo-presence.js").MemoContributorsPage>;
325
325
  presence: {
326
- (id: string): Promise<import("./memo-presence.js").MemoPresenceRoster>;
326
+ (id: string, options?: import("./memo-presence.js").MemoPresenceOptions): Promise<import("./memo-presence.js").MemoPresenceRoster>;
327
327
  (id: string, input: Record<string, unknown>): Promise<import("./memo-presence.js").MemoPresenceReceipt>;
328
328
  };
329
- presenceText: (id: string) => Promise<string>;
329
+ presenceText: (id: string, options?: import("./memo-presence.js").MemoPresenceOptions) => Promise<string>;
330
330
  updatePresence: (id: string, input: Record<string, unknown>, options?: import("./client.js").RequestOptions) => Promise<import("./memo-presence.js").MemoPresenceReceipt>;
331
331
  visit: (id: string, options?: {
332
332
  intent?: string;
@@ -20,6 +20,7 @@ export interface ArtifactPushArgs extends DreamlakeOpts {
20
20
  namespace?: string;
21
21
  visibility?: string;
22
22
  share?: boolean;
23
+ latestOnly?: boolean;
23
24
  incremental?: boolean;
24
25
  full?: boolean;
25
26
  /** Preview description — the user's; later pushes leave it alone. */
@@ -283,6 +283,7 @@ export async function runDreamlakeArtifactPush(args, deps = {}) {
283
283
  version,
284
284
  ...(args.visibility ? { visibility: args.visibility } : {}),
285
285
  ...(args.share ? { share: true } : {}),
286
+ ...(args.latestOnly !== undefined ? { shareLatestOnly: args.latestOnly } : {}),
286
287
  ...(args.description !== undefined ? { description: args.description } : {}),
287
288
  });
288
289
  if (reg.status < 200 || reg.status >= 300) {
@@ -444,6 +445,8 @@ export function registerArtifactCommand(program) {
444
445
  .option("--incremental", "upload only new compressed chunks (default; requires an updated viewer)", true)
445
446
  .option("--full", "upload the entire file in the original single-blob format")
446
447
  .addOption(new Option("--no-incremental", "compatibility alias for --full").hideHelp())
448
+ .option("--latest-only", "restrict recipients to the most recent version; preserves member history")
449
+ .option("--no-latest-only", "allow recipients to read version history")
447
450
  .option("--share", "issue a share token so the artifact can be read via a ?share= link")
448
451
  .option("--description <text>", "preview description for link cards (kept across later pushes)")
449
452
  .option("--cover <file>", "preview cover image: PNG, JPEG or WebP, 1200×900 (4:3) recommended (kept across later pushes)")).action(async (file, opts) => {
@@ -19,6 +19,7 @@ export const helpExamples = {
19
19
  "artifact meta set": "# At push time:\ndreamlake artifact push ./report.html --id q1-dashboard \\\n --description \"Revenue, churn and pipeline for the quarter\" \\\n --cover ./cover.png\n\n# Or after the fact, for an artifact that already exists:\ndreamlake artifact meta set q1-dashboard --description \"Revenue, churn and pipeline\"\ndreamlake artifact meta set q1-dashboard --cover ./cover.png\ndreamlake artifact meta show q1-dashboard\n\n# Back to the automatic description / the generated cover:\ndreamlake artifact meta set q1-dashboard --clear-description --clear-cover",
20
20
  "artifact share": "# Find the dashboard you already uploaded; no new version is needed.\ndreamlake artifact list\nARTIFACT=\"q1-dashboard\" # Replace with the id from list.\ndreamlake artifact share get \"$ARTIFACT\"\n\n# Give signed-in recipients read access, then verify the returned link.\ndreamlake artifact share create \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"\n\n# When link access is no longer needed, revoke it and verify.\ndreamlake artifact share revoke \"$ARTIFACT\"\ndreamlake artifact share get \"$ARTIFACT\"",
21
21
  "artifact visibility": "ARTIFACT=\"q1-dashboard\" # Your existing artifact id.\ndreamlake artifact visibility \"$ARTIFACT\" public\ndreamlake artifact visibility \"$ARTIFACT\" private\ndreamlake artifact visibility \"$ARTIFACT\" unlisted",
22
+ "artifact share latest-only": "# Change an existing artifact without uploading or changing its link.\ndreamlake artifact share latest-only report on\ndreamlake artifact share get report --json\n# Allow recipients to browse history again.\ndreamlake artifact share latest-only report off",
22
23
  "artifact rename": "dreamlake artifact rename session-work-map-20261014 session-work-map --namespace my-team",
23
24
  "runnable bind": "dreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes \\\n --server \"$LAKESHORE_URL\" --cp-namespace acme --dry-run\ndreamlake runnable bind udf/acme/recipes.process@FULL_SHA256 \\\n --snapshot CODE_REPO_ID --project recipes --server \"$LAKESHORE_URL\" --cp-namespace acme",
24
25
  "runnable execute": "dreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --json\ndreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --attempt 2 --json",
@@ -117,7 +118,7 @@ export const helpExamples = {
117
118
  "memos files reconcile": "dreamlake memos files reconcile \"$OPERATION_ID\" --note \"$MEMO_ID\" --json",
118
119
  "memos files cancel": "dreamlake memos files cancel \"$OPERATION_ID\" --note \"$MEMO_ID\" --json",
119
120
  "memos visit": "# Reuse the task's DREAMLAKE_AGENT_ID and DREAMLAKE_AGENT_NAME.\nMEMO_ID=release-plan\ndreamlake memos visit \"$MEMO_ID\"",
120
- "memos presence": "# Read the participant roster without joining. Text is the default.\nMEMO_ID=release-plan\ndreamlake memos presence \"$MEMO_ID\"",
121
+ "memos presence": "# Read the participant roster without joining. Text is the default.\nMEMO_ID=release-plan\ndreamlake memos presence \"$MEMO_ID\"\n# Include a source-bound human selection snapshot.\ndreamlake memos presence \"$MEMO_ID\" --selections",
121
122
  "memos select": "export DREAMLAKE_AGENT_ID=\"review-session-42\"\nexport DREAMLAKE_AGENT_NAME=\"Codex\"\nMEMO_ID=\"your-note-id\"\ndreamlake memos select --text \"The next step is tested in simulation.\" --note \"$MEMO_ID\"\n# Select the last occurrence of a repeated passage.\ndreamlake memos select --text \"simulation\" --note \"$MEMO_ID\" -o -1",
122
123
  "memos contributors": "dreamlake memos contributors release-plan --namespace geyang --json\n# If hasMore is true, continue with the returned nextCursor:\ndreamlake memos contributors release-plan --namespace geyang --cursor LINK_CURSOR --json",
123
124
  "memos rm": "# Read it first and confirm it is the note you mean.\ndreamlake memos read MEMO_ID\n# Asks for confirmation, showing the title and owning namespace.\ndreamlake memos rm MEMO_ID\n# Scripts and agents: skip the prompt and take a JSON receipt.\ndreamlake memos rm MEMO_ID --yes --json\n# Afterwards a read reports not found.\ndreamlake memos read MEMO_ID",
@@ -124,6 +124,7 @@ export declare function runMemosContributors(ref: string, opts: ConnOpts & {
124
124
  /** Reading the roster never registers presence or maintains a session. */
125
125
  export declare function runMemosPresence(ref: string, opts: ConnOpts & {
126
126
  json?: boolean;
127
+ selections?: boolean;
127
128
  }): Promise<number>;
128
129
  /** The agent's self-reported purpose, validated before any presence request.
129
130
  * undefined means the flag was not given — the server then preserves intent. */
@@ -1,4 +1,4 @@
1
- import { memoPresenceApi, memoPresenceIntent } from '../../api/memo-presence.js';
1
+ import { memoPresenceApi, memoPresenceIntent, formatMemoPresence } from '../../api/memo-presence.js';
2
2
  import { memoTransport } from './api-transport.js';
3
3
  import { collectionList } from "../collection-list.js";
4
4
  import { registerVersionCommands, runSavedVersionRead } from "./version-commands.js";
@@ -217,6 +217,7 @@ export function registerMemosCommand(program) {
217
217
  strict(notes.command("presence"))
218
218
  .argument("<memo>", "memo id, slug or title")
219
219
  .description("read who is present without joining the memo")
220
+ .option("--selections", "include source-bound human selections (requires server support)")
220
221
  .option("--namespace <slug>", "memo owner namespace")
221
222
  .option("--json", "emit JSON for programmatic consumers")
222
223
  .action(async (note, opts) => { process.exitCode = await runMemosPresence(note, opts); });
@@ -1359,9 +1360,11 @@ export async function runMemosPresence(ref, opts) {
1359
1360
  const id = await resolveNote(c, ref);
1360
1361
  if (!id)
1361
1362
  return 1;
1362
- const response = await requestRaw(`${c.remote}/namespaces/${seg(c.ns)}/notes/${seg(id)}/presence?format=${opts.json ? 'json' : 'text'}`, { token: c.token, timeoutMs: 30000, followRedirects: false });
1363
+ const response = await requestRaw(`${c.remote}/namespaces/${seg(c.ns)}/notes/${seg(id)}/presence?format=${opts.json || opts.selections ? 'json' : 'text'}${opts.selections ? '&selections=true' : ''}`, { token: c.token, timeoutMs: 30000, followRedirects: false });
1363
1364
  if (opts.json)
1364
1365
  emitJson(await response.json());
1366
+ else if (opts.selections)
1367
+ process.stdout.write(formatMemoPresence(await response.json()));
1365
1368
  else {
1366
1369
  const text = await response.text();
1367
1370
  process.stdout.write(text + (text.endsWith('\n') ? '' : '\n'));
@@ -0,0 +1,9 @@
1
+ export interface AliasOptions {
2
+ bin: string;
3
+ /** Known installed binaries, including the previous version before pruning. */
4
+ versions: string[];
5
+ windows?: boolean;
6
+ searchPath?: string;
7
+ }
8
+ /** Return a warning when dl cannot be installed safely; never replace a foreign command. */
9
+ export declare function installAlias(opts: AliasOptions): string | null;
@@ -0,0 +1,86 @@
1
+ // A command on PATH, not a shell alias: works in scripts and every shell.
2
+ import { accessSync, constants, copyFileSync, lstatSync, readFileSync, readlinkSync, renameSync, rmSync, statSync, symlinkSync } from "node:fs";
3
+ import path from "node:path";
4
+ /** Return a warning when dl cannot be installed safely; never replace a foreign command. */
5
+ export function installAlias(opts) {
6
+ const windows = opts.windows ?? process.platform === "win32";
7
+ const launcher = path.join(opts.bin, windows ? "dreamlake.exe" : "dreamlake");
8
+ const alias = path.join(opts.bin, windows ? "dl.exe" : "dl");
9
+ const conflict = (file) => `Warning: dl was not configured because ${file} already exists. It was left unchanged. Use dreamlake, or rename the conflicting command and re-run dreamlake install.`;
10
+ const staging = `${alias}.new-${process.pid}`;
11
+ let staged = false;
12
+ try {
13
+ let existing;
14
+ try {
15
+ existing = lstatSync(alias);
16
+ }
17
+ catch (err) {
18
+ if (err.code !== "ENOENT")
19
+ throw err;
20
+ }
21
+ if (existing) {
22
+ if (windows) {
23
+ if (!existing.isFile() || existing.isSymbolicLink())
24
+ return conflict(alias);
25
+ const bytes = readFileSync(alias);
26
+ if (!opts.versions.some(file => bytes.equals(readFileSync(file))))
27
+ return conflict(alias);
28
+ }
29
+ else if (!existing.isSymbolicLink() || path.resolve(opts.bin, readlinkSync(alias)) !== launcher) {
30
+ return conflict(alias);
31
+ }
32
+ }
33
+ // Check all PATH entries before creating a new alias: PATH setup may prepend
34
+ // our bin directory, which would otherwise silently take over another dl.
35
+ const extensions = windows ? ["", ...new Set([".exe", ".cmd", ".bat", ".com", ".ps1", ...(process.env.PATHEXT ?? "").toLowerCase().split(";").filter(Boolean)])] : [""];
36
+ let other = null;
37
+ for (const dir of (opts.searchPath ?? process.env.PATH ?? "").split(windows ? ";" : ":")) {
38
+ for (const ext of extensions) {
39
+ const candidate = path.resolve(dir || ".", `dl${ext}`);
40
+ if (windows ? candidate.toLowerCase() === alias.toLowerCase() : candidate === alias)
41
+ continue;
42
+ try {
43
+ if (!statSync(candidate).isFile())
44
+ continue;
45
+ accessSync(candidate, windows ? constants.F_OK : constants.X_OK);
46
+ other = candidate;
47
+ break;
48
+ }
49
+ catch { /* absent or not executable */ }
50
+ }
51
+ if (other)
52
+ break;
53
+ }
54
+ if (other && !existing)
55
+ return conflict(other);
56
+ if (windows) {
57
+ // A copy needs no symlink privileges, preserves argv/stdio/exit status,
58
+ // and can be invoked directly by PowerShell, CMD, or another program.
59
+ copyFileSync(launcher, staging, constants.COPYFILE_EXCL);
60
+ staged = true;
61
+ try {
62
+ renameSync(staging, alias);
63
+ }
64
+ catch (err) {
65
+ if (!existing || !["EBUSY", "EPERM", "EACCES"].includes(err.code ?? ""))
66
+ throw err;
67
+ // dl self-update may be running this executable. Windows permits
68
+ // renaming that copy; the installer prunes it once its process exits.
69
+ renameSync(alias, `${alias}.old-${process.pid}`);
70
+ renameSync(staging, alias);
71
+ }
72
+ }
73
+ else if (!existing) {
74
+ // Exclusive creation also protects a command created since the check.
75
+ symlinkSync("dreamlake", alias);
76
+ }
77
+ return other ? `Warning: another dl is on PATH at ${other}. PATH order selects which runs; use ${alias} for DreamLake. Shell aliases and functions can also override dl.` : null;
78
+ }
79
+ catch (err) {
80
+ return `Warning: could not configure dl at ${alias}: ${err.message}. Use dreamlake and re-run dreamlake install after resolving this.`;
81
+ }
82
+ finally {
83
+ if (staged)
84
+ rmSync(staging, { force: true });
85
+ }
86
+ }
@@ -21,6 +21,8 @@ export function registerInstallCommand(program) {
21
21
  const converting = !isNativeInstall() && process.env.DREAMLAKE_BOOTSTRAP !== "1";
22
22
  const result = await performInstall(target, { modifyPath: opts.modifyPath });
23
23
  process.stdout.write(`Installed dreamlake ${result.version} → ${result.launcher}\n`);
24
+ if (!result.launcherConflict && !result.aliasWarning)
25
+ process.stdout.write("Also available as dl (same commands and settings).\n");
24
26
  if (converting) {
25
27
  process.stdout.write("This is now a native install under ~/.local; the copy you ran this from is untouched.\n");
26
28
  }
@@ -20,6 +20,7 @@ export interface InstallResult {
20
20
  * user ends up with `command not found` after a green checkmark.
21
21
  */
22
22
  launcherConflict: string | null;
23
+ aliasWarning: string | null;
23
24
  }
24
25
  /**
25
26
  * Resolve a user-supplied target into a concrete version. Accepts a channel
@@ -17,6 +17,7 @@ import { compareVersions, detectPlatform, downloadBinary, fetchManifest, isChann
17
17
  import { activeChannel, pinnedVersion, updatesDisabled, writeSettings } from "./settings.js";
18
18
  import { BytesProgress } from "../progress.js";
19
19
  import { VERSION } from "../version.js";
20
+ import { installAlias } from "./alias.js";
20
21
  /**
21
22
  * Resolve a user-supplied target into a concrete version. Accepts a channel
22
23
  * name or an exact version; a channel also becomes the saved default for
@@ -208,7 +209,7 @@ function prune(keep) {
208
209
  // Launchers renamed out of the way because Windows had them locked.
209
210
  try {
210
211
  for (const entry of readdirSync(binDir())) {
211
- if (/^dreamlake\.exe\.old-\d+$/.test(entry)) {
212
+ if (/^(dreamlake|dl)\.exe\.old-\d+$/.test(entry)) {
212
213
  rmSync(path.join(binDir(), entry), { force: true });
213
214
  }
214
215
  }
@@ -295,6 +296,7 @@ export async function performInstall(target, opts = {}) {
295
296
  throw new Error(`superseded by a pin to ${pinnedVersion()} set while downloading`);
296
297
  }
297
298
  const { previous, conflict } = linkLauncher(version);
299
+ const aliasWarning = conflict ? null : installAlias({ bin: binDir(), versions: listVersions().map(versionPath) });
298
300
  // Asking for an exact version pins it; asking for a channel resumes
299
301
  // following that channel. Without this the background updater would move
300
302
  // you straight off the version you just asked for.
@@ -329,6 +331,7 @@ export async function performInstall(target, opts = {}) {
329
331
  launcher: launcherPath(),
330
332
  pinned: channel ? null : version,
331
333
  launcherConflict: conflict,
334
+ aliasWarning,
332
335
  shadowedBy,
333
336
  pathAdvice,
334
337
  };
@@ -339,6 +342,7 @@ export async function performInstall(target, opts = {}) {
339
342
  */
340
343
  export function installWarnings(result) {
341
344
  const tilde = (p) => p.replace(homedir(), "~");
345
+ const aliasWarnings = result.aliasWarning ? [result.aliasWarning] : [];
342
346
  if (result.launcherConflict) {
343
347
  return [
344
348
  `Warning: ${tilde(result.launcherConflict)} already exists and is not a symlink we manage.`,
@@ -349,6 +353,7 @@ export function installWarnings(result) {
349
353
  }
350
354
  if (result.shadowedBy) {
351
355
  return [
356
+ ...aliasWarnings,
352
357
  `Warning: another dreamlake is earlier on your PATH and will keep running instead:`,
353
358
  ` ${tilde(result.shadowedBy)}`,
354
359
  `Installed ${result.version} at ${tilde(result.launcher)}.`,
@@ -356,7 +361,7 @@ export function installWarnings(result) {
356
361
  `or put ~/.local/bin ahead of it in PATH. Check with: dreamlake doctor`,
357
362
  ];
358
363
  }
359
- return [];
364
+ return aliasWarnings;
360
365
  }
361
366
  /** Newest version available on `channel`, or null when the check fails. */
362
367
  export async function latestAvailable(channel) {
@@ -2,13 +2,14 @@
2
2
  import type { Command } from "commander";
3
3
  import { type ConnOpts } from "./memos/index.js";
4
4
  type Kind = "notes" | "artifact";
5
- type Operation = "get" | "create" | "revoke" | "access" | "remove" | "visibility";
5
+ type Operation = "get" | "create" | "revoke" | "access" | "remove" | "visibility" | "latest-only";
6
6
  interface ShareOptions extends ConnOpts {
7
7
  json?: boolean;
8
8
  role?: string;
9
9
  revokeAccepted?: boolean;
10
10
  userId?: string;
11
11
  visibility?: string;
12
+ latestOnly?: boolean;
12
13
  }
13
14
  export declare function runShare(kind: Kind, operation: Operation, ref: string, opts: ShareOptions): Promise<number>;
14
15
  export declare function registerShareCommands(parent: Command, kind: Kind): void;
package/dist/cli/share.js CHANGED
@@ -15,6 +15,10 @@ export async function runShare(kind, operation, ref, opts) {
15
15
  fail(`visibility must be ${visibilities.join(", ")}`);
16
16
  return 1;
17
17
  }
18
+ if (operation === "latest-only" && (kind !== "artifact" || typeof opts.latestOnly !== "boolean")) {
19
+ fail("latest-only requires on or off");
20
+ return 1;
21
+ }
18
22
  const c = resolveCtx(opts);
19
23
  const token = requireToken(c);
20
24
  if (!token)
@@ -53,7 +57,7 @@ export async function runShare(kind, operation, ref, opts) {
53
57
  const canManage = kind === "notes" ? row.permissions?.share : row.viewerCanManage;
54
58
  // The artifact mutation endpoint is an upsert: preflight avoids creating a
55
59
  // catalog stub or restoring an already-deleted artifact on an ordinary call.
56
- if (operation !== "get" && !canManage) {
60
+ if (operation !== "get" && canManage !== true) {
57
61
  fail("not allowed to manage sharing for this resource");
58
62
  return 1;
59
63
  }
@@ -87,15 +91,21 @@ export async function runShare(kind, operation, ref, opts) {
87
91
  row = await requestJson(c.remote, base + (isNote && operation !== "visibility" ? "/share" : ""), {
88
92
  token,
89
93
  method: isNote ? (operation === "visibility" ? "PATCH" : operation === "revoke" ? "DELETE" : "PUT") : "POST",
90
- ...(operation === "visibility" ? { json: { visibility: opts.visibility } }
91
- : isNote ? operation === "create" ? { json: { role: opts.role ?? "read" } }
92
- : { query: { revokeAccepted: opts.revokeAccepted ? "true" : undefined } }
93
- : { json: { share: operation === "create" } }),
94
+ ...(operation === "latest-only" ? { json: { shareLatestOnly: opts.latestOnly } }
95
+ : operation === "visibility" ? { json: { visibility: opts.visibility } }
96
+ : isNote ? operation === "create" ? { json: { role: opts.role ?? "read" } }
97
+ : { query: { revokeAccepted: opts.revokeAccepted ? "true" : undefined } }
98
+ : { json: { share: operation === "create", ...(operation === "create" && opts.latestOnly !== undefined ? { shareLatestOnly: opts.latestOnly } : {}) } }),
94
99
  });
95
100
  }
101
+ if ((operation === "latest-only" || operation === "create") && opts.latestOnly !== undefined && row.shareLatestOnly !== opts.latestOnly) {
102
+ fail("server did not confirm latest-only sharing; inspect share get before retrying");
103
+ return 1;
104
+ }
96
105
  const url = `${webBase(c.remote)}/${encodeURIComponent(ns)}/${kind === "notes" ? "notes" : "artifacts"}/${encodeURIComponent(urlId)}`;
97
106
  const result = {
98
107
  url, visibility: row.visibility,
108
+ ...(kind === "artifact" ? { shareLatestOnly: row.shareLatestOnly ?? false } : {}),
99
109
  publicUrl: row.visibility === "public" || row.visibility === "unlisted" ? url : null,
100
110
  shareUrl: row.shareToken ? `${url}?share=${encodeURIComponent(row.shareToken)}` : null,
101
111
  shareRole: kind === "notes" ? row.shareRole ?? null : row.shareToken ? "read" : null,
@@ -107,6 +117,8 @@ export async function runShare(kind, operation, ref, opts) {
107
117
  else {
108
118
  process.stdout.write(`Resource: ${url}\nVisibility: ${row.visibility ?? "unknown"}\n`);
109
119
  process.stdout.write(result.shareUrl ? `Share (${result.shareRole}): ${result.shareUrl}\n` : `Share link: ${result.shareStatus}\n`);
120
+ if (kind === "artifact")
121
+ process.stdout.write(`Most recent version only: ${row.shareLatestOnly ? "on" : "off"}\n`);
110
122
  if (kind === "notes" && operation === "revoke")
111
123
  process.stdout.write(opts.revokeAccepted
112
124
  ? "Link revoked and acceptance records deleted. Existing room sessions may continue until the room is rotated.\n"
@@ -123,7 +135,9 @@ export function registerShareCommands(parent, kind) {
123
135
  const share = parent.command("share").description("get and manage share links without changing content");
124
136
  for (const operation of ["get", "create", "revoke", ...(kind === "notes" ? ["access", "remove"] : [])]) {
125
137
  let cmd = share.command(operation).argument("<resource>", "resource id (Memos also accept a name or slug)")
126
- .description({ get: "inspect existing links without enabling sharing", create: "enable a share link (reuse an existing token)", revoke: "disable the share link", access: "list Memo acceptance records (stored roles may lag)", remove: "remove one accepted Memo grant", visibility: "set visibility" }[operation]);
138
+ .description({ get: "inspect existing links without enabling sharing", create: "enable a share link (reuse an existing token)", revoke: "disable the share link", access: "list Memo acceptance records (stored roles may lag)", remove: "remove one accepted Memo grant", visibility: "set visibility", "latest-only": "set recipient version access" }[operation]);
139
+ if (operation === "create" && kind === "artifact")
140
+ cmd.option("--latest-only", "share only the most recent version").option("--no-latest-only", "allow version history");
127
141
  if (operation === "create" && kind === "notes")
128
142
  cmd.option("--role <role>", "read or write; applies to all link-derived access on subsequent requests", "read");
129
143
  if (operation === "revoke" && kind === "notes")
@@ -136,6 +150,14 @@ export function registerShareCommands(parent, kind) {
136
150
  else
137
151
  cmd.action(async (ref, opts) => { process.exit(await runShare(kind, operation, ref, opts)); });
138
152
  }
153
+ if (kind === "artifact")
154
+ withConnFlags(share.command("latest-only")
155
+ .argument("<resource>").argument("<mode>", "on or off")
156
+ .description("set recipient version access without changing the share link or uploading content")
157
+ .option("--namespace <slug>", "namespace").option("--json", "emit structured JSON"))
158
+ .action(async (ref, mode, opts) => {
159
+ process.exit(await runShare(kind, "latest-only", ref, { ...opts, latestOnly: mode === "on" ? true : mode === "off" ? false : undefined }));
160
+ });
139
161
  withConnFlags(parent.command("visibility").argument("<resource>").argument("<visibility>", "private, public or unlisted")
140
162
  .description("set read visibility; does not revoke share links or accepted access")
141
163
  .option("--namespace <slug>", "namespace").option("--json", "emit structured JSON"))
@@ -13,7 +13,7 @@ export declare function validateKey(value: string): void;
13
13
  export declare function prepareTransfers(transfers: Transfer[]): Promise<void>;
14
14
  export declare function transferSelected(transfers: Transfer[], call: VaultCall, cancelled?: () => boolean): Promise<void>;
15
15
  export declare function transferReport(transfers: Transfer[]): {
16
- status: "success" | "pending" | "unknown" | "failure";
16
+ status: "success" | "unknown" | "pending" | "failure";
17
17
  detail: string;
18
18
  ifMatch?: number | undefined;
19
19
  id: string;
@@ -1 +1 @@
1
- export declare const VERSION = "0.109.0";
1
+ export declare const VERSION = "0.110.1";
@@ -6,4 +6,4 @@
6
6
  // value means a binary that re-installs the same version forever.
7
7
  //
8
8
  // Editing this by hand does nothing for a release; bump package.json.
9
- export const VERSION = "0.109.0";
9
+ export const VERSION = "0.110.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.109.0",
3
+ "version": "0.110.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -8,7 +8,8 @@
8
8
  "homepage": "https://cli.dreamlake.ai",
9
9
  "description": "dreamlake — data-warehouse CLI. The `dreamlake` command uploads/downloads assets, manages episodes, bindrs, datasets, organizations and teams, and versions artifacts, workflow specs and pipelines against a DreamLake server + BSS.",
10
10
  "bin": {
11
- "dreamlake": "bin/dreamlake.js"
11
+ "dreamlake": "bin/dreamlake.js",
12
+ "dl": "bin/dreamlake.js"
12
13
  },
13
14
  "exports": {
14
15
  "./api": {
@@ -36,13 +37,13 @@
36
37
  "node": ">=18"
37
38
  },
38
39
  "optionalDependencies": {
39
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.109.0",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.109.0",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.109.0",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.109.0",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.109.0",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.109.0",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.109.0",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.109.0"
40
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.110.1",
41
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.110.1",
42
+ "@dreamlake/dreamlake-cli-linux-x64": "0.110.1",
43
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.110.1",
44
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.110.1",
45
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.110.1",
46
+ "@dreamlake/dreamlake-cli-win32-x64": "0.110.1",
47
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.110.1"
47
48
  }
48
49
  }