@dreamlake/dreamlake-cli 0.125.0 → 0.125.2

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.
@@ -858,11 +858,11 @@ export declare function createApi(transport: Transport, storageFetch?: typeof fe
858
858
  }) => Promise<import("./project-audience.js").ProjectAudience>;
859
859
  access: ({ project }: import("./project-access.js").ProjectAccessTarget) => Promise<import("./project-access.js").ProjectAccess>;
860
860
  setAccess: ({ project, accessMode, visibility }: import("./project-access.js").ProjectAccessUpdate) => Promise<import("./project-access.js").ProjectAccess>;
861
+ update: (project: string, patch: import("./project-identity.js").ProjectIdentityPatch) => Promise<import("./project-identity.js").ProjectIdentity>;
861
862
  list: (query?: import("./common.js").Query) => Promise<{
862
863
  [key: string]: unknown;
863
864
  }>;
864
865
  get: (id: string) => Promise<import("./common.js").Resource>;
865
- update: (id: string, input: Partial<import("./workspace.js").ProjectInput>) => Promise<import("./common.js").Resource>;
866
866
  delete: (id: string) => Promise<unknown>;
867
867
  };
868
868
  nodes: {
@@ -2304,11 +2304,11 @@ export declare function createClient(options: ClientOptions): {
2304
2304
  }) => Promise<import("./project-audience.js").ProjectAudience>;
2305
2305
  access: ({ project }: import("./project-access.js").ProjectAccessTarget) => Promise<import("./project-access.js").ProjectAccess>;
2306
2306
  setAccess: ({ project, accessMode, visibility }: import("./project-access.js").ProjectAccessUpdate) => Promise<import("./project-access.js").ProjectAccess>;
2307
+ update: (project: string, patch: import("./project-identity.js").ProjectIdentityPatch) => Promise<import("./project-identity.js").ProjectIdentity>;
2307
2308
  list: (query?: import("./common.js").Query) => Promise<{
2308
2309
  [key: string]: unknown;
2309
2310
  }>;
2310
2311
  get: (id: string) => Promise<import("./common.js").Resource>;
2311
- update: (id: string, input: Partial<import("./workspace.js").ProjectInput>) => Promise<import("./common.js").Resource>;
2312
2312
  delete: (id: string) => Promise<unknown>;
2313
2313
  };
2314
2314
  nodes: {
@@ -0,0 +1,2 @@
1
+ /** Use the immutable ID, never a title, slug, URL or short display hash. */
2
+ export declare function memoDirective(id: string): string;
@@ -0,0 +1,6 @@
1
+ /** Use the immutable ID, never a title, slug, URL or short display hash. */
2
+ export function memoDirective(id) {
3
+ if (typeof id !== "string" || !/^[a-f0-9]{24}$/i.test(id))
4
+ throw new Error("Memo may already exist, but its full ID was not confirmed. Inspect Memos before creating again.");
5
+ return `:memo[${id}]`;
6
+ }
@@ -245,6 +245,7 @@ export interface MemoHandle {
245
245
  }
246
246
  export type CreatedMemo = MemoHandle & {
247
247
  id: string;
248
+ directive: string;
248
249
  created: MemoRow;
249
250
  };
250
251
  export interface MemosFacade {
@@ -359,7 +359,7 @@ export function memosFacade(t) {
359
359
  throw new MemoCreatedWithoutSource(created.note.id, namespace, outcome, { cause: error });
360
360
  }
361
361
  }
362
- return Object.assign(memoHandle(t, created.note.id, { namespace }), { id: created.note.id, created: created.note });
362
+ return Object.assign(memoHandle(t, created.note.id, { namespace }), { id: created.note.id, directive: created.note.directive, created: created.note });
363
363
  };
364
364
  return open;
365
365
  }
@@ -37,6 +37,8 @@ export interface MemoSearchPage {
37
37
  staleNotes: number;
38
38
  }
