diff --git a/README.md b/README.md index dfb33ca..bcf5223 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,8 @@ Agent: (runs linear work issues update ENG-12 --status Done, then issues commen ## Why linear -- **A copy of your workspace on your computer.** `sync` copies teams, users, states, labels, projects, issues and - comments into a local store, and the next sync takes only what changed. Lists and search then answer with no +- **A copy of your workspace on your computer.** `sync` copies teams, users, states, labels, projects, sprints (Linear's + cycles), issues and comments into a local store, and the next sync takes only what changed. Lists and search then answer with no request to Linear, also offline. - **A permission on every action.** Each command and each Linear API operation has its own level: allow, ask, read only or deny. A delete needs a key of its own. @@ -127,13 +127,20 @@ linear work issues update ENG-12 --status Done linear work issues comments create ENG-12 --text "Shipped in 2.4" ``` -### Projects and teams +### Projects, teams and cycles ```sh linear work projects list linear work teams list +linear work sprints list # each team's cycles: number, start and end +linear work issues list sprint: # or sprint:none ``` +An issue you move to Linear's trash leaves the copy at the daily check for deleted issues, which the `sync` answer +names under `deletions`: Linear does not mark a trashed issue as changed, so a plain `sync` between those checks still +shows it. Its comments leave with it. An issue you restore from the trash comes back at the next daily check. Issues in +a Duplicate state stay, and `issues list type:duplicate` lists them. + ### Documents ```sh @@ -146,8 +153,8 @@ linear work changes --since 7d # documents the syncs adde A document you move to Linear's trash leaves the copy on the next `sync`, read from the workspace's audit log. A key without audit-log access gets the warning `source.deletions-unchecked` on each sync, and trashed documents then leave -only with `sync --rescan`. A document you restore from the trash comes back only with `sync --rescan`, because Linear -does not mark a restore as a change. +only with `sync --rescan`. A document you restore from the trash comes back within a week, when `sync` walks the +chosen folders in full, or at once with `sync --rescan`, because Linear does not mark a restore as a change. ### Any Linear API operation diff --git a/changes/feat-sprints.md b/changes/feat-sprints.md new file mode 100644 index 0000000..d54547b --- /dev/null +++ b/changes/feat-sprints.md @@ -0,0 +1,18 @@ +### Added + +- **Linear's cycles, as sprints.** `sync` copies each team's cycles, `sprints list` lists them with their number, + start and end, and `issues list sprint:` (or `sprint:none`) narrows the issues. An unnamed cycle is shown as + `Sprint `. +- **An issue moved to Linear's trash leaves the local copy.** Trashing does not change an issue's edit time, so a sync + that reads only changes never saw it. The daily check for deleted issues now leaves trashed issues out, so they and + their comments leave the copy, and an issue restored from the trash comes back at the next daily check. The `sync` + answer says when that check last ran and is next due (`deletions`). +- **A document restored from Linear's trash comes back without `--rescan`.** Once a week `sync` walks the chosen + folders in full and brings it back. + +### Fixed + +- **Issues in a Duplicate state are kept.** Their state was dropped, so they pointed at a state the copy did not hold; + `issues list type:duplicate` now lists them, and a task from such an issue closes. +- **A `sync` with nothing new says so.** Its counts name only the rows that changed, so Desktop shows it up to date. A + kind the key cannot read is named in `meta.issues`. diff --git a/contracts/wirecat.json b/contracts/wirecat.json index 777c6c6..9817670 100644 --- a/contracts/wirecat.json +++ b/contracts/wirecat.json @@ -6673,6 +6673,19 @@ "permission": "projects.list", "entity": "tracker_project" }, + { + "path": [ + "sprints", + "list" + ], + "summary": "sprints copied from the tracker, newest change first", + "effects": { + "remote": "none", + "local": "read" + }, + "permission": "sprints.list", + "entity": "tracker_sprint" + }, { "path": [ "teams", diff --git a/docs/commands.md b/docs/commands.md index 4c9a4d1..ad9fc42 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -10141,7 +10141,7 @@ linear identities link ## `linear sync` -bring the tracker's copy in the local store up to date: teams, users, states, labels, projects, issues and comments that changed since the last sync, or everything with --rescan; once a day it also finds what the tracker deleted. Open issues assigned to you become your tasks, and close when the issue is done, canceled, deleted or goes to someone else. It also imports what changed in the chosen document folders, answered under documents; a part that fails leaves the other's answer. A run stops before its deadline or --max-pages and the next one goes on from there +bring the tracker's copy in the local store up to date: teams, users, states, labels, projects, sprints, issues and comments that changed since the last sync, or everything with --rescan; once a day it also finds what the tracker deleted, and says when it next will. Open issues assigned to you become your tasks, and close when the issue is done, canceled, a duplicate, deleted or goes to someone else. It also imports what changed in the chosen document folders, answered under documents; a part that fails leaves the other's answer. A run stops before its deadline or --max-pages and the next one goes on from there **Changes something on this computer only.** @@ -10155,7 +10155,7 @@ linear sync [options] | `--max-pages ` | at most this many requests for the issues in this run, and as many for the documents. | | `--embed` | also index new issues, projects and comments and the documents' pending text for meaning search, with a model already downloaded. | -**Returns:** tracker documents sync — provider, account, state, complete, synced, gaps, progress, documents, and 4 more; every field: linear commands info sync +**Returns:** tracker documents sync — provider, account, state, complete, synced, gaps, progress, deletions, and 5 more; every field: linear commands info sync **Example:** `linear work sync`, `linear work sync --rescan` @@ -10350,6 +10350,31 @@ linear projects list [query] [options] **Example:** `linear work projects list`, `linear work projects list archived:include` +## `linear sprints` + +each team's sprints (Linear's cycles): number, start, end and when completed + +### `linear sprints list` + +sprints copied from the tracker, newest change first + +```sh +linear sprints list [query] [options] +``` + +| Argument | | What it is | +|---|---|---| +| `query` | optional | field:value terms that narrow the list — the fields are below. | + +| Option | What it does | +|---|---| +| `--limit ` | rows per page, 1–500. Default: `50`. | +| `--page ` | which page, starting at 1. Default: `1`. | + +**Returns:** tracker sprint — kind, external_id, deleted; every field: linear commands info sprints list + +**Example:** `linear work sprints list`, `linear work sprints list archived:include` + ## `linear teams` the tracker's teams diff --git a/docs/dev/test-matrix.md b/docs/dev/test-matrix.md index 308682a..c414106 100644 --- a/docs/dev/test-matrix.md +++ b/docs/dev/test-matrix.md @@ -7,7 +7,7 @@ ran it · ⛔ not tested offline, with the reason and where it is checked instea Measured from the test run (`coverage/argv.jsonl`), not searched for — see [TESTING.md](TESTING.md) for how, and for the states and failures that cut across commands. -**2760 ✅ · 89 ⛔ · 0 ❌** — 582 commands, 2267 options. +**2763 ✅ · 89 ⛔ · 0 ❌** — 583 commands, 2269 options. | Command | Option | | Note | |---|---|---|---| @@ -2770,6 +2770,9 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `projects list` | | ✅ | | | `projects list` | `--limit` | ✅ | | | `projects list` | `--page` | ✅ | | +| `sprints list` | | ✅ | | +| `sprints list` | `--limit` | ✅ | | +| `sprints list` | `--page` | ✅ | | | `teams list` | | ✅ | | | `teams list` | `--limit` | ✅ | | | `teams list` | `--page` | ✅ | | diff --git a/lint/baseline/unknown-resource.json b/lint/baseline/unknown-resource.json new file mode 100644 index 0000000..9005b86 --- /dev/null +++ b/lint/baseline/unknown-resource.json @@ -0,0 +1 @@ +["sprints"] diff --git a/package.json b/package.json index 37a6b38..d5789e8 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ }, "dependencies": { "@wirecat/cli-base": "0.132.0", - "@wirecat/cli-core": "0.744.0", + "@wirecat/cli-core": "0.750.0", "commander": "15.0.0", "valibot": "1.5.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 067b4bf..ec32844 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: specifier: 0.132.0 version: 0.132.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core': - specifier: 0.744.0 - version: 0.744.0(@wirecat/cli-base@0.132.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) + specifier: 0.750.0 + version: 0.750.0(@wirecat/cli-base@0.132.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) commander: specifier: 15.0.0 version: 15.0.0 @@ -1213,8 +1213,8 @@ packages: '@wirecat/cli-core-sqlite@1.1.0': resolution: {integrity: sha512-GpGlh/dAIX/nblBYCdT6DfWSLFxav9mxxeELQAfEuw+QZdT9unKxbi5xa02s/s4JS1P7n0PQx2sCABj4FlMRNw==} - '@wirecat/cli-core@0.744.0': - resolution: {integrity: sha512-KqP/T5z5TLah1bqO4yBO5WdSKy/E6oqd9Id531i6LH/P68s3rC5M/PgBGwrm+x5FLEfIhYp91FlH1p9eHEx+5g==} + '@wirecat/cli-core@0.750.0': + resolution: {integrity: sha512-9xUOyRg8cAmb64EJ37thM6AbNNy3xbgVRMhCjTjKU9xN0osUWO1euXB8IN+qmgn1W7aQU2tuXP4XcsuJUY2Evw==} engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: @@ -3364,7 +3364,7 @@ snapshots: '@wirecat/cli-core-sqlite@1.1.0': {} - '@wirecat/cli-core@0.744.0(@wirecat/cli-base@0.132.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': + '@wirecat/cli-core@0.750.0(@wirecat/cli-base@0.132.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': dependencies: '@anthropic-ai/sdk': 1.3.0(zod@4.6.7) '@bomb.sh/tab': 0.0.22(commander@15.0.0) diff --git a/scripts/live.sh b/scripts/live.sh index 85ed352..ec79f15 100755 --- a/scripts/live.sh +++ b/scripts/live.sh @@ -4,7 +4,7 @@ # keyring is out of reach, so nothing touches the owner's store, keyring or settings. # scripts/live.sh < token-file # Needs: a Linear personal API key the owner chose for this check (keyring service linear), read access is enough -# Needs: a workspace with at least one team and one issue the key can read +# Needs: a workspace with at least one team and one issue the key can read, and a team with cycles turned on # Needs: write access and the workspace's audit log (an admin's key): the check makes a project with one document, trashes the document and the project set -euo pipefail root=$(cd -- "$(dirname -- "$0")/.." && pwd) @@ -59,6 +59,7 @@ trap cleanup EXIT "${cli[@]}" live sync --max-pages 40 --json >"$work/changes.json" "${cli[@]}" live teams list --json >"$work/teams.json" "${cli[@]}" live issues list --limit 1 --json >"$work/issues.json" +"${cli[@]}" live sprints list --json >"$work/sprints.json" # Totals only: the record is public, the workspace's data is not. node -e ' const read = (name) => JSON.parse(require("fs").readFileSync(`${process.argv[1]}/${name}.json`, "utf8")) @@ -76,7 +77,11 @@ node -e ' const changes = check("changes") if (!changes.synced.some((one) => one.round === "changes")) throw new Error("the second sync read no changes round") if (!(read("teams").items ?? []).length || !(read("issues").items ?? []).length) throw new Error("teams or issues list empty") - process.stdout.write(`synced: ${full.synced.map((one) => `${one.kind} ${one.saved}`).join(", ")}; changes round: ${changes.synced.length} kinds\n`) + // Linear makes the cycles of a team once they are turned on, and the API refuses to create one. + const sprints = read("sprints").items ?? [] + if (!sprints.length) throw new Error("sprints list is empty: turn on cycles for a team the key can read") + if (!sprints.every((one) => typeof one.number === "number" && one.starts_at)) throw new Error("a sprint has no number or start") + process.stdout.write(`synced: ${full.synced.map((one) => `${one.kind} ${one.saved}`).join(", ")}; changes round: ${changes.synced.length} kinds; sprints: ${sprints.length}\n`) ' "$work" "${cli[@]}" live doctor --json >/dev/null @@ -123,5 +128,5 @@ node -e ' project="" "${cli[@]}" live session end --json >/dev/null -echo "live check passed: describe format 2, sign-in, full and changes sync, teams and issues from the copy, doctor," \ +echo "live check passed: describe format 2, sign-in, full and changes sync, teams, issues and sprints from the copy, doctor," \ "a trashed document removed by a plain sync, sign-out" diff --git a/src/documents/manifest.ts b/src/documents/manifest.ts index 13e768d..a4c37a8 100644 --- a/src/documents/manifest.ts +++ b/src/documents/manifest.ts @@ -37,6 +37,8 @@ export const DOCUMENT_MANIFEST = { id: "metadata.entityId", }, content: { operation: "document", body: { id: "{id}" }, markdown: "content" }, + // A restore from the trash moves no updatedAt and has no audit entry: only a full walk brings the document back. + rescanEvery: "7d", reads: { project: { operation: "project", body: { id: "{id}" } }, projects: { operation: "projects", body: all }, diff --git a/src/generated/wirecat-config.ts b/src/generated/wirecat-config.ts index 97f92cd..211f64b 100644 --- a/src/generated/wirecat-config.ts +++ b/src/generated/wirecat-config.ts @@ -11,7 +11,7 @@ export const SOURCE: Readonly> & { readonly kinds: readonly string[] } = { provider: "linear", - kinds: ["team", "user", "state", "label", "project", "issue", "comment"], + kinds: ["team", "user", "state", "label", "project", "sprint", "issue", "comment"], entities: { team: { list: { @@ -236,6 +236,54 @@ export const SOURCE: Readonly> & { archivedAt: "archivedAt", }, }, + sprint: { + list: { + operation: "cycles", + variables: { + first: 100, + includeArchived: true, + }, + selection: + "nodes { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt team { id } } pageInfo { hasNextPage endCursor }", + }, + changes: { + operation: "cycles", + variables: { + first: 100, + includeArchived: true, + orderBy: "updatedAt", + filter: { + updatedAt: { + gte: "{since}", + }, + }, + }, + selection: + "nodes { id createdAt updatedAt archivedAt number name description startsAt endsAt completedAt team { id } } pageInfo { hasNextPage endCursor }", + since: "iso", + }, + ids: { + operation: "cycles", + variables: { + first: 100, + includeArchived: true, + }, + selection: "nodes { id } pageInfo { hasNextPage endCursor }", + }, + map: { + externalId: "id", + name: "name", + number: "number", + description: "description", + team: "team.id", + startsAt: "startsAt", + endsAt: "endsAt", + completedAt: "completedAt", + createdAt: "createdAt", + updatedAt: "updatedAt", + archivedAt: "archivedAt", + }, + }, issue: { list: { operation: "issues", @@ -244,7 +292,7 @@ export const SOURCE: Readonly> & { includeArchived: true, }, selection: - "nodes { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } assignee { id } creator { id } parent { id } labels { nodes { id } } } pageInfo { hasNextPage endCursor }", + "nodes { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } cycle { id } assignee { id } creator { id } parent { id } labels { nodes { id } } trashed } pageInfo { hasNextPage endCursor }", }, changes: { operation: "issues", @@ -259,7 +307,7 @@ export const SOURCE: Readonly> & { }, }, selection: - "nodes { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } assignee { id } creator { id } parent { id } labels { nodes { id } } } pageInfo { hasNextPage endCursor }", + "nodes { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } cycle { id } assignee { id } creator { id } parent { id } labels { nodes { id } } trashed } pageInfo { hasNextPage endCursor }", since: "iso", }, ids: { @@ -268,7 +316,7 @@ export const SOURCE: Readonly> & { first: 50, includeArchived: true, }, - selection: "nodes { id } pageInfo { hasNextPage endCursor }", + selection: "nodes { id trashed } pageInfo { hasNextPage endCursor }", }, map: { externalId: "id", @@ -278,6 +326,7 @@ export const SOURCE: Readonly> & { state: "state.id", team: "team.id", project: "project.id", + sprint: "cycle.id", assignee: "assignee.id", creator: "creator.id", labels: { @@ -290,6 +339,7 @@ export const SOURCE: Readonly> & { completedAt: "completedAt", canceledAt: "canceledAt", url: "url", + deleted: "trashed", createdAt: "createdAt", updatedAt: "updatedAt", archivedAt: "archivedAt", @@ -355,7 +405,7 @@ export const SOURCE: Readonly> & { input: "{values}", }, selection: - "success issue { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } assignee { id } creator { id } parent { id } labels { nodes { id } } }", + "success issue { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } cycle { id } assignee { id } creator { id } parent { id } labels { nodes { id } } trashed }", items: "issue", }, update: { @@ -365,7 +415,7 @@ export const SOURCE: Readonly> & { input: "{values}", }, selection: - "success issue { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } assignee { id } creator { id } parent { id } labels { nodes { id } } }", + "success issue { id createdAt updatedAt archivedAt identifier title description url priority dueDate completedAt canceledAt state { id } team { id } project { id } cycle { id } assignee { id } creator { id } parent { id } labels { nodes { id } } trashed }", items: "issue", }, fields: { diff --git a/src/tracker-options.test.ts b/src/tracker-options.test.ts index 2095232..87a7d75 100644 --- a/src/tracker-options.test.ts +++ b/src/tracker-options.test.ts @@ -25,7 +25,7 @@ it("every option of the tracker commands runs over a synced copy", async () => { ["issues", "show", ref], ["issues", "search", word, "--limit", "1", "--page", "1"], ["issues", "assign", ref, "--due", "3d"], - ...["projects", "teams", "users", "states", "labels"].map((group) => [ + ...["projects", "teams", "users", "states", "labels", "sprints"].map((group) => [ group, "list", "--limit", diff --git a/src/tracker-sprints.test.ts b/src/tracker-sprints.test.ts new file mode 100644 index 0000000..d70a293 --- /dev/null +++ b/src/tracker-sprints.test.ts @@ -0,0 +1,90 @@ +import { tmpdir } from "node:os" +import { join } from "node:path" +import { memoryKeyring } from "@wirecat/cli-base" +import { FAKE_MANIFEST_TOKEN } from "@wirecat/cli-core/crm/testing" +import { openStore } from "@wirecat/cli-core/store" +import { syncTracker } from "@wirecat/cli-core/tracker" +import { trackerManifestFake, trackerManifestFixture } from "@wirecat/cli-core/tracker/testing" +import { expect, it } from "vitest" +import { API } from "./config.js" +import { definitions } from "./generated/definitions.js" +import { HOOK_OPTIONS, SOURCE } from "./generated/wirecat-config.js" +import { runCli } from "./testing/harness.js" + +const DAY = 86_400_000 + +const setup = async () => { + const keyring = memoryKeyring() + const fake = trackerManifestFake(SOURCE, { api: API.manifest, definitions }) + // Two rows of each kind fit one page, and the sync writes the store for each page: three rows were too slow for CI. + for (const rows of Object.values(fake.rows)) rows?.splice(2) + const cli = async (...args: string[]) => { + const ran = await runCli(["personal", ...args, "--json"], { keyring, service: fake }) + expect(ran.code, ran.err).toBe(0) + return ran.json() as { items: Record[]; item: Record } + } + const started = await runCli(["personal", "session", "start", "--json"], { + keyring, + service: fake, + stdin: FAKE_MANIFEST_TOKEN, + }) + expect(started.code, started.err).toBe(0) + const ids = async (...query: string[]) => + (await cli("issues", "list", ...query)).items.map((one) => one.external_id).sort() + const row = (kind: "issue" | "state", id: string) => + fake.rows[kind]?.find((one) => one.id === id) as Record + return { fake, cli, ids, row } +} + +it("copies Linear's cycles as sprints, narrows issues by their cycle, and keeps a Duplicate state", async () => { + const { fake, cli, ids, row } = await setup() + row("issue", "issue-2").cycle = null + fake.touch("issue", "issue-2") + row("state", "state-1").type = "duplicate" + fake.touch("state", "state-1") + await cli("sync") + + const sprints = (await cli("sprints", "list")).items + expect(sprints.map((one) => one.external_id).sort()).toEqual(["sprint-1", "sprint-2"]) + expect(sprints.find((one) => one.external_id === "sprint-1")).toMatchObject({ number: 1, team: "team-1" }) + expect(await ids("sprint:sprint-1")).toEqual(["issue-1"]) + expect(await ids("sprint:none")).toEqual(["issue-2"]) + + expect((await cli("states", "list")).items.map((one) => one.type)).toContain("duplicate") + expect(await ids("type:duplicate")).toEqual(["issue-1", "issue-2"]) + expect(fake.refusals).toEqual([]) +}) + +it("drops an issue moved to the trash at the daily pass, and brings it back with its comments once restored", async () => { + const fixture = trackerManifestFixture(SOURCE, { api: API.manifest, definitions, ...HOOK_OPTIONS }) + const { fake } = fixture + for (const rows of Object.values(fake.rows)) rows?.splice(2) + // Only the kinds the case reads: each kind is several store writes a sync, and all eight were too slow for CI. + const source = Object.create(fixture.source, { + traits: { value: { ...fixture.source.traits, kinds: ["issue", "comment"] } }, + }) as typeof fixture.source + const store = await openStore({ path: join(tmpdir(), "trash.db") }) + const account = { provider: "linear", account: "user-1" } as const + let now = Date.parse("2026-11-25T10:00:00Z") + const sync = async () => { + now += 2 * DAY + await syncTracker(source, store, account, { now }) + } + const live = async () => (await store.tracker.list(account, "issue")).items.map((one) => one.record.externalId).sort() + const comments = async () => (await store.tracker.list(account, "comment")).items.length + + await sync() + expect(await comments()).toBe(2) + fake.trash("issue", "issue-1") + await sync() + expect(await live()).toEqual(["issue-2"]) + expect(await comments()).toBe(0) + + const row = fake.rows.issue?.find((one) => one.id === "issue-1") as Record + Object.assign(row, { trashed: null, archivedAt: null }) + await sync() + expect(await live()).toEqual(["issue-1", "issue-2"]) + expect(await comments()).toBe(2) + expect(fake.refusals).toEqual([]) + await store.close() +}) diff --git a/wirecat.config.ts b/wirecat.config.ts index f2d72d1..64c1f83 100644 --- a/wirecat.config.ts +++ b/wirecat.config.ts @@ -7,12 +7,12 @@ const timeMap = { createdAt: "createdAt", updatedAt: "updatedAt", archivedAt: "a const all = { first: 100, includeArchived: true } const issueFields = "identifier title description url priority dueDate completedAt canceledAt state { id } team { id } " + - "project { id } assignee { id } creator { id } parent { id } labels { nodes { id } }" + "project { id } cycle { id } assignee { id } creator { id } parent { id } labels { nodes { id } } trashed" const commentFields = "body url issue { id } user { id }" // Three calls per kind: everything, what changed since the cursor, and every id for the deletion pass, which selects -// nothing else to keep Linear's complexity points low. -const kind = (operation: string, fields: string, extra: Record = {}) => { +// only the id and what marks a row deleted, to keep Linear's complexity points low. +const kind = (operation: string, fields: string, extra: Record = {}, ids = "id") => { const selection = `nodes { id ${times} ${fields} } ${page}` return { list: { operation, variables: { ...all, ...extra }, selection }, @@ -22,7 +22,7 @@ const kind = (operation: string, fields: string, extra: Record selection, since: "iso" as const, }, - ids: { operation, variables: { ...all, ...extra }, selection: `nodes { id } ${page}` }, + ids: { operation, variables: { ...all, ...extra }, selection: `nodes { ${ids} } ${page}` }, } } @@ -41,7 +41,7 @@ export default defineCli({ category: "tracker", source: { provider: "linear", - kinds: ["team", "user", "state", "label", "project", "issue", "comment"], + kinds: ["team", "user", "state", "label", "project", "sprint", "issue", "comment"], entities: { team: { ...kind("teams", "name key"), map: { externalId: "id", name: "name", key: "key", ...timeMap } }, user: { @@ -75,8 +75,24 @@ export default defineCli({ ...timeMap, }, }, + // Linear's cycles; most have no name, and the copy titles them by number. + sprint: { + ...kind("cycles", "number name description startsAt endsAt completedAt team { id }"), + map: { + externalId: "id", + name: "name", + number: "number", + description: "description", + team: "team.id", + startsAt: "startsAt", + endsAt: "endsAt", + completedAt: "completedAt", + ...timeMap, + }, + }, issue: { - ...kind("issues", issueFields, { first: 50 }), + // Trashing an issue leaves its updatedAt, so only the daily id pass sees it: it reads trashed to leave it out. + ...kind("issues", issueFields, { first: 50 }, "id trashed"), map: { externalId: "id", key: "identifier", @@ -85,6 +101,7 @@ export default defineCli({ state: "state.id", team: "team.id", project: "project.id", + sprint: "cycle.id", assignee: "assignee.id", creator: "creator.id", labels: { each: "labels.nodes", id: "id" }, @@ -94,6 +111,7 @@ export default defineCli({ completedAt: "completedAt", canceledAt: "canceledAt", url: "url", + deleted: "trashed", ...timeMap, }, },