@dreamlake/dreamlake-cli 0.96.0 → 0.97.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.
@@ -541,8 +541,12 @@ export declare function createApi(transport: Transport): {
541
541
  namespaceSlug: string;
542
542
  permissions: Record<string, boolean>;
543
543
  }>;
544
+ archive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
545
+ unarchive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
544
546
  delete: (noteId: string) => Promise<unknown>;
545
- shared: () => Promise<{
547
+ shared: (query?: {
548
+ includeArchived?: boolean;
549
+ }) => Promise<{
546
550
  notes: import("./notes.js").NoteRow[];
547
551
  }>;
548
552
  projects: (noteId: string, view?: "nodes") => Promise<unknown>;
@@ -646,6 +650,7 @@ export declare function createApi(transport: Transport): {
646
650
  note?: string;
647
651
  cursor?: string;
648
652
  limit?: number;
653
+ includeArchived?: boolean;
649
654
  caseSensitive?: boolean;
650
655
  glob?: string;
651
656
  regex?: string;
@@ -681,10 +686,13 @@ export declare function createApi(transport: Transport): {
681
686
  q?: string;
682
687
  limit?: number;
683
688
  offset?: number;
689
+ includeArchived?: boolean;
684
690
  }) => Promise<{
685
691
  notes: import("./notes.js").NoteRow[];
686
692
  }>;
687
- search: (q: string, limit?: number, offset?: number) => Promise<{
693
+ search: (q: string, limit?: number, offset?: number, options?: {
694
+ includeArchived?: boolean;
695
+ }) => Promise<{
688
696
  notes: import("./notes.js").NoteRow[];
689
697
  total: number;
690
698
  }>;
@@ -736,6 +744,13 @@ export declare function createApi(transport: Transport): {
736
744
  type: string;
737
745
  resourceId: string;
738
746
  }) => Promise<unknown>;
747
+ resourceList: (project: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<{
748
+ resources: import("./workspace.js").ProjectResourceRow[];
749
+ page: number;
750
+ pageSize: number;
751
+ total: number;
752
+ totalPages: number;
753
+ }>;
739
754
  resources: (project: string, kind: "bindrs" | "datasets" | "episodes") => {
740
755
  list: (query?: import("./common.js").Query) => Promise<{
741
756
  [key: string]: unknown;
@@ -776,15 +791,19 @@ export declare function createApi(transport: Transport): {
776
791
  delete: (id: string) => Promise<unknown>;
777
792
  };
778
793
  nodes: {
779
- list: (query?: import("./common.js").Query) => Promise<unknown>;
780
- children: (query: import("./common.js").Query) => Promise<unknown>;
794
+ list: (query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
795
+ children: (query: import("./workspace.js").NodeTreeQuery) => Promise<import("./workspace.js").NodeChildrenPage>;
796
+ descendants: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
797
+ archive: (id: string) => Promise<import("./workspace.js").NodeRow>;
798
+ unarchive: (id: string) => Promise<import("./workspace.js").NodeRow>;
781
799
  lookup: (query: {
782
800
  namespace: string;
783
801
  project: string;
784
802
  path: string;
785
803
  episode?: string;
786
804
  }) => Promise<import("./common.js").Resource>;
787
- contents: (id: string, query?: import("./common.js").Query) => Promise<unknown>;
805
+ episodes: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
806
+ contents: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
788
807
  update: (id: string, input: import("./common.js").JsonObject) => Promise<unknown>;
789
808
  delete: (id: string) => Promise<{
790
809
  deleted?: number;
@@ -1740,8 +1759,12 @@ export declare function createClient(options: ClientOptions): {
1740
1759
  namespaceSlug: string;
1741
1760
  permissions: Record<string, boolean>;
1742
1761
  }>;
1762
+ archive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
1763
+ unarchive: (noteId: string) => Promise<import("./notes.js").NoteRow>;
1743
1764
  delete: (noteId: string) => Promise<unknown>;
1744
- shared: () => Promise<{
1765
+ shared: (query?: {
1766
+ includeArchived?: boolean;
1767
+ }) => Promise<{
1745
1768
  notes: import("./notes.js").NoteRow[];
1746
1769
  }>;
1747
1770
  projects: (noteId: string, view?: "nodes") => Promise<unknown>;
@@ -1845,6 +1868,7 @@ export declare function createClient(options: ClientOptions): {
1845
1868
  note?: string;
1846
1869
  cursor?: string;
1847
1870
  limit?: number;
1871
+ includeArchived?: boolean;
1848
1872
  caseSensitive?: boolean;
1849
1873
  glob?: string;
1850
1874
  regex?: string;
@@ -1880,10 +1904,13 @@ export declare function createClient(options: ClientOptions): {
1880
1904
  q?: string;
1881
1905
  limit?: number;
1882
1906
  offset?: number;
1907
+ includeArchived?: boolean;
1883
1908
  }) => Promise<{
1884
1909
  notes: import("./notes.js").NoteRow[];
1885
1910
  }>;
1886
- search: (q: string, limit?: number, offset?: number) => Promise<{
1911
+ search: (q: string, limit?: number, offset?: number, options?: {
1912
+ includeArchived?: boolean;
1913
+ }) => Promise<{
1887
1914
  notes: import("./notes.js").NoteRow[];
1888
1915
  total: number;
1889
1916
  }>;
@@ -1935,6 +1962,13 @@ export declare function createClient(options: ClientOptions): {
1935
1962
  type: string;
1936
1963
  resourceId: string;
1937
1964
  }) => Promise<unknown>;
1965
+ resourceList: (project: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<{
1966
+ resources: import("./workspace.js").ProjectResourceRow[];
1967
+ page: number;
1968
+ pageSize: number;
1969
+ total: number;
1970
+ totalPages: number;
1971
+ }>;
1938
1972
  resources: (project: string, kind: "bindrs" | "datasets" | "episodes") => {
1939
1973
  list: (query?: import("./common.js").Query) => Promise<{
1940
1974
  [key: string]: unknown;
@@ -1975,15 +2009,19 @@ export declare function createClient(options: ClientOptions): {
1975
2009
  delete: (id: string) => Promise<unknown>;
1976
2010
  };
1977
2011
  nodes: {
1978
- list: (query?: import("./common.js").Query) => Promise<unknown>;
1979
- children: (query: import("./common.js").Query) => Promise<unknown>;
2012
+ list: (query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
2013
+ children: (query: import("./workspace.js").NodeTreeQuery) => Promise<import("./workspace.js").NodeChildrenPage>;
2014
+ descendants: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
2015
+ archive: (id: string) => Promise<import("./workspace.js").NodeRow>;
2016
+ unarchive: (id: string) => Promise<import("./workspace.js").NodeRow>;
1980
2017
  lookup: (query: {
1981
2018
  namespace: string;
1982
2019
  project: string;
1983
2020
  path: string;
1984
2021
  episode?: string;
1985
2022
  }) => Promise<import("./common.js").Resource>;
1986
- contents: (id: string, query?: import("./common.js").Query) => Promise<unknown>;
2023
+ episodes: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
2024
+ contents: (id: string, query?: import("./workspace.js").NodeTreeQuery) => Promise<unknown>;
1987
2025
  update: (id: string, input: import("./common.js").JsonObject) => Promise<unknown>;
1988
2026
  delete: (id: string) => Promise<{
1989
2027
  deleted?: number;
@@ -34,6 +34,8 @@ export interface NoteRow {
34
34
  namespaceSlug?: string;
35
35
  visibility?: string;
36
36
  updatedAt?: string;
37
+ /** Independent lifecycle state; null/missing means active. */
38
+ archivedAt?: string | null;
37
39
  matches?: {
38
40
  anchor: string;
39
41
  title: string;
@@ -151,8 +153,13 @@ export declare function notesApi(t: Transport, namespace: string): {
151
153
  namespaceSlug: string;
152
154
  permissions: Record<string, boolean>;
153
155
  }>;
156
+ /** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
157
+ archive: (noteId: string) => Promise<NoteRow>;
158
+ unarchive: (noteId: string) => Promise<NoteRow>;
154
159
  delete: (noteId: string) => Promise<unknown>;
155
- shared: () => Promise<{
160
+ shared: (query?: {
161
+ includeArchived?: boolean;
162
+ }) => Promise<{
156
163
  notes: NoteRow[];
157
164
  }>;
158
165
  projects: (noteId: string, view?: "nodes") => Promise<unknown>;
@@ -256,6 +263,7 @@ export declare function notesApi(t: Transport, namespace: string): {
256
263
  note?: string;
257
264
  cursor?: string;
258
265
  limit?: number;
266
+ includeArchived?: boolean;
259
267
  caseSensitive?: boolean;
260
268
  glob?: string;
261
269
  regex?: string;
@@ -291,10 +299,13 @@ export declare function notesApi(t: Transport, namespace: string): {
291
299
  q?: string;
292
300
  limit?: number;
293
301
  offset?: number;
302
+ includeArchived?: boolean;
294
303
  }) => Promise<{
295
304
  notes: NoteRow[];
296
305
  }>;
297
- search: (q: string, limit?: number, offset?: number) => Promise<{
306
+ search: (q: string, limit?: number, offset?: number, options?: {
307
+ includeArchived?: boolean;
308
+ }) => Promise<{
298
309
  notes: NoteRow[];
299
310
  total: number;
300
311
  }>;
package/dist/api/notes.js CHANGED
@@ -60,11 +60,17 @@ export function notesApi(t, namespace) {
60
60
  resolve: async (ref) => {
61
61
  if (/^[a-f0-9]{24}$/i.test(ref))
62
62
  return ref;
63
- const result = await t.request('GET', base, { query: { limit: 200 } });
64
- const hit = result.notes.find(row => row.slug === ref || row.id === ref || row.name === ref);
65
- if (!hit)
66
- throw new ApiError(404, 'note_not_found', { namespace, ref });
67
- return hit.id;
63
+ let offset = 0;
64
+ for (;;) {
65
+ const result = await t.request('GET', base, { query: { limit: 200, offset, includeArchived: true } });
66
+ const hit = result.notes.find(row => row.slug === ref || row.id === ref || row.name === ref);
67
+ if (hit)
68
+ return hit.id;
69
+ offset += result.notes.length;
70
+ if (!result.notes.length || (result.total === undefined ? result.notes.length < 200 : offset >= result.total))
71
+ break;
72
+ }
73
+ throw new ApiError(404, 'note_not_found', { namespace, ref });
68
74
  },
69
75
  /** CSS inspection is read-only; selectText publishes a separate agent selection. */
70
76
  selectElement: async (noteId, css) => {
@@ -113,8 +119,11 @@ export function notesApi(t, namespace) {
113
119
  };
114
120
  },
115
121
  get: (noteId) => t.request("GET", `/notes/${id(noteId)}`),
122
+ /** Archive independently of delete/tags. A saved edit restores the note and its folder path. */
123
+ archive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: true } }),
124
+ unarchive: (noteId) => t.request("PATCH", `${base}/${id(noteId)}`, { json: { archived: false } }),
116
125
  delete: (noteId) => t.request("DELETE", `${base}/${id(noteId)}`),
117
- shared: () => t.request("GET", "/me/notes/shared"),
126
+ shared: (query = {}) => t.request("GET", "/me/notes/shared", { query }),
118
127
  projects: (noteId, view) => t.request("GET", `/namespaces/${seg(namespace)}/resources/note/${id(noteId)}/projects`, { query: { view } }),
119
128
  move: (noteId, input) => t.request("POST", `${base}/${id(noteId)}/move`, { json: input }),
120
129
  share: (noteId) => sharingApi(t, namespace, "notes", id(noteId)),
@@ -172,8 +181,8 @@ export function notesApi(t, namespace) {
172
181
  versions: (noteId, query = {}) => t.request("GET", `${base}/${id(noteId)}/versions`, { query }),
173
182
  version: (noteId, versionId) => t.request("GET", `${base}/${id(noteId)}/versions/${seg(versionId)}`),
174
183
  list: (query = {}) => t.request("GET", base, { query }),
175
- search: (q, limit = 50, offset = 0) => t.request("GET", base, {
176
- query: { q, limit, offset },
184
+ search: (q, limit = 50, offset = 0, options = {}) => t.request("GET", base, {
185
+ query: { q, limit, offset, ...options },
177
186
  }),
178
187
  body: (noteId) => t.request("GET", `${base}/${id(noteId)}/body`),
179
188
  sections: (noteId) => t.request("GET", `${base}/${id(noteId)}/sections`),
@@ -26,6 +26,14 @@ export declare function projectsApi(t: Transport, namespace: string): {
26
26
  type: string;
27
27
  resourceId: string;
28
28
  }) => Promise<unknown>;
29
+ /** Mixed project resources, or one bindr's members via the bindr filter. */
30
+ resourceList: (project: string, query?: NodeTreeQuery) => Promise<{
31
+ resources: ProjectResourceRow[];
32
+ page: number;
33
+ pageSize: number;
34
+ total: number;
35
+ totalPages: number;
36
+ }>;
29
37
  resources: (project: string, kind: "bindrs" | "datasets" | "episodes") => {
30
38
  list: (query?: Query) => Promise<{
31
39
  [key: string]: unknown;
@@ -65,16 +73,47 @@ export declare function projectsApi(t: Transport, namespace: string): {
65
73
  update: (id: string, input: Partial<ProjectInput>) => Promise<Resource>;
66
74
  delete: (id: string) => Promise<unknown>;
67
75
  };
76
+ export interface ProjectResourceRow {
77
+ nodeId: string;
78
+ name: string;
79
+ kind: string;
80
+ archivedAt?: string | null;
81
+ [key: string]: unknown;
82
+ }
83
+ export interface NodeRow extends Resource {
84
+ name?: string;
85
+ kind?: string;
86
+ archivedAt?: string | null;
87
+ }
88
+ export type NodeTreeQuery = Query & {
89
+ includeArchived?: boolean;
90
+ };
91
+ export interface NodeChildrenPage {
92
+ nodes: NodeRow[];
93
+ page?: number;
94
+ pageSize?: number;
95
+ total?: number;
96
+ totalPages?: number;
97
+ /** Recursive search uses cursors rather than page numbers. */
98
+ nextCursor?: string | null;
99
+ hasMore?: boolean;
100
+ searchMode?: string;
101
+ }
68
102
  export declare function nodesApi(t: Transport): {
69
- list: (query?: Query) => Promise<unknown>;
70
- children: (query: Query) => Promise<unknown>;
103
+ list: (query?: NodeTreeQuery) => Promise<unknown>;
104
+ children: (query: NodeTreeQuery) => Promise<NodeChildrenPage>;
105
+ descendants: (id: string, query?: NodeTreeQuery) => Promise<unknown>;
106
+ /** Only folder nodes are archivable; the server enforces kind and write access. */
107
+ archive: (id: string) => Promise<NodeRow>;
108
+ unarchive: (id: string) => Promise<NodeRow>;
71
109
  lookup: (query: {
72
110
  namespace: string;
73
111
  project: string;
74
112
  path: string;
75
113
  episode?: string;
76
114
  }) => Promise<Resource>;
77
- contents: (id: string, query?: Query) => Promise<unknown>;
115
+ episodes: (id: string, query?: NodeTreeQuery) => Promise<unknown>;
116
+ contents: (id: string, query?: NodeTreeQuery) => Promise<unknown>;
78
117
  update: (id: string, input: JsonObject) => Promise<unknown>;
79
118
  delete: (id: string) => Promise<{
80
119
  deleted?: number;
@@ -44,6 +44,8 @@ export function projectsApi(t, namespace) {
44
44
  resourceId: input.resourceId,
45
45
  });
46
46
  },
47
+ /** Mixed project resources, or one bindr's members via the bindr filter. */
48
+ resourceList: (project, query = {}) => call(t, "GET", path(project) + "/resources", undefined, query),
47
49
  resources: (project, kind) => resourceApi(t, path(project) + "/" + kind),
48
50
  bindrs: (project) => ({
49
51
  ...resourceApi(t, path(project) + "/bindrs"),
@@ -67,8 +69,13 @@ export function nodesApi(t) {
67
69
  return {
68
70
  list: (query = {}) => call(t, "GET", "/nodes", undefined, query),
69
71
  children: (query) => call(t, "GET", "/nodes/children", undefined, query),
72
+ descendants: (id, query = {}) => call(t, "GET", `/nodes/${seg(id)}/descendants`, undefined, { ...query, includeArchived: query.includeArchived ?? false }),
73
+ /** Only folder nodes are archivable; the server enforces kind and write access. */
74
+ archive: (id) => call(t, "PATCH", `/nodes/${seg(id)}`, { archived: true }),
75
+ unarchive: (id) => call(t, "PATCH", `/nodes/${seg(id)}`, { archived: false }),
70
76
  lookup: (query) => call(t, "GET", "/nodes/lookup", undefined, query),
71
- contents: (id, query = {}) => call(t, "GET", `/nodes/${seg(id)}/contents`, undefined, query),
77
+ episodes: (id, query = {}) => call(t, "GET", `/nodes/${seg(id)}/episodes`, undefined, query),
78
+ contents: (id, query = {}) => call(t, "GET", `/nodes/${seg(id)}/contents`, undefined, { ...query, includeArchived: query.includeArchived ?? false }),
72
79
  update: (id, input) => call(t, "PATCH", `/nodes/${seg(id)}`, input),
73
80
  delete: (id) => call(t, "DELETE", `/nodes/${seg(id)}`),
74
81
  download: (id) => call(t, "GET", `/nodes/${seg(id)}/download`),
@@ -21,7 +21,7 @@ export async function runCreateBindr(name, opts) {
21
21
  const base = `/namespaces/${s.namespace}/projects/${s.project}/bindrs`;
22
22
  let members = [];
23
23
  if (opts.episode) {
24
- const episodes = await fetchAllEpisodes(remote, s.namespace, s.project, token);
24
+ const episodes = await fetchAllEpisodes(remote, s.namespace, s.project, token, { includeArchived: true });
25
25
  const matched = matchEpisodes(episodes, opts.episode);
26
26
  if (matched.length === 0) {
27
27
  fail(`no episodes match '${opts.episode}'`);
@@ -97,7 +97,7 @@ export async function runDeleteEpisode(name, opts) {
97
97
  return 1;
98
98
  const { s, token, remote } = ctx;
99
99
  const proj = formatProject(s);
100
- const episodes = await fetchAllEpisodes(remote, s.namespace, s.project, token);
100
+ const episodes = await fetchAllEpisodes(remote, s.namespace, s.project, token, { includeArchived: true });
101
101
  const ep = episodes.find((e) => e.name === name);
102
102
  if (!ep) {
103
103
  fail(`episode '${name}' not found in ${proj}`);
@@ -95,7 +95,8 @@ export async function runDownload(opts) {
95
95
  // ── Container (folder / episode / project) — recursive ──────────
96
96
  const outDir = opts.output ?? node.name;
97
97
  const prefix = `${node.path ?? ""}${node.name},`;
98
- const files = await fetchAllContents(remote, token, node.id);
98
+ // An explicit recursive download includes the complete retained subtree.
99
+ const files = await fetchAllContents(remote, token, node.id, undefined, { includeArchived: true });
99
100
  if (files.length === 0) {
100
101
  process.stdout.write(` (no files under ${node.kind} '${node.name}')\n`);
101
102
  return 0;
@@ -0,0 +1,15 @@
1
+ /** Folder lifecycle and browsing use the shared node API. */
2
+ import type { Command } from 'commander';
3
+ import { type ConnOpts } from '../notes/index.js';
4
+ type Options = ConnOpts & {
5
+ json?: boolean;
6
+ project?: string;
7
+ parentId?: string;
8
+ includeArchived?: boolean;
9
+ page?: string;
10
+ pageSize?: string;
11
+ };
12
+ export declare function runFoldersList(opts: Options): Promise<number>;
13
+ export declare function runFoldersArchive(id: string, archived: boolean, opts: Options): Promise<number>;
14
+ export declare function registerFoldersCommand(program: Command): void;
15
+ export {};
@@ -0,0 +1,81 @@
1
+ import { nodesApi } from '../../api/workspace.js';
2
+ import { resolveCtx } from '../compat/ctx.js';
3
+ import { requireToken, requireNamespace } from '../compat/http.js';
4
+ import { withConnFlags } from '../compat/flags.js';
5
+ import { emitJson, fail, renderTable } from '../helpers.js';
6
+ import { noteTransport } from '../notes/api-transport.js';
7
+ import { report } from '../notes/index.js';
8
+ export async function runFoldersList(opts) {
9
+ const c = resolveCtx(opts), token = requireToken(c);
10
+ if (!token)
11
+ return 1;
12
+ try {
13
+ if (!opts.parentId && !opts.project) {
14
+ fail('pass --parent-id or --project (and optionally --namespace)');
15
+ return 1;
16
+ }
17
+ const namespace = opts.parentId ? undefined : await requireNamespace(c, opts.namespace);
18
+ if (!opts.parentId && !namespace)
19
+ return 1;
20
+ const page = Number(opts.page ?? 1), pageSize = Number(opts.pageSize ?? 50);
21
+ if (!Number.isInteger(page) || page < 1 || !Number.isInteger(pageSize) || pageSize < 1 || pageSize > 200) {
22
+ fail('--page must be positive; --page-size must be 1–200');
23
+ return 1;
24
+ }
25
+ const result = await nodesApi(noteTransport({ remote: c.remote, token })).children({
26
+ ...(opts.parentId ? { parentId: opts.parentId } : { namespace: namespace, project: opts.project }),
27
+ page, pageSize, ...(opts.includeArchived ? { includeArchived: true } : {}),
28
+ });
29
+ if (opts.json)
30
+ emitJson(result);
31
+ else {
32
+ process.stdout.write(renderTable(result.nodes.map(n => ({ ID: n.id, NAME: n.name ?? '', KIND: n.kind ?? '', ARCHIVED: n.archivedAt ?? '' })), ['ID', 'NAME', 'KIND', 'ARCHIVED']));
33
+ process.stdout.write(`\nPage ${result.page} of ${result.totalPages} (${result.total} items)\n`);
34
+ }
35
+ return 0;
36
+ }
37
+ catch (error) {
38
+ return report(error);
39
+ }
40
+ }
41
+ export async function runFoldersArchive(id, archived, opts) {
42
+ const c = resolveCtx(opts), token = requireToken(c);
43
+ if (!token)
44
+ return 1;
45
+ if (!/^[a-f0-9]{24}$/i.test(id)) {
46
+ fail('expected a 24-hex folder node id');
47
+ return 1;
48
+ }
49
+ try {
50
+ const api = nodesApi(noteTransport({ remote: c.remote, token }));
51
+ const result = await (archived ? api.archive(id) : api.unarchive(id));
52
+ if (opts.json)
53
+ emitJson(result);
54
+ else
55
+ process.stdout.write(`✓ ${archived ? 'archived' : 'unarchived'} folder ${id}\n`);
56
+ return 0;
57
+ }
58
+ catch (error) {
59
+ return report(error);
60
+ }
61
+ }
62
+ export function registerFoldersCommand(program) {
63
+ const folders = program.command('folders').description('browse folder contents and manage folder archival');
64
+ withConnFlags(folders.command('list').allowExcessArguments(false))
65
+ .description('list immediate contents of a folder or project root')
66
+ .option('--parent-id <id>', 'folder node id')
67
+ .option('--project <slug>', 'project root when no --parent-id is supplied')
68
+ .option('--namespace <slug>', 'project namespace')
69
+ .option('--include-archived', 'include archived items and paths')
70
+ .option('--page <n>', 'page number', '1')
71
+ .option('--page-size <n>', 'items per page (1–200)', '50')
72
+ .option('--json', 'emit nodes and pagination metadata')
73
+ .action(async (opts) => { process.exitCode = await runFoldersList(opts); });
74
+ for (const action of ['archive', 'unarchive']) {
75
+ withConnFlags(folders.command(action).allowExcessArguments(false))
76
+ .description(action === 'archive' ? 'archive a folder without deleting its contents' : 'unarchive a folder and restore its ancestor path')
77
+ .argument('<id>', 'folder node id')
78
+ .option('--json', 'emit updated folder metadata')
79
+ .action(async (id, opts) => { process.exitCode = await runFoldersArchive(id, action === 'archive', opts); });
80
+ }
81
+ }
@@ -67,6 +67,11 @@ export const helpExamples = {
67
67
  "layout apply": "dreamlake layout apply request.json --cdp http://127.0.0.1:9222 --page PAGE_ID --layout LAYOUT_ID",
68
68
  "machine": "dreamlake machine self\ndreamlake machine host 0123456789abcdef01234567\ndreamlake machine project 0123456789abcdef01234567",
69
69
  "auth identity": "dreamlake auth identity\ndreamlake --identity machine profile\ndreamlake --identity user profile",
70
+ "notes archive": "dreamlake notes archive NOTE_ID --json\n# With a slug or exact title, select its owning namespace.\ndreamlake notes archive release-plan --namespace acme",
71
+ "notes unarchive": "dreamlake notes unarchive NOTE_ID --json\n# Archived titles and slugs remain resolvable.\ndreamlake notes unarchive release-plan --namespace acme",
72
+ "folders list": "# List immediate contents at a project root or inside a folder.\ndreamlake folders list --project project-slug --namespace acme --include-archived --json\ndreamlake folders list --parent-id FOLDER_ID --include-archived --page 1 --page-size 50",
73
+ "folders archive": "dreamlake folders archive FOLDER_ID --json",
74
+ "folders unarchive": "dreamlake folders unarchive FOLDER_ID --json",
70
75
  "notes files list": "dreamlake notes files list --note release-plan\ndreamlake notes files list 'assets/*.png' --note release-plan --limit 50\ndreamlake notes files list --note release-plan --json",
71
76
  "notes media upload": "dreamlake notes media upload ./diagram.png\nIMAGE_URL=$(dreamlake notes media upload ./diagram.png)",
72
77
  "notes files write": "dreamlake notes files write config.json --text '{\"enabled\":true}' --note \"$NOTE_ID\" --idempotency-key config-initial-1",
@@ -84,8 +89,8 @@ export const helpExamples = {
84
89
  "notes delete": "dreamlake notes delete 'obsolete paragraph' --note \"$NOTE_ID\" \\\n --base-revision \"$BASE\" --json\n# Pin verification to the receipt's acknowledged revision.\ndreamlake notes read \"$NOTE_ID\" --at \"$ACK\"",
85
90
  "notes write": "dreamlake notes read \"$NOTE_ID\" --json > baseline.json\nBASE=$(jq -er .revision baseline.json)\njq -jr .content baseline.json > draft.md\n# Edit draft.md without changing the saved original baseline.\ndreamlake notes write \"$NOTE_ID\" --file draft.md --base-revision \"$BASE\" --json\n# ACK is the successful write receipt's revision.\ndreamlake notes read \"$NOTE_ID\" --at \"$ACK\"",
86
91
  "notes": "# Find a note and read it directly.\ndreamlake notes search \"release plan\"\ndreamlake notes read release-plan\n\n# Preview a unique wording change, apply it, then read back.\ndreamlake notes replace \"Draft checklist\" --text \"Ready for review\" --note release-plan --dry-run\ndreamlake notes replace \"Draft checklist\" --text \"Ready for review\" --note release-plan\ndreamlake notes read release-plan\n\n# Create a private note from a Markdown file.\ndreamlake notes create \"Release plan\" --file release-plan.md\n\n# Cross-interface design (unreleased target APIs; verify installed --help):\n# https://docs.dreamlake.ai/notes/api/",
87
- "notes list": "dreamlake notes list --limit 10\ndreamlake notes list --shared\ndreamlake notes list --namespace acme",
88
- "notes search": "dreamlake notes search \"release plan\"\ndreamlake notes search deploy --namespace acme --json",
92
+ "notes list": "dreamlake notes list --limit 10\ndreamlake notes list --shared\ndreamlake notes list --namespace acme\ndreamlake notes list --include-archived",
93
+ "notes search": "dreamlake notes search \"release plan\"\ndreamlake notes search deploy --namespace acme --json\ndreamlake notes search deploy --include-archived",
89
94
  "notes create": "dreamlake notes create \"Release plan\" --text \"Draft checklist\"\nprintf '# Release plan\\n' | dreamlake notes create \"Release plan\" --file - --json",
90
95
  "notes read": "dreamlake notes read release-plan\n# Inspect source with generated address hints; do not write the hints back.\ndreamlake notes read release-plan --view markdown\n# Preserve exact source plus revision/hash for a programmatic edit baseline.\ndreamlake notes read release-plan --json > baseline.json\ndreamlake notes read release-plan --since \"10 minutes ago\" --format diff\n# Detailed read design (unreleased target syntax):\n# https://docs.dreamlake.ai/notes/api/reading/\n# Reuse a stable agent identity for this task.\nexport DREAMLAKE_AGENT_ID=release-reviewer-a\nexport DREAMLAKE_AGENT_NAME=\"Release reviewer A\"\ndreamlake notes read release-plan --linger\n# Ctrl-C stops following.\n\nExample notifications:\n+ @alice joined\n+ Reviewer (agent) joined\n* Reviewer (agent) read the note\n* Reviewer (agent) edited the note\n* @alice selected \"## The center\"\n- @alice left",
91
96
  "notes projects": "dreamlake notes projects 000000000000000000000001 --namespace acme",
package/dist/cli/index.js CHANGED
@@ -34,6 +34,7 @@ import { registerPageCommand } from "./page/index.js";
34
34
  import { registerConnectionCommand } from "./connection/index.js";
35
35
  import { registerSourceCommand } from "./source/index.js";
36
36
  import { registerTasksCommand } from "./tasks/index.js";
37
+ import { registerFoldersCommand } from "./folders/index.js";
37
38
  import { registerNotesCommand } from "./notes/index.js";
38
39
  import { registerDeclareCommand } from "./declare/index.js";
39
40
  import { registerHostsCommand } from "./hosts/index.js";
@@ -194,6 +195,7 @@ async function main(argv) {
194
195
  registerPageCommand(program);
195
196
  registerSourceCommand(program);
196
197
  registerNotesCommand(program);
198
+ registerFoldersCommand(program);
197
199
  registerOwnershipCommand(program);
198
200
  registerProjectCommand(program);
199
201
  registerTasksCommand(program);
@@ -37,7 +37,7 @@ export async function runListAssets(opts) {
37
37
  let containerPrefix;
38
38
  try {
39
39
  if (t.episode) {
40
- const episodes = await fetchAllEpisodes(remote, t.namespace, t.project, token);
40
+ const episodes = await fetchAllEpisodes(remote, t.namespace, t.project, token, { includeArchived: true });
41
41
  const ep = episodes.find((e) => e.name === t.episode);
42
42
  if (!ep) {
43
43
  fail(`episode '${t.episode}' not found in ${t.project}@${t.namespace}`);
@@ -0,0 +1,7 @@
1
+ /** Archive is reversible lifecycle metadata, independent of deletion and tags. */
2
+ import type { Command } from 'commander';
3
+ import { type ConnOpts } from './index.js';
4
+ export declare function runNotesArchive(ref: string, archived: boolean, opts: ConnOpts & {
5
+ json?: boolean;
6
+ }): Promise<number>;
7
+ export declare function registerArchiveCommands(notes: Command): void;
@@ -0,0 +1,59 @@
1
+ import { notesApi } from '../../api/notes.js';
2
+ import { requestJson } from '../client.js';
3
+ import { resolveCtx } from '../compat/ctx.js';
4
+ import { requireNamespace, requireToken } from '../compat/http.js';
5
+ import { withConnFlags } from '../compat/flags.js';
6
+ import { emitJson, fail } from '../helpers.js';
7
+ import { noteTransport } from './api-transport.js';
8
+ import { resolveNote, report, seg } from './index.js';
9
+ export async function runNotesArchive(ref, archived, opts) {
10
+ const c = resolveCtx(opts), token = requireToken(c);
11
+ if (!token)
12
+ return 1;
13
+ const asserted = opts.namespace?.trim().replace(/^@/, '') || undefined;
14
+ try {
15
+ let id = ref;
16
+ if (!/^[a-f0-9]{24}$/i.test(ref)) {
17
+ const ns = await requireNamespace(c, asserted);
18
+ if (!ns)
19
+ return 1;
20
+ const found = await resolveNote({ remote: c.remote, token, ns }, ref);
21
+ if (!found)
22
+ return 1;
23
+ id = found;
24
+ }
25
+ const note = await requestJson(c.remote, `/notes/${seg(id)}`, { token });
26
+ if (note.id !== id || !note.namespaceSlug) {
27
+ fail("server did not return the note's owning namespace");
28
+ return 1;
29
+ }
30
+ if (asserted && asserted !== note.namespaceSlug) {
31
+ fail(`note ${id} is in '${note.namespaceSlug}', not --namespace '${asserted}'`);
32
+ return 1;
33
+ }
34
+ if (note.permissions?.rename === false) {
35
+ fail('you do not have permission to archive this note');
36
+ return 1;
37
+ }
38
+ const api = notesApi(noteTransport({ remote: c.remote, token }), note.namespaceSlug);
39
+ const result = await (archived ? api.archive(id) : api.unarchive(id));
40
+ if (opts.json)
41
+ emitJson(result);
42
+ else
43
+ process.stdout.write(`✓ ${archived ? 'archived' : 'unarchived'} note ${id}\n`);
44
+ return 0;
45
+ }
46
+ catch (error) {
47
+ return report(error);
48
+ }
49
+ }
50
+ export function registerArchiveCommands(notes) {
51
+ for (const action of ['archive', 'unarchive']) {
52
+ withConnFlags(notes.command(action).allowExcessArguments(false))
53
+ .description(action === 'archive' ? 'archive a note without deleting it or removing its filings' : 'unarchive a note and restore its folder path')
54
+ .argument('<note>', 'note id, slug or exact title')
55
+ .option('--namespace <slug>', 'whose notes for lookup; with an id, asserts the owner')
56
+ .option('--json', 'emit the updated note metadata')
57
+ .action(async (note, opts) => { process.exitCode = await runNotesArchive(note, action === 'archive', opts); });
58
+ }
59
+ }
@@ -94,6 +94,7 @@ export declare function runNotesSelect(css: string, opts: ConnOpts & {
94
94
  json?: boolean;
95
95
  }): Promise<number>;
96
96
  export declare function runNotesGrep(query: string | undefined, opts: ConnOpts & {
97
+ includeArchived?: boolean;
97
98
  regex?: string;
98
99
  flags?: string;
99
100
  caseSensitive?: boolean;
@@ -545,6 +545,8 @@ export async function runNotesGrep(query, opts) {
545
545
  const base = new URLSearchParams();
546
546
  if (query !== undefined)
547
547
  base.set("q", query);
548
+ if (opts.includeArchived)
549
+ base.set("includeArchived", "true");
548
550
  if (opts.regex !== undefined)
549
551
  base.set("regex", opts.regex);
550
552
  if (opts.flags)
@@ -44,10 +44,12 @@ export declare function registerNotesCommand(program: Command): void;
44
44
  export declare function runNotesList(opts: ConnOpts & {
45
45
  limit?: string;
46
46
  shared?: boolean;
47
+ includeArchived?: boolean;
47
48
  json?: boolean;
48
49
  }): Promise<number>;
49
50
  export declare function runNotesSearch(query: string, opts: ConnOpts & {
50
51
  limit?: string;
52
+ includeArchived?: boolean;
51
53
  json?: boolean;
52
54
  }): Promise<number>;
53
55
  export declare function runNotesSections(ref: string, opts: ConnOpts & {
@@ -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 { registerArchiveCommands } from "./archive-command.js";
7
8
  import { registerRmCommand } from "./rm-command.js";
8
9
  import { registerSuggestDiffCommand } from "./suggest-diff.js";
9
10
  import { registerShareCommands } from "../share.js";
@@ -108,14 +109,19 @@ export function report(err) {
108
109
  export async function resolveNote(c, ref) {
109
110
  if (/^[a-f0-9]{24}$/i.test(ref))
110
111
  return ref;
111
- const res = await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=200`, { token: c.token });
112
- const hit = res.notes.find((n) => n.slug === ref || n.id === ref || n.name === ref);
113
- if (!hit) {
114
- fail(`no note '${ref}' in namespace '${c.ns}' — 'dreamlake notes list' shows what is there, ` +
115
- `and an organization's notes need --namespace <slug>`);
116
- return null;
117
- }
118
- return hit.id;
112
+ let offset = 0;
113
+ for (;;) {
114
+ const res = await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=200&includeArchived=true&offset=${offset}`, { token: c.token });
115
+ const hit = res.notes.find((n) => n.slug === ref || n.id === ref || n.name === ref);
116
+ if (hit)
117
+ return hit.id;
118
+ offset += res.notes.length;
119
+ if (!res.notes.length || (res.total === undefined ? res.notes.length < 200 : offset >= res.total))
120
+ break;
121
+ }
122
+ fail(`no note '${ref}' in namespace '${c.ns}' — 'dreamlake notes list --include-archived' shows what is there, ` +
123
+ `and an organization's notes need --namespace <slug>`);
124
+ return null;
119
125
  }
120
126
  /** Body text from --file, --text, or stdin. Exactly one, so an empty write is
121
127
  * always deliberate rather than the result of a forgotten flag. */
@@ -193,6 +199,7 @@ export function registerNotesCommand(program) {
193
199
  registerMoveCommand(notes);
194
200
  registerTransferCommand(notes);
195
201
  registerRmCommand(notes);
202
+ registerArchiveCommands(notes);
196
203
  registerSuggestDiffCommand(notes);
197
204
  // Same connection flags as the other ported groups, so --debug/--remote
198
205
  // behave identically across the CLI.
@@ -229,6 +236,7 @@ export function registerNotesCommand(program) {
229
236
  // ── notes list ──
230
237
  strict(collectionList(notes, "list"))
231
238
  .description("list notes in one namespace")
239
+ .option("--include-archived", "include archived notes")
232
240
  .option("--limit <n>", "page size", "50")
233
241
  .option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
234
242
  .option("--shared", "list notes other people shared with you, across namespaces")
@@ -238,6 +246,7 @@ export function registerNotesCommand(program) {
238
246
  strict(notes.command("search"))
239
247
  .argument("<query>", "matched against note titles and bodies, case-insensitively")
240
248
  .description("find notes by title or body text")
249
+ .option("--include-archived", "include archived notes")
241
250
  .option("--limit <n>", "page size", "50")
242
251
  .option("--namespace <slug>", "whose notes (default: your personal namespace, not an org's)")
243
252
  .option("--json", "emit JSON")
@@ -246,6 +255,7 @@ export function registerNotesCommand(program) {
246
255
  strict(notes.command("grep"))
247
256
  .argument("[query]", "literal text; punctuation matches itself")
248
257
  .description("search every note you can see and print where each hit is")
258
+ .option("--include-archived", "include archived notes")
249
259
  .option("--regex <pattern>", "search by pattern instead of literal text")
250
260
  .option("--flags <flags>", "regex flags: any of i, m, s, u")
251
261
  .option("--case-sensitive", "match case (the default for --regex)")
@@ -604,8 +614,8 @@ export async function runNotesList(opts) {
604
614
  return 1;
605
615
  try {
606
616
  const rows = opts.shared
607
- ? (await requestJson(c.remote, "/me/notes/shared", { token: c.token })).notes
608
- : (await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=${encodeURIComponent(opts.limit ?? "50")}`, { token: c.token })).notes;
617
+ ? (await requestJson(c.remote, "/me/notes/shared", { token: c.token, query: { includeArchived: opts.includeArchived } })).notes
618
+ : (await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?limit=${encodeURIComponent(opts.limit ?? "50")}${opts.includeArchived ? "&includeArchived=true" : ""}`, { token: c.token })).notes;
609
619
  if (opts.json)
610
620
  return emitJson({ notes: rows }), 0;
611
621
  if (rows.length === 0) {
@@ -642,7 +652,7 @@ export async function runNotesSearch(query, opts) {
642
652
  if (!c)
643
653
  return 1;
644
654
  try {
645
- const res = await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?q=${seg(query)}&limit=${encodeURIComponent(opts.limit ?? "50")}`, { token: c.token });
655
+ const res = await requestJson(c.remote, `/namespaces/${seg(c.ns)}/notes?q=${seg(query)}&limit=${encodeURIComponent(opts.limit ?? "50")}${opts.includeArchived ? "&includeArchived=true" : ""}`, { token: c.token });
646
656
  if (opts.json)
647
657
  return emitJson(res), 0;
648
658
  if (res.notes.length === 0) {
@@ -21,7 +21,9 @@ export interface BindrRec {
21
21
  name: string;
22
22
  }
23
23
  /** Fetch all episodes in a project (throws on error). */
24
- export declare function fetchAllEpisodes(remote: string, namespace: string, project: string, token: string): Promise<EpisodeRec[]>;
24
+ export declare function fetchAllEpisodes(remote: string, namespace: string, project: string, token: string, options?: {
25
+ includeArchived?: boolean;
26
+ }): Promise<EpisodeRec[]>;
25
27
  /** Fetch all bindrs in a project (throws on error). */
26
28
  export declare function fetchAllBindrs(remote: string, namespace: string, project: string, token: string): Promise<BindrRec[]>;
27
29
  /** Match episodes by glob against their name OR node path (leading "/" stripped). */
@@ -69,4 +71,6 @@ export declare function lookupNode(remote: string, token: string, q: {
69
71
  * (paginated; ?kind= filters). NOTE: /nodes/:id/descendants exists but its
70
72
  * response schema strips the node list on the deployed server — use this.
71
73
  */
72
- export declare function fetchAllContents(remote: string, token: string, nodeId: string, kind?: string): Promise<NodeRec[]>;
74
+ export declare function fetchAllContents(remote: string, token: string, nodeId: string, kind?: string, options?: {
75
+ includeArchived?: boolean;
76
+ }): Promise<NodeRec[]>;
@@ -63,8 +63,8 @@ async function fetchEveryPage(remote, path, token, key) {
63
63
  return { items, total };
64
64
  }
65
65
  /** Fetch all episodes in a project (throws on error). */
66
- export async function fetchAllEpisodes(remote, namespace, project, token) {
67
- const r = await fetchAllPages(remote, `/namespaces/${namespace}/projects/${project}/episodes`, token, "episodes");
66
+ export async function fetchAllEpisodes(remote, namespace, project, token, options = {}) {
67
+ const r = await fetchAllPages(remote, `/namespaces/${namespace}/projects/${project}/episodes${options.includeArchived ? "?includeArchived=true" : ""}`, token, "episodes");
68
68
  return r === "not-found" ? [] : r.items;
69
69
  }
70
70
  /** Fetch all bindrs in a project (throws on error). */
@@ -118,13 +118,13 @@ export async function lookupNode(remote, token, q) {
118
118
  * (paginated; ?kind= filters). NOTE: /nodes/:id/descendants exists but its
119
119
  * response schema strips the node list on the deployed server — use this.
120
120
  */
121
- export async function fetchAllContents(remote, token, nodeId, kind) {
121
+ export async function fetchAllContents(remote, token, nodeId, kind, options = {}) {
122
122
  const files = [];
123
123
  let page = 1;
124
124
  for (;;) {
125
125
  const data = await requestJson(remote, `/nodes/${nodeId}/contents`, {
126
126
  token,
127
- query: { page, pageSize: 500, kind: kind ?? undefined },
127
+ query: { page, pageSize: 500, kind: kind ?? undefined, ...options, includeArchived: options.includeArchived ?? false },
128
128
  });
129
129
  const batch = data.files ?? [];
130
130
  files.push(...batch);
@@ -76,7 +76,7 @@ export async function runUpdateBindr(name, opts) {
76
76
  return 1;
77
77
  }
78
78
  }
79
- const episodes = opts.add || opts.remove ? await fetchAllEpisodes(remote, s.namespace, s.project, token) : [];
79
+ const episodes = opts.add || opts.remove ? await fetchAllEpisodes(remote, s.namespace, s.project, token, { includeArchived: true }) : [];
80
80
  try {
81
81
  if (opts.add) {
82
82
  const toAdd = matchEpisodes(episodes, opts.add);
@@ -1 +1 @@
1
- export declare const VERSION = "0.96.0";
1
+ export declare const VERSION = "0.97.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.96.0";
9
+ export const VERSION = "0.97.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamlake/dreamlake-cli",
3
- "version": "0.96.0",
3
+ "version": "0.97.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
@@ -35,13 +35,13 @@
35
35
  "node": ">=18"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@dreamlake/dreamlake-cli-darwin-arm64": "0.96.0",
39
- "@dreamlake/dreamlake-cli-darwin-x64": "0.96.0",
40
- "@dreamlake/dreamlake-cli-linux-x64": "0.96.0",
41
- "@dreamlake/dreamlake-cli-linux-arm64": "0.96.0",
42
- "@dreamlake/dreamlake-cli-linux-x64-musl": "0.96.0",
43
- "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.96.0",
44
- "@dreamlake/dreamlake-cli-win32-x64": "0.96.0",
45
- "@dreamlake/dreamlake-cli-win32-arm64": "0.96.0"
38
+ "@dreamlake/dreamlake-cli-darwin-arm64": "0.97.1",
39
+ "@dreamlake/dreamlake-cli-darwin-x64": "0.97.1",
40
+ "@dreamlake/dreamlake-cli-linux-x64": "0.97.1",
41
+ "@dreamlake/dreamlake-cli-linux-arm64": "0.97.1",
42
+ "@dreamlake/dreamlake-cli-linux-x64-musl": "0.97.1",
43
+ "@dreamlake/dreamlake-cli-linux-arm64-musl": "0.97.1",
44
+ "@dreamlake/dreamlake-cli-win32-x64": "0.97.1",
45
+ "@dreamlake/dreamlake-cli-win32-arm64": "0.97.1"
46
46
  }
47
47
  }