@cvr/linear 0.4.0 → 0.5.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.
package/README.md CHANGED
@@ -71,6 +71,13 @@ linear team list
71
71
  | `linear issue start [id]` | Start work, with `--dry-run` and `--json` support |
72
72
  | `linear issue create` | Create a new issue |
73
73
  | `linear issue comment ID` | Add a comment, with `--dry-run` support |
74
+ | `linear issue files ID` | List uploads; `--download` saves them |
75
+
76
+ ### Files
77
+
78
+ | Command | Description |
79
+ | --------------------------- | --------------------------------------------------- |
80
+ | `linear file download URL…` | Download `uploads.linear.app` files with your token |
74
81
 
75
82
  ### Teams
76
83
 
@@ -96,6 +103,7 @@ linear team list
96
103
  - Keep `--query-file` paths inside the current workspace; traversal and escaping symlinks are rejected.
97
104
  - Raw GraphQL mutations require the explicit `--allow-mutation` flag.
98
105
  - Never read or interpolate the token directly; the CLI owns authentication.
106
+ - Download attachments with `linear issue files ID --download` or `linear file download URL`. The token is sent only to `uploads.linear.app`, never to a redirect target. Existing files are kept unless `--overwrite` is passed.
99
107
 
100
108
  ## Configuration
101
109
 
@@ -137,7 +145,7 @@ Built with:
137
145
 
