@dreamlake/dreamlake-cli 0.108.0 → 0.109.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.
@@ -3,7 +3,7 @@ import { type MemoSource } from "./memo-edits.js";
3
3
  import * as editing from "./memo-editing.js";
4
4
  import { type MemoFocusedRead } from "./memo-reading.js";
5
5
  import { type MemoCommandStatus, type MemoWriteMode, type MemoWriteReceipt } from "./memo-write.js";
6
- import { type MemoRow, type MemosApi, type MemoVersion } from "./memos.js";
6
+ import { type MemoRow, type MemoPermalink, type MemosApi, type MemoVersion } from "./memos.js";
7
7
  /** `{note, content, hash, revision}`: four distinct values. A hash describes text; a revision is the write baseline. */
8
8
  export type MemoSnapshot = MemoSource;
9
9
  /** A qualified reference: the first `/` separates the lookup namespace from a 24-hex id or a slug. */
@@ -191,6 +191,10 @@ export interface MemoHandle {
191
191
  since: string;
192
192
  format?: "diff" | "inline-dff";
193
193
  }): Promise<MemoDiff>;
194
+ /** Get or allocate a public URL, or edit its slug; previous slugs remain reserved aliases. */
195
+ permalink(input?: {
196
+ slug?: string;
197
+ }): Promise<MemoPermalink>;
194
198
  presence(): Promise<unknown>;
195
199
  /** Announce the caller once. `address`/`cursor` locations are a documented target (UnsupportedTarget today). */
196
200
  visit(input?: MemoVisitInput): Promise<unknown>;
@@ -309,6 +309,7 @@ export function memoHandle(t, ref, context = {}) {
309
309
  return result;
310
310
  });
311
311
  },
312
+ async permalink(input = {}) { return guarded(async (api) => api.permalink(await id(api), input), "write"); },
312
313
  async presence() { return guarded(async (api) => api.presence(await id(api))); },
