-
-
Notifications
You must be signed in to change notification settings - Fork 9
[FEAT] Add documents CLI commands #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] Add documents CLI commands #21
Conversation
|
Thanks for the PR, @ralfschimmel! I seem to be unable to get it to work, though. I have a Linear issue (ZCO-1569) which contains a PNG and a GIF (both embeds), and a MD document (as attachment). All three are listed when I read the issue: > tsx src/main.ts issues read ZCO-1569
{
"id": "de732438-8ae2-4f9e-95a9-85a614b04816",
"identifier": "ZCO-1569",
"title": "File embed testing grounds",
"description": "…",
"embeds": [
{
"label": "Confident Man and Futuristic Car.png",
"url": "https://uploads.linear.app/7df2165d-5920-4338-950f-…/571bf0bf-3586-4f92-9427-…/1234a028-2053-452c-8da4-…?signature=…",
"expiresAt": "2025-12-06T14:11:23.278Z"
},
{
"label": "i-swear-to-god-connor.gif",
"url": "https://uploads.linear.app/7df2165d-5920-4338-950f-…/571bf0bf-3586-4f92-9427-…/00d4a028-2053-452c-8da4-…?signature=…",
"expiresAt": "2025-12-06T14:11:23.278Z"
},
{
"label": "swift6-migration-compact.md",
"url": "https://uploads.linear.app/7df2165d-5920-4338-950f-…/316bcc3a-baa7-4b01-a6dc-…/591f244c-5ca9-4777-bcef-…?signature=…",
"expiresAt": "2025-12-06T14:11:23.278Z"
}
],
…I think |
Add comprehensive document management for Linear: - documents create: Create new documents with optional project/team association - documents read: Read document content by ID - documents list: List documents, filterable by project or issue - documents update: Update document title, content, project, icon, color - documents delete: Soft delete (trash) documents The --issue filter on `documents list` uses the attachments API internally to find Linear Documents that are attached to a specific issue. The --attach-to option on `documents create` allows linking a new document to an issue via an attachment. Note: Attachments service is kept internal (no CLI commands) - it's used as plumbing for the documents-to-issues linking feature. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9ac1a7f to
9aa04f0
Compare
Response to FeedbackThanks for testing! You're right that Linear's File ConceptsLinear has two different ways files can be associated with issues:
Your PNG, GIF, and MD files were uploaded into the description, so they're embeds, not attachments. Updated PRI've removed the
This way, the PR focuses on Documents (first-class Linear entities) without exposing the confusing attachments/embeds distinction to users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, now I understand: we're talking about the (mainly) project-level documents, not issue-level files and embeds. 👍🏼
Second review: Good stuff, we're almost there! Clean architecture, good test coverage, good API design, solid error handling, and documentation. I see some issues, though.
🔴 Critical: Unrelated breaking change
src/queries/common.ts removes branchName from ISSUE_CORE_FIELDS, but:
src/utils/graphql-issues-service.ts:824still referencesissue.branchNamesrc/utils/linear-types.d.ts:6still defines the field
This silently breaks branch name retrieval for issues. I guess it's accidental, so please revert it.
🟡 Error message references non-existent command
src/commands/documents.ts:171 suggests:
To retry attachment: linearis attachments create --issue ...
But the PR description says attachments CLI commands were removed. People following this advice will get a "command not found" error.
🟡 Missing unit tests for URL parsing
extractDocumentIdFromUrl() (src/commands/documents.ts:53-80) handles multiple edge cases but has no unit tests. Given it's parsing URLs with assumptions about Linear's format, this deffo deserves coverage.
Minor/Optional
LIST_DOCUMENTS_BY_IDS_QUERYis identical toLIST_DOCUMENTS_QUERY- unless there are good arguments against it, should be consolidated
Summary
As I've said, good stuff, with some minor and easily fixable issues. Please make those changes, and I'll merge it! 🤙🏼
- Restore accidentally removed `branchName` field in ISSUE_CORE_FIELDS - Remove misleading retry suggestion from attachment error message - Export `extractDocumentIdFromUrl()` and add comprehensive unit tests (19 tests) - Consolidate duplicate queries (remove LIST_DOCUMENTS_BY_IDS_QUERY) - Improve type safety: change `_options: any` to `_options: unknown` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Review Feedback AddressedThanks for the thorough review! All requested changes have been implemented: 🔴 Critical:
|
|
Thanks, @ralfschimmel! |
Summary
Add comprehensive document management for Linear:
documents create: Create new documents with optional project/team associationdocuments read: Read document content by IDdocuments list: List documents, filterable by project or issuedocuments update: Update document title, content, project, icon, colordocuments delete: Soft delete (trash) documentsKey Features
Issue Integration
--issuefilter ondocuments listshows documents attached to an issue--attach-tooption ondocuments createlinks a new document to an issueThese features use Linear's Attachments API internally to link documents to issues.
Design Decision
The attachments CLI commands have been removed from this PR. The attachments service is kept as internal plumbing for documents-to-issues linking only.
Linear has a confusing distinction between:
Since the primary use case is Documents (for workflow systems), keeping attachments as internal-only avoids user confusion.
Test plan
documents create --title "Test"creates a documentdocuments listreturns documentsdocuments list --issue ABC-123returns documents attached to issuedocuments read <id>returns document content🤖 Generated with Claude Code