138
146
  - **[Bun](https://bun.sh)**: Fast JavaScript runtime with native compilation
139
147
  - **[Effect](https://effect.website)**: TypeScript library for type-safe, composable code
140
- - **[Effect CLI](https://github.com/Effect-TS/effect/tree/main/packages/effect/src/unstable/cli)**: CLI framework with prompts and argument parsing
148
+ - **[Effect CLI](https://github.com/Effect-TS/effect/tree/main/packages/effect/src/cli)**: CLI framework with prompts and argument parsing
141
149
  - **[@linear/sdk](https://github.com/linear/linear)**: Official Linear GraphQL SDK
142
150
 
143
151
  ## Credits
package/bin/linear CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/linear
3
- size: 98228352 bytes
4
- sha256: f1e0db0ec0ecc437d77704cf19ee45021a33245d72bf735b654d3ffbb21e7bc7
3
+ size: 83912160 bytes
4
+ sha256: 128240f654731526d32f5ed7b9e5d23650f7dfe5308684ec93e5cebb16b9757f
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cvr/linear",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cevr/linear-cli.git"
@@ -27,31 +27,31 @@
27
27
  "lint:fix": "oxlint --fix",
28
28
  "fmt": "oxfmt",
29
29
  "fmt:check": "oxfmt --check",
30
- "typecheck": "tsgo --noEmit",
30
+ "typecheck": "tsc --noEmit",
31
31
  "gate": "concurrently -n type,style,build,test -c blue,yellow,cyan,green \"bun run typecheck\" \"bun run lint && bun run fmt:check\" \"bun run build\" \"bun run test\"",
32
32
  "prepare": "lefthook install && effect-tsgo patch",
33
33
  "version": "changeset version",
34
34
  "release": "changeset publish"
35
35
  },
36
36
  "dependencies": {
37
- "@effect/platform-bun": "4.0.0-beta.98",
37
+ "@effect/platform-bun": "4.0.0",
38
38
  "@linear/sdk": "^88.2.0",
39
- "effect": "4.0.0-beta.98",
39
+ "effect": "4.0.0",
40
40
  "graphql": "^17.0.2",
41
41
  "toml": "^5.0.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@changesets/changelog-github": "^0.7.0",
45
- "@changesets/cli": "^2.31.1",
46
- "@effect/tsgo": "^0.23.0",
47
- "@effect/vitest": "4.0.0-beta.98",
44
+ "@changesets/changelog-github": "^1.0.1",
45
+ "@changesets/cli": "^3.0.3",
46
+ "@effect/tsgo": "^0.47.2",
47
+ "@effect/vitest": "4.0.0",
48
48
  "@types/bun": "^1.3.14",
49
49
  "@typescript/native-preview": "7.0.0-dev.20260707.2",
50
50
  "concurrently": "^10.0.3",
51
51
  "lefthook": "^2.1.10",
52
52
  "oxfmt": "^0.59.0",
53
53
  "oxlint": "^1.74.0",
54
- "oxlint-plugin-effect": "latest",
54
+ "oxlint-plugin-effect": "^0.5.0",
55
55
  "typescript": "^7.0.2",
56
56
  "vitest": "^4.1.10"
57
57
  },
@@ -54,6 +54,18 @@ linear issue view BITE-123 --children --comments --relations --json
54
54
 
55
55
  Use the returned `branchName`; do not invent a branch name from the title.
56
56
 
57
+ ### Download attachments
58
+
59
+ Files attached to an issue are Markdown links to `https://uploads.linear.app/...`, which need the Linear credential. Never fetch them with `curl`; use the CLI:
60
+
61
+ ```bash
62
+ linear issue files BITE-123 --json
63
+ linear issue files BITE-123 --download --output-dir ./files --json
64
+ linear file download https://uploads.linear.app/... --output-dir ./files --json
65
+ ```
66
+
67
+ `issue files` scans the description and every comment and returns `name`, `url`, and `source` (`description` or the comment ID). With `--download`, each file is saved under its Markdown name, and the output lists `path`, `bytes`, and `contentType`. The CLI accepts only `uploads.linear.app` URLs, and it does not send the token to a redirect target. An existing file stops the run unless you pass `--overwrite`.
68
+
57
69
  ## Mutations
58
70
 
59
71
  ### Start work
package/src/cli.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { Command } from "effect/unstable/cli";
1
+ import { Command } from "effect/cli";
2
2
  import packageJson from "../package.json" with { type: "json" };
3
3
  import { api } from "./commands/api.js";
4
4
  import { auth } from "./commands/auth.js";
5
+ import { file } from "./commands/file.js";
5
6
  import { issue } from "./commands/issue.js";
6
7
  import { project } from "./commands/project.js";
7
8
  import { team } from "./commands/team.js";
8
9
 
9
10
  export const linear = Command.make("linear").pipe(
10
11
  Command.withDescription("Manage Linear issues, teams, projects, and authentication"),
11
- Command.withSubcommands([auth, team, project, issue, api]),
12
+ Command.withSubcommands([auth, team, project, issue, file, api]),
12
13
  );
13
14
 
14
15
  export const runCli = Command.runWith(linear, { version: packageJson.version });
@@ -1,27 +1,28 @@
1
1
  import { Console, Effect, FileSystem, Option, Path, Schema } from "effect";
2
- import { Command, Flag } from "effect/unstable/cli";
2
+ import { Command, Flag } from "effect/cli";
3
3
  import { Kind } from "graphql/language/kinds.js";
4
4
  import { parse } from "graphql/language/parser.js";
5
5
  import { InvalidInputError } from "../lib/errors.js";
6
6
  import { encodeJson } from "../lib/json.js";
7
7
  import { LinearService } from "../services/Linear.js";
8
8
 
9
- const queryOption = Flag.string("query").pipe(
9
+ const queryOption = Flag.String("query").pipe(
10
10
  Flag.withDescription("GraphQL document"),
11
11
  Flag.optional,
12
12
  );
13
13
 
14
- const queryFileOption = Flag.string("query-file").pipe(
14
+ const queryFileOption = Flag.String("query-file").pipe(
15
15
  Flag.withDescription("Read the GraphQL document from a file"),
16
16
  Flag.optional,
17
17
  );
18
18
 
19
- const variablesOption = Flag.string("variables").pipe(
19
+ const variablesOption = Flag.String("variables").pipe(
20
20
  Flag.withDescription("GraphQL variables as a JSON object"),
21
21
  Flag.withDefault("{}"),
22
22
  );
23
23
 
24
- const allowMutationOption = Flag.boolean("allow-mutation").pipe(
24
+ const allowMutationOption = Flag.Boolean("allow-mutation").pipe(
25
+ Flag.withDefault(false),
25
26
  Flag.withDescription("Explicitly authorize a raw GraphQL mutation"),
26
27
  );
27
28
 
@@ -87,13 +88,14 @@ export const graphqlCommand = Command.make(
87
88
  InvalidInputError.make({ message: "--query or --query-file is required" }),
88
89
  onSome: (path) =>
89
90
  readWorkspaceQueryFile(path).pipe(
90
- Effect.mapError((error) =>
91
- error._tag === "InvalidInputError"
92
- ? error
93
- : InvalidInputError.make({
94
- message: `Could not read GraphQL query file ${path}: ${error}`,
95
- }),
96
- ),
91
+ Effect.mapError((error) => {
92
+ if (error._tag === "InvalidInputError") {
93
+ return error;
94
+ }
95
+ return InvalidInputError.make({
96
+ message: `Could not read GraphQL query file ${path}: ${error}`,
97
+ });
98
+ }),
97
99
  ),
98
100
  }),
99
101
  });
@@ -1,5 +1,5 @@
1
- import { Command, Prompt } from "effect/unstable/cli";
2
- import { ChildProcess } from "effect/unstable/process";
1
+ import { Command, Prompt } from "effect/cli";
2
+ import { ChildProcess } from "effect/process";
3
3
  import { Console, Effect } from "effect";
4
4
  import { jsonFlag } from "../lib/flags.js";
5
5
  import { encodeJson } from "../lib/json.js";
@@ -21,13 +21,13 @@ export const authCommand = Command.make("auth", {}, () =>
21
21
  return (yield* process.exitCode) === 0;
22
22
  }).pipe(
23
23
  Effect.scoped,
24
- Effect.catch(() => Effect.succeed(false)),
24
+ Effect.orElseSucceed(() => false),
25
25
  );
26
26
  if (!browserOpened) {
27
27
  yield* Console.log(`Could not open browser. Please visit the URL manually.`);
28
28
  }
29
29
 
30
- const token = yield* Prompt.hidden({ message: "Paste your API key" });
30
+ const token = yield* Prompt.Hidden({ message: "Paste your API key" });
31
31
 
32
32
  // Validate token by making an API call
33
33
  yield* Console.log("\nValidating token...");
@@ -66,7 +66,7 @@ export const whoamiCommand = Command.make("whoami", { json: jsonFlag }, ({ json
66
66
  yield* Console.log(`\nLogged in as:`);
67
67
  yield* Console.log(` Name: ${viewer.name}`);
68
68
  yield* Console.log(` Email: ${viewer.email}`);
69
- yield* Console.log(` Admin: ${viewer.admin ? "Yes" : "No"}`);
69
+ yield* Console.log(` Admin: ${formatYesNo(viewer.admin)}`);
70
70
  if (viewer.status?.label !== undefined) {
71
71
  yield* Console.log(` Status: ${viewer.status.emoji ?? ""} ${viewer.status.label}`);
72
72
  }
@@ -81,3 +81,10 @@ export const whoamiCommand = Command.make("whoami", { json: jsonFlag }, ({ json
81
81
 
82
82
  // Combined auth command with subcommands
83
83
  export const auth = authCommand.pipe(Command.withSubcommands([whoamiCommand]));
84
+
85
+ function formatYesNo(value: boolean): string {
86
+ if (value) {
87
+ return "Yes";
88
+ }
89
+ return "No";
90
+ }
@@ -0,0 +1,61 @@
1
+ import { Argument, Command } from "effect/cli";
2
+ import { Console, Effect } from "effect";
3
+ import type { SavedFile } from "../domain/Linear.js";
4
+ import { parseUploadUrl } from "../domain/Input.js";
5
+ import { saveDownloads } from "../lib/downloads.js";
6
+ import { InvalidInputError } from "../lib/errors.js";
7
+ import { jsonFlag, outputDirFlag, overwriteFlag } from "../lib/flags.js";
8
+ import { encodeJson } from "../lib/json.js";
9
+
10
+ const uploadUrlsArg = Argument.String("url").pipe(
11
+ Argument.withDescription("https://uploads.linear.app/... URL (repeat for several files)"),
12
+ Argument.variadic(),
13
+ );
14
+
15
+ export const logSavedFiles = (savedFiles: ReadonlyArray<SavedFile>, json: boolean) =>
16
+ Effect.gen(function* () {
17
+ if (json) {
18
+ yield* Console.log(encodeJson(savedFiles));
19
+ return;
20
+ }
21
+ for (const savedFile of savedFiles) {
22
+ yield* Console.log(`Saved ${savedFile.path} (${savedFile.bytes} bytes)`);
23
+ }
24
+ });
25
+
26
+ // linear file download <url>... - Download files uploaded to Linear
27
+ export const fileDownloadCommand = Command.make(
28
+ "download",
29
+ { urls: uploadUrlsArg, outputDir: outputDirFlag, overwrite: overwriteFlag, json: jsonFlag },
30
+ ({ urls, outputDir, overwrite, json }) =>
31
+ Effect.gen(function* () {
32
+ if (urls.length === 0) {
33
+ return yield* InvalidInputError.make({
34
+ message:
35
+ "Upload URL required. Usage: linear file download https://uploads.linear.app/... --json",
36
+ });
37
+ }
38
+ const uploadUrls = yield* Effect.forEach(urls, parseUploadUrl);
39
+ const savedFiles = yield* saveDownloads({
40
+ requests: uploadUrls.map((url) => ({ url })),
41
+ outputDir,
42
+ overwrite,
43
+ });
44
+ yield* logSavedFiles(savedFiles, json);
45
+ }),
46
+ ).pipe(
47
+ Command.withDescription("Download files uploaded to Linear with the configured credential"),
48
+ Command.withExamples([
49
+ {
50
+ command: "linear file download https://uploads.linear.app/... --output-dir ./files --json",
51
+ description: "Save one upload and print its path as JSON",
52
+ },
53
+ ]),
54
+ );
55
+
56
+ export const file = Command.make("file", {}, () =>
57
+ Console.log("Use 'linear file download <url>' to download an upload. See --help for more."),
58
+ ).pipe(
59
+ Command.withDescription("Download files uploaded to Linear"),
60
+ Command.withSubcommands([fileDownloadCommand]),
61
+ );