Skip to content

refactor(documents): use cli-core's shared documents commands - #374

Draft
leemour wants to merge 2 commits into
mainfrom
refactor/shared-documents-commands
Draft

leemour wants to merge 2 commits into
mainfrom
refactor/shared-documents-commands

Conversation

@leemour

@leemour leemour commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Task

Move drive onto cli-core's shared documents commands (WireCatLabs/cli-core#2966), with no change to its commands, options, --json fields or error reasons.

Draft until WireCatLabs/cli-core#2966 is released. This branch pins cli-core 0.662.0 (main's pin), which does not have @wirecat/cli-core/documents/cli yet, so CI stays red until then. The next step is to bump the pin to the release that carries WireCatLabs/cli-core#2966 and push once.

Why

notion-cli needs the same documents commands as drive. With them in cli-core, both CLIs answer the same way, and a fix lands once.

What

  • folders, sync, status, documents list|show|export|context, search, catalog, tags, relationships, notes, memories, facts, identities and mirrors now come from cli-core. src/commands/*.ts only bind drive's ports and words (DRIVE_WORDS in src/commands/context.ts).
  • Removed, because cli-core has them now: src/knowledge-query.ts, the tree code in src/catalog.ts, the moved rows in src/list-queries.ts, ageOf/staleCopy in src/age.ts, the notes and search shell overrides, and the catalog, mirror and export.exists reasons.
  • Kept in drive, on purpose:
    • the profile lock (proper-lockfile), the policy with --read-only, and its own MCP server. These go against the handbook, so they were not moved into the shared code.
    • documents add across several profiles, folders browse (entity drive_remote_folder), the status coverage text, the mirror config and the Google targets, and the Google owners behind identities. These are Drive-only.

Changed for callers (fragment changes/refactor-shared-documents-commands.md, under "Changed — may break callers"):

  • The entity names that commands --json declares: drive_document → document (view imported), drive_catalog → catalog, drive_document_tag → document_tag, drive_document_relationship → document_relationship, drive_document_identity → document_identity, drive_selected_folder → selected_folder, drive_mirror → mirror.
  • identities list answers remote_id and provider (google-drive) instead of google_id, and takes remote_id:<id>.
  • catalog tree reads only the folder it shows. Over 10 000 entries it still fails with catalog.tree-limit, and the message says to name a smaller folder or lower --depth. An entry in two folders is shown in full once and marked repeated: true elsewhere.
  • The catalog, mirror, export.exists and listing.too-large reasons are cli-core's, and their messages name no provider.
  • commands info --json loses the notes and search override entries: those are shared commands now.
  • documents list parses its query before it loads the profile. The reason changes only when both are wrong.

Testing

On a local pack of WireCatLabs/cli-core#2966:

  • commands --json diff against drive@main: only the entity and view names and the identity fields above change. Every description, option, argument, effect and example is identical.
  • pnpm generate: contracts/wirecat.json and docs/commands.md change only by the entity names, plus one "Next usually" line. contracts/own-catalogue.json loses the 42 paths that cli-core now owns.
  • contracts:check (help.snap), test:matrix (0 missing), lint, lint:commands and docs:check pass.
  • Family cli-dev audit (scripts/audit.sh): drive's rows and the list of 24 blocking findings are identical to the baseline before this change.

🤖 Generated with Claude Code

folders, sync, status, documents list|show|export|context, search, catalog,
tags, relationships, notes, memories, facts, identities and mirrors now come
from @wirecat/cli-core/documents/cli. drive passes its ports, its words
(Google, Google Drive, the remote word "google") and its own wording where it
differs, and keeps its own parts: the profile lock, the policy and
--read-only, its MCP server, documents add across profiles, folders browse,
the status coverage text, the mirror config and Google targets, and the
Google owners behind identities.

Commands, options, arguments, effects, examples and --json fields are
unchanged. The entity names that commands --json declares become the shared
ones (drive_document -> document, view imported; drive_catalog -> catalog;
drive_document_tag -> document_tag, and so on). catalog tree has no total cap,
so catalog.tree-limit is gone. The catalog, mirror and export.exists reasons
are cli-core's now.

Needs the cli-core release with the shared documents commands; the pin moves
when it is out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared document_identity has one schema in every documents CLI, so
identities list answers remote_id and provider (google-drive) where it
answered google_id, and takes remote_id:<id>. The mirrors sync text keeps
drive's wording through words.text, and listing.too-large is cli-core's
reason now. The changelog fragment lists what callers see change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant