From 679d21be998e49313dcbadc76a985304b8c3a1dc Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 18 Nov 2026 00:41:49 +0100 Subject: [PATCH] feat(documents): folders list names each chosen folder folders list answered only the id, so a folder chosen in Yandex Disk showed its raw resource_id until a sync named it. documentLibraryCommands already keeps the folder as folders add read it; the row now carries its name, and its path when the CLI gives folderPath. Co-Authored-By: Claude Opus 5.5 --- changes/feat-folders-list-name.md | 5 +++++ src/cli/documents/folders.ts | 2 +- src/cli/documents/library.test.ts | 5 ++++- src/cli/documents/library.ts | 8 +++++++- src/cli/documents/queries.ts | 8 +++++++- 5 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 changes/feat-folders-list-name.md diff --git a/changes/feat-folders-list-name.md b/changes/feat-folders-list-name.md new file mode 100644 index 000000000..f43ed75dc --- /dev/null +++ b/changes/feat-folders-list-name.md @@ -0,0 +1,5 @@ +### Added + +- **`folders list` of a documents CLI names each chosen folder.** A row has `name`, the folder's name when `folders add` + kept it, and `path` when the CLI gives `folderPath` to `documentLibraryCommands`. A folder shown only by its id + (ydisk's `resource_id`) now has words. A CLI that lists its own folders still answers `{ id }`. diff --git a/src/cli/documents/folders.ts b/src/cli/documents/folders.ts index 2a871bb20..6b97297bb 100644 --- a/src/cli/documents/folders.ts +++ b/src/cli/documents/folders.ts @@ -12,7 +12,7 @@ export interface DocumentFolderCommands { /** Checks the folder with the provider and keeps it in the selected profile; refuses one that is not a folder. */ add(input: string): Promise<{ id: string; name: string }> /** The selected profile's chosen folders, narrowed by `id:`. */ - list(filter: Record): { id: string }[] + list(filter: Record): { id: string; name?: string; path?: string }[] /** Forgets the folder; answers its id. */ remove(input: string): string /** Adds the CLI's own `folders browse`, which help then lists between `list` and `remove`. */ diff --git a/src/cli/documents/library.test.ts b/src/cli/documents/library.test.ts index 30c16e130..2c0c54781 100644 --- a/src/cli/documents/library.test.ts +++ b/src/cli/documents/library.test.ts @@ -56,6 +56,7 @@ const definition = (source: FeedlessDocumentSource, words: DocumentWords = WORDS ? (source as unknown as { byPath(path: string): Promise }).byPath(input) : source.metadata(input), isFolder, + folderPath: (file) => `/${file.name}`, row: (file, reference) => ({ id: file.id, name: file.name, url: file.url, reference }), textLimit: 100_000, maxEntries: 1_000, @@ -104,7 +105,9 @@ describe("documentLibraryCommands over a source without a change feed", () => { expect(JSON.parse((await cli(["folders", "add", "root"])).stdout)).toMatchObject({ item: { id: "root", added: true }, }) - expect(JSON.parse((await cli(["folders", "list"])).stdout).items).toEqual([{ id: "root" }]) + expect(JSON.parse((await cli(["folders", "list"])).stdout).items).toEqual([ + { id: "root", name: "root", path: "/root" }, + ]) expect(JSON.parse((await cli(["sync"])).stdout).item).toMatchObject({ saved: 2, removed: 0 }) source.put({ ...source.files.get("a"), version: "2" } as SourceFile, "a new budget line") source.remove("b") diff --git a/src/cli/documents/library.ts b/src/cli/documents/library.ts index cfe92aae3..41183eee3 100644 --- a/src/cli/documents/library.ts +++ b/src/cli/documents/library.ts @@ -100,6 +100,8 @@ export interface DocumentLibraryOptions { coverage: string /** The accounts a document names, for `identities list`; none when the provider shows none. */ people?: DocumentKnowledgePort["people"] + /** Where a chosen folder is at the provider, for `folders list`: a Disk path. Unset: the answer has no path. */ + folderPath?(folder: M): string | undefined /** The CLI's own `folders browse`. */ browse?(folders: Command, tools: DocumentLibraryTools): void } @@ -425,7 +427,11 @@ export const documentLibraryCommands = (options: DocumentL list: (filter) => roots() .filter((id) => filter.id === undefined || filter.id === id) - .map((id) => ({ id })), + .map((id) => { + const file = files().folders().files?.[id] + const path = file ? options.folderPath?.(file) : undefined + return { id, ...(file ? { name: file.name } : {}), ...(path ? { path } : {}) } + }), remove: (input) => { const id = options.idOf(input) const chosen = files().folders() diff --git a/src/cli/documents/queries.ts b/src/cli/documents/queries.ts index 1e27ab02a..a69473b4d 100644 --- a/src/cli/documents/queries.ts +++ b/src/cli/documents/queries.ts @@ -35,7 +35,13 @@ const registry = ( ), }) -export const folderRow = v.strictObject({ id: v.string() }) +export const folderRow = v.strictObject({ + id: v.string(), + /** The folder as `folders add` named it; left out for a folder chosen before its name was kept. */ + name: v.optional(v.string()), + /** Where the provider says it is, when the CLI gives a `folderPath`: a Disk path. */ + path: v.optional(v.string()), +}) export const mirrorRow = v.strictObject({ id: v.string(), path: v.string(), folder: v.string() }) export const tagRow = v.strictObject({ tag: v.string() }) export const linkRow = v.looseObject({