313
314
  async visit(input = {}) {
314
315
  if (input.address !== undefined || input.cursor !== undefined)
@@ -6,6 +6,14 @@ import { type MemoSource, type MemoEdit } from "./memo-edits.js";
6
6
  export { memoEdits, type MemoSource, type MemoEdit, type MemoPatch, noteEdits, type NoteSource, type NoteEdit, type NotePatch, } from "./memo-edits.js";
7
7
  import { type Transport } from "./client.js";
8
8
  import { type MemoPatchRequest, type MemoWriteReceipt, type MemoCommandStatus } from "./memo-write.js";
9
+ /** Current public URL and retained previous slugs. */
10
+ export interface MemoPermalink {
11
+ noteId: string;
12
+ namespaceSlug: string;
13
+ slug: string;
14
+ href: string;
15
+ aliases: string[];
16
+ }
9
17
  export interface MemoSearchHit {
10
18
  noteId: string;
11
19
  noteSlug: string;
@@ -150,6 +158,10 @@ export declare function memosApi(t: Transport, namespace: string): {
150
158
  projects: string[];
151
159
  dryRun?: boolean;
152
160
  }) => Promise<unknown>;
161
+ /** Get or allocate a public/unlisted URL; an explicit slug edits it and retains aliases. */
162
+ permalink: (noteId: string, input?: {
163
+ slug?: string;
164
+ }) => Promise<MemoPermalink>;
153
165
  share: (noteId: string) => {
154
166
  get: () => Promise<Record<string, unknown>>;
155
167
  create: (role?: "read" | "write") => Promise<unknown>;
package/dist/api/memos.js CHANGED
@@ -123,6 +123,8 @@ export function memosApi(t, namespace) {
123
123
  shared: (query = {}) => t.request("GET", "/me/notes/shared", { query }),
124
124
  projects: (noteId, view) => t.request("GET", `/namespaces/${namespaceSeg(namespace)}/resources/note/${id(noteId)}/projects`, { query: { view } }),
125
125
  move: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/move`, { json: input }),
126
+ /** Get or allocate a public/unlisted URL; an explicit slug edits it and retains aliases. */
127
+ permalink: (noteId, input = {}) => t.request("POST", `${base}/${id(noteId)}/permalink`, { json: input, redirect: "error" }),
126
128
  share: (noteId) => sharingApi(t, namespace, "notes", id(noteId)),
127
129
  files: (noteId) => memoFilesApi(t, `${base}/${id(noteId)}`),
128
130
  media: async (form) => {
@@ -140,6 +140,7 @@ export const helpExamples = {
140
140
  "memos share revoke": "MEMO=\"release-plan\" # Your existing memo id or slug.\ndreamlake memos share revoke \"$MEMO\" --revoke-accepted",
141
141
  "memos share access": "MEMO=\"release-plan\" # Your existing memo id or slug.\n# List acceptance records and stored roles as a readable table.\ndreamlake memos share access \"$MEMO\"",
142
142
  "memos share remove": "MEMO=\"release-plan\" # Your existing memo id or slug.\nUSER_ID=\"user-id-from-access-list\"\ndreamlake memos share remove \"$MEMO\" \"$USER_ID\"",
143
+ "memos permalink": "dreamlake memos permalink <memo-id> --namespace <namespace> --json\ndreamlake memos permalink <memo-id> --namespace <namespace> --slug my-article --json",
143
144
  "memos suggest-diff": "# Review a change as a new private note.\ndreamlake memos suggest-diff before.md after.md --user \"Docs review\" \\\n | dreamlake memos create \"Redline: release plan\" --file -\n# Propose edits inside the note itself; refuses changes it cannot express.\ndreamlake memos suggest-diff current.md edited.md --in-place --user \"$DREAMLAKE_AGENT_NAME\" > proposal.md\n# Count insertions, deletions, replacements and changed code blocks.\ndreamlake memos suggest-diff before.md after.md --json | jq .stats",
144
145
  "memos transfer": "dreamlake memos transfer MEMO_ID --namespace alice --to acme \\\n --dry-run --out note-transfer.json\n# Submit the exact reviewed file; the authorized destination member accepts separately.\ndreamlake memos transfer MEMO_ID --namespace alice --to acme \\\n --confirm --request-file note-transfer.json\n# If you also have destination acceptance authority:\ndreamlake memos transfer MEMO_ID --namespace alice --to acme \\\n --confirm --request-file note-transfer.json --accept-if-authorized --wait",
145
146
  "memos tag": "# Save the current content on the existing Memo.\ndreamlake memos tag MEMO_ID end-of-day --namespace my-org --summary \"Reviewed today's actions\"\n# Require the hash retained from a reviewed full read (not its opaque revision).\ndreamlake memos tag MEMO_ID reviewed --hash sha256:CONTENT_HASH --json\n# Connect this checkpoint to an earlier version in the same Memo.\ndreamlake memos tag MEMO_ID next-checkpoint --parent VERSION_ID\n# Read and validate without creating a version.\ndreamlake memos tag MEMO_ID preview --dry-run --json",
@@ -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 { registerPermalinkCommand } from "./permalink-command.js";
7
8
  import { registerArchiveCommands } from "./archive-command.js";
8
9
  import { registerRmCommand } from "./rm-command.js";
9
10
  import { registerSuggestDiffCommand } from "./suggest-diff.js";
@@ -201,6 +202,7 @@ export function registerMemosCommand(program) {
201
202
  registerTransferCommand(notes);
202
203
  registerRmCommand(notes);
203
204
  registerArchiveCommands(notes);
205
+ registerPermalinkCommand(notes);
204
206
  registerSuggestDiffCommand(notes);
205
207
  // Same connection flags as the other ported groups, so --debug/--remote
206
208
  // behave identically across the CLI.
@@ -0,0 +1,7 @@
1
+ import type { Command } from 'commander';
2
+ import { type ConnOpts } from './index.js';
3
+ export declare function runMemosPermalink(ref: string, opts: ConnOpts & {
4
+ slug?: string;
5
+ json?: boolean;
6
+ }): Promise<number>;
7
+ export declare function registerPermalinkCommand(memos: Command): void;
@@ -0,0 +1,50 @@
1
+ import { memoHandle } from '../../api/memo-facade.js';
2
+ import { resolveCtx } from '../compat/ctx.js';
3
+ import { requireToken } from '../compat/http.js';
4
+ import { withConnFlags } from '../compat/flags.js';
5
+ import { emitJson, fail } from '../helpers.js';
6
+ import { memoTransport } from './api-transport.js';
7
+ import { ctx, resolveNote } from './index.js';
8
+ export async function runMemosPermalink(ref, opts) {
9
+ const c = resolveCtx(opts), token = requireToken(c);
10
+ if (!token)
11
+ return 1;
12
+ try {
13
+ let target = ref;
14
+ let namespace = opts.namespace?.trim().replace(/^@/, '') || undefined;
15
+ if (!/^[a-f0-9]{24}$/i.test(ref) && !ref.includes('/')) {
16
+ const scope = await ctx(opts);
17
+ if (!scope)
18
+ return 1;
19
+ const id = await resolveNote(scope, ref);
20
+ if (!id)
21
+ return 1;
22
+ target = id;
23
+ namespace = scope.ns;
24
+ }
25
+ const result = await memoHandle(memoTransport({ remote: c.remote, token }), target, { namespace })
26
+ .permalink(opts.slug === undefined ? {} : { slug: opts.slug });
27
+ if (opts.json)
28
+ emitJson(result);
29
+ else {
30
+ process.stdout.write(`${result.href}\n`);
31
+ for (const slug of result.aliases)
32
+ process.stdout.write(`Previous: ${slug}\n`);
33
+ }
34
+ return 0;
35
+ }
36
+ catch (error) {
37
+ // Reserved slugs are permanent conflicts, not RTC contention. Do not retry.
38
+ fail(error instanceof Error ? error.message : String(error));
39
+ return 1;
40
+ }
41
+ }
42
+ export function registerPermalinkCommand(memos) {
43
+ withConnFlags(memos.command('permalink').allowExcessArguments(false))
44
+ .description('get or allocate a public article URL, edit its slug, and list previous slugs')
45
+ .argument('<memo>', 'memo id, qualified reference, internal slug or exact title')
46
+ .option('--namespace <slug>', 'lookup namespace; with an id, asserts the owner')
47
+ .option('--slug <slug>', 'set the public URL slug; retain previous URLs')
48
+ .option('--json', 'emit current URL, namespace and alias history')
49
+ .action(async (memo, opts) => { process.exitCode = await runMemosPermalink(memo, opts); });
50
+ }
@@ -1 +1 @@
1
- export declare const VERSION = "0.108.0";
1
+ export declare const VERSION = "0.109.0";
@@ -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.108.0";
9
+ export const VERSION = "0.109.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.108.0",
3
+ "version": "0.109.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -36,13 +36,13 @@
36
36
  "node": ">=18"
37
37
  },
38
38
  "optionalDependencies": {
39
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.108.0",
40
- "@dreamlake/dreamlake-cli-darwin-x64": "0.108.0",
41
- "@dreamlake/dreamlake-cli-linux-x64": "0.108.0",
42
- "@dreamlake/dreamlake-cli-linux-arm64": "0.108.0",
43
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.108.0",
44
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.108.0",
45
- "@dreamlake/dreamlake-cli-win32-x64": "0.108.0",
46
- "@dreamlake/dreamlake-cli-win32-arm64": "0.108.0"
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"
47
47
  }
48
48
  }