39
39
  export interface MemoRow {
40
+ /** Canonical source; titles/slugs are not reference identities. */
41
+ directive?: string;
40
42
  coverFileId?: string | null;
41
43
  id: string;
42
44
  name: string;
@@ -275,7 +277,23 @@ export declare function memosApi(t: Transport, namespace: string): {
275
277
  projects?: string[];
276
278
  visibility?: "private" | "public" | "unlisted";
277
279
  }) => Promise<{
278
- note: MemoRow;
280
+ note: {
281
+ directive: string;
282
+ coverFileId?: string | null;
283
+ id: string;
284
+ name: string;
285
+ slug: string;
286
+ namespaceSlug?: string;
287
+ visibility?: string;
288
+ updatedAt?: string;
289
+ /** Independent lifecycle state; null/missing means active. */
290
+ archivedAt?: string | null;
291
+ matches?: {
292
+ anchor: string;
293
+ title: string;
294
+ snippet: string;
295
+ }[];
296
+ };
279
297
  rtc: {
280
298
  rtcDocId: string;
281
299
  };
package/dist/api/memos.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { memoDirective } from "./memo-directive.js";
1
2
  import { readMemoView } from "./memo-reading.js";
2
3
  import { validateHtmlSnapshot, scopedSourceRange } from "./memo-html-read.js";
3
4
  import { characterDiff } from "./memo-character-plan.js";
@@ -189,9 +190,11 @@ export function memosApi(t, namespace) {
189
190
  diff: (noteId, query) => t.request("GET", `${base}/${id(noteId)}/diff`, { query }),
190
191
  saveVersion: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/versions`, { json: input }),
191
192
  find: (query) => t.request("GET", `${base}/search`, { query }),
192
- create: (input) => t.request("POST", base, {
193
- json: input,
194
- }),
193
+ create: async (input) => {
194
+ const created = await t.request("POST", base, { json: input });
195
+ const directive = memoDirective(created?.note?.id);
196
+ return { ...created, note: { ...created.note, directive } };
197
+ },
195
198
  edit: async (noteId, baseRevision, edits, mode = "exact", options) => patch(noteId, withCommand(memoEdits(await source(noteId, baseRevision), edits, mode), options)),
196
199
  /** The durable record of one command id, scoped to the calling actor; 404 `command_not_found` when none. */
197
200
  commandStatus: async (noteId, commandId) => readMemoCommand(t, `${base}/${id(noteId)}/commands/${seg(validateCommandId(commandId))}`, commandId),
@@ -0,0 +1,21 @@
1
+ import { type Transport } from './client.js';
2
+ export interface ProjectIdentityPatch {
3
+ name?: string;
4
+ slug?: string;
5
+ slugMode?: 'auto' | 'custom';
6
+ description?: string;
7
+ visibility?: 'private' | 'public';
8
+ tags?: string[];
9
+ metadata?: Record<string, unknown>;
10
+ expectedProjectId?: string;
11
+ expectedSlugRevision?: number;
12
+ }
13
+ export interface ProjectIdentity {
14
+ id: string;
15
+ name: string;
16
+ slug: string;
17
+ slugMode: 'auto' | 'custom';
18
+ slugRevision: number;
19
+ }
20
+ /** Resolve once, bind to stable identity/revision, and never retry an uncertain write. */
21
+ export declare function updateProjectIdentity(t: Transport, namespace: string, target: string, patch: ProjectIdentityPatch): Promise<ProjectIdentity>;
@@ -0,0 +1,34 @@
1
+ import { seg } from './client.js';
2
+ /** Resolve once, bind to stable identity/revision, and never retry an uncertain write. */
3
+ export async function updateProjectIdentity(t, namespace, target, patch) {
4
+ if (!namespace.trim() || !target.trim())
5
+ throw new Error('An explicit namespace and project are required');
6
+ if (patch.slug !== undefined && patch.slugMode === 'auto')
7
+ throw new Error('slug and slugMode=auto cannot be combined');
8
+ if (patch.expectedSlugRevision !== undefined && (!Number.isSafeInteger(patch.expectedSlugRevision) || patch.expectedSlugRevision < 0))
9
+ throw new Error('expectedSlugRevision must be a nonnegative safe integer');
10
+ const base = `/namespaces/${seg(namespace)}/projects`;
11
+ const current = await t.request('GET', `${base}/${seg(target)}`);
12
+ if (typeof current?.id !== 'string' || !/^[a-fA-F0-9]{24}$/.test(current.id)
13
+ || !['auto', 'custom'].includes(current.slugMode) || !Number.isSafeInteger(current.slugRevision) || current.slugRevision < 0)
14
+ throw new Error('Server does not advertise project slug settings; no update submitted');
15
+ if (patch.expectedProjectId !== undefined && patch.expectedProjectId !== current.id)
16
+ throw new Error('Project identity changed; no update submitted');
17
+ const result = await t.request('PATCH', `${base}/${seg(current.id)}`, { json: {
18
+ ...patch, expectedProjectId: current.id, expectedSlugRevision: patch.expectedSlugRevision ?? current.slugRevision,
19
+ } });
20
+ const expectedMode = patch.slugMode ?? (patch.slug !== undefined ? 'custom' : current.slugMode);
21
+ const expectedSlug = patch.slug ?? (expectedMode === 'custom' ? current.slug : undefined);
22
+ // Metadata has the same precedence as the server's merged project fields.
23
+ const requestedName = patch.metadata?.displayName ?? patch.name;
24
+ const expectedName = typeof requestedName === 'string' && requestedName !== current.name
25
+ ? requestedName.trim() : requestedName;
26
+ if (result?.id !== current.id || typeof result.slug !== 'string' || !result.slug
27
+ || /[,/]/.test(result.slug) || result.slug === '.' || result.slug === '..'
28
+ || result.slugMode !== expectedMode
29
+ || !Number.isSafeInteger(result.slugRevision) || result.slugRevision < current.slugRevision
30
+ || (expectedSlug !== undefined && result.slug !== expectedSlug)
31
+ || (requestedName !== undefined && result.name !== expectedName))
32
+ throw new Error('Project update outcome unconfirmed; inspect the stable project ID before retrying');
33
+ return result;
34
+ }
@@ -1,3 +1,5 @@
1
+ import { type ProjectIdentityPatch } from './project-identity.js';
2
+ export * from './project-identity.js';
1
3
  export * from "./bindrs.js";
2
4
  import { type ProjectAccessMode } from "./project-access.js";
3
5
  /** Workspace resource APIs. Authentication/ACLs stay in the existing service routes. */
@@ -5,6 +7,7 @@ import { type Transport } from "./client.js";
5
7
  import { type JsonObject, type Query, type Resource } from "./common.js";
6
8
  export interface ProjectInput {
7
9
  name: string;
10
+ slug?: string;
8
11
  accessMode?: ProjectAccessMode;
9
12
  description?: string;
10
13
  visibility?: "private" | "public" | "team";
@@ -136,11 +139,11 @@ export declare function projectsApi(t: Transport, namespace: string): {
136
139
  }) => Promise<import("./project-audience.js").ProjectAudience>;
137
140
  access: ({ project }: import("./project-access.js").ProjectAccessTarget) => Promise<import("./project-access.js").ProjectAccess>;
138
141
  setAccess: ({ project, accessMode, visibility }: import("./project-access.js").ProjectAccessUpdate) => Promise<import("./project-access.js").ProjectAccess>;
142
+ update: (project: string, patch: ProjectIdentityPatch) => Promise<import("./project-identity.js").ProjectIdentity>;
139
143
  list: (query?: Query) => Promise<{
140
144
  [key: string]: unknown;
141
145
  }>;
142
146
  get: (id: string) => Promise<Resource>;
143
- update: (id: string, input: Partial<ProjectInput>) => Promise<Resource>;
144
147
  delete: (id: string) => Promise<unknown>;
145
148
  };
146
149
  export interface ProjectResourceRow {
@@ -1,3 +1,5 @@
1
+ import { updateProjectIdentity } from './project-identity.js';
2
+ export * from './project-identity.js';
1
3
  import { projectAudienceApi } from "./project-audience.js";
2
4
  import { bindrsApi } from "./bindrs.js";
3
5
  export * from "./bindrs.js";
@@ -17,6 +19,7 @@ export function projectsApi(t, namespace) {
17
19
  }
18
20
  return {
19
21
  ...resourceApi(t, base),
22
+ update: (project, patch) => updateProjectIdentity(t, namespace, project, patch),
20
23
  ...projectAccessApi(t, namespace),
21
24
  ...projectAudienceApi(t, namespace),
22
25
  create: (input) => createProjectWithAccess(t, namespace, input),
@@ -218,6 +218,7 @@ export const helpExamples = {
218
218
  "project detach": "dl project detach research --namespace acme --type note --resource \"$MEMO_ID\"",
219
219
  "project permissions": "# Choose organization and Project with the keyboard.\ndl project permissions\n# Or select the owning namespace and exact Project up front.\ndl project permissions research --namespace acme",
220
220
  "project audience": "dl project audience research --namespace acme --json",
221
+ "project rename": "dl project rename research \"Research Results\" --namespace my-team\ndl project rename research --namespace my-team --slug stable-research\ndl project rename stable-research --namespace my-team --auto-slug",
221
222
  "provider create": "dl provider create -n aws-demo --provider aws-jump-worker --json\n# Read the generated AGENT.md and terraform/ENROLLMENT.md.\n# Fill terraform/terraform.tfvars.json and terraform/backend.json explicitly.\ndl provider create -n aws-demo --continue --json",
222
223
  "provider plan": "# Requires the selected backend and authorized AWS read access.\ndl provider plan -n aws-demo --json",
223
224
  "provider machine": "dl provider machine status -n aws-dev --account 123456789012 --json\ndl provider machine start -n aws-dev --account 123456789012 --yes\ndl provider machine terminal -n aws-dev --account 123456789012\ndl provider machine stop -n aws-dev --account 123456789012 --yes",
@@ -1,3 +1,4 @@
1
+ import { memoDirective } from "../../api/memo-directive.js";
1
2
  import { memoPresenceApi, memoPresenceIntent, formatMemoPresence } from '../../api/memo-presence.js';
2
3
  import { memoTransport } from './api-transport.js';
3
4
  import { collectionList } from "../collection-list.js";
@@ -1172,6 +1173,7 @@ export async function runMemosCreate(name, opts) {
1172
1173
  json: { name, visibility: opts.visibility ?? (opts.public ? "public" : "private"), ...(opts.project?.length ? { projects: [...new Set(opts.project)] } : {}) },
1173
1174
  token: c.token,
1174
1175
  });
1176
+ const directive = memoDirective(created?.note?.id);
1175
1177
  const id = created.note.id;
1176
1178
  let etag;
1177
1179
  if (body) {
@@ -1181,10 +1183,10 @@ export async function runMemosCreate(name, opts) {
1181
1183
  etag = w.etag;
1182
1184
  }
1183
1185
  if (opts.json)
1184
- return emitJson({ ...created.note, etag }), 0;
1186
+ return emitJson({ ...created.note, directive, etag }), 0;
1185
1187
  // The slug can differ from the title — duplicates take a suffix — so print
1186
1188
  // what was actually created rather than what was asked for.
1187
- process.stdout.write(`✓ created ${created.note.slug}\n id ${id}\n`);
1189
+ process.stdout.write(`✓ created ${created.note.slug}\n id ${id}\n reference ${directive}\n`);
1188
1190
  return 0;
1189
1191
  }
1190
1192
  catch (e) {
@@ -13,7 +13,7 @@ const hash = (text) => 'sha256:' + createHash('sha256').update(text, 'utf8').dig
13
13
  // Keep resource atoms byte-for-byte, including attributes/fragments and legacy forms.
14
14
  // Conservative even inside code: intentional changes use the explicit override.
15
15
  export function resourceAtoms(text) {
16
- return text.match(/:(?:note|artifact|dashboard|experiment|project|folder|bindr|asset-reference)\[(?:\\.|[^\]\\])*\](?:\{(?:\\.|[^}\\])*\})?|:(?:note|artifact)\{(?:\\.|[^}\\])*\}|#(?:note|artifact):[^\s)<>]+/g) ?? [];
16
+ return text.match(/:(?:memo|note|artifact|dashboard|experiment|project|folder|bindr|asset-reference)\[(?:\\.|[^\]\\])*\](?:\{(?:\\.|[^}\\])*\})?|:(?:memo|note|artifact)\{(?:\\.|[^}\\])*\}|#(?:note|artifact):[^\s)<>]+/g) ?? [];
17
17
  }
18
18
  export function revisionBody(source, draft, options) {
19
19
  tokens(source, source.note);
@@ -1,3 +1,4 @@
1
+ import { runProjectRename } from './rename.js';
1
2
  import { runProjectPermissions, runProjectAudience } from './permissions.js';
2
3
  import { runProjectAccess } from './access.js';
3
4
  import { runProjectAttachment } from './attachments.js';
@@ -34,6 +35,13 @@ export async function runProjectRead(action, project, opts) {
34
35
  }
35
36
  export function registerProjectCommand(program) {
36
37
  const group = program.command('project').description('Inspect or share a Project, or request whole ownership transfer');
38
+ withConnFlags(group.command('rename <project> [name]'))
39
+ .description('rename a Project; auto slugs follow its name, custom slugs persist')
40
+ .requiredOption('--namespace <slug>', 'owning namespace')
41
+ .option('--slug <slug>', 'set a custom slug that persists on later renames')
42
+ .option('--auto-slug', 'reset the slug to follow the project name')
43
+ .option('--json', 'print the updated identity and address settings')
44
+ .action(async (project, name, options) => { process.exitCode = await runProjectRename(project, name, options); });
37
45
  withConnFlags(group.command('permissions [project]'))
38
46
  .description('interactive keyboard management of Project audience, grants and access mode')
39
47
  .option('--namespace <slug>', 'owning namespace; omit to choose')
@@ -0,0 +1,7 @@
1
+ import { type DreamlakeOpts } from '../compat/ctx.js';
2
+ export declare function runProjectRename(project: string, name: string | undefined, options: DreamlakeOpts & {
3
+ namespace: string;
4
+ slug?: string;
5
+ autoSlug?: boolean;
6
+ json?: boolean;
7
+ }): Promise<number>;
@@ -0,0 +1,27 @@
1
+ import { createClient } from '../../api/index.js';
2
+ import { resolveCtx } from '../compat/ctx.js';
3
+ import { fail } from '../helpers.js';
4
+ import { emitProjectResult } from './output.js';
5
+ export async function runProjectRename(project, name, options) {
6
+ try {
7
+ if (!options.namespace?.trim() || !project.trim())
8
+ throw new Error('An explicit namespace and project are required');
9
+ if (name === undefined && options.slug === undefined && !options.autoSlug)
10
+ throw new Error('Supply a name, --slug, or --auto-slug');
11
+ if (options.slug !== undefined && options.autoSlug)
12
+ throw new Error('--slug and --auto-slug cannot be combined');
13
+ const c = resolveCtx(options);
14
+ if (!c.token)
15
+ throw new Error("Not authenticated — run 'dl login' first");
16
+ const result = await createClient({ remote: c.remote, token: c.token }).projects(options.namespace).update(project, {
17
+ ...(name !== undefined ? { name } : {}), ...(options.slug !== undefined ? { slug: options.slug } : {}),
18
+ ...(options.autoSlug ? { slugMode: 'auto' } : {}),
19
+ });
20
+ emitProjectResult(result, () => `${result.name}\n${options.namespace}/${result.slug} (${result.slugMode})\nProject ID: ${result.id}`, options.json);
21
+ return 0;
22
+ }
23
+ catch (error) {
24
+ fail(error.message);
25
+ return 1;
26
+ }
27
+ }
@@ -1 +1 @@
1
- export declare const VERSION = "0.125.0";
1
+ export declare const VERSION = "0.125.2";
@@ -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.125.0";
9
+ export const VERSION = "0.125.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.125.0",
3
+ "version": "0.125.2",
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.125.0",
41
- "@dreamlake/dreamlake-cli-darwin-x64": "0.125.0",
42
- "@dreamlake/dreamlake-cli-linux-x64": "0.125.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64": "0.125.0",
44
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.125.0",
45
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.125.0",
46
- "@dreamlake/dreamlake-cli-win32-x64": "0.125.0",
47
- "@dreamlake/dreamlake-cli-win32-arm64": "0.125.0"
40
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.125.2",
41
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.125.2",
42
+ "@dreamlake/dreamlake-cli-linux-x64": "0.125.2",
43
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.125.2",
44
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.125.2",
45
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.125.2",
46
+ "@dreamlake/dreamlake-cli-win32-x64": "0.125.2",
47
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.125.2"
48
48
  }
49
49
  }