Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:<sprint id> # 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
Expand All @@ -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

Expand Down
18 changes: 18 additions & 0 deletions changes/feat-sprints.md
Original file line number Diff line number Diff line change
@@ -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:<id>` (or `sprint:none`) narrows the issues. An unnamed cycle is shown as
`Sprint <number>`.
- **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`.
13 changes: 13 additions & 0 deletions contracts/wirecat.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 27 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -10141,7 +10141,7 @@ linear identities link <document> <linear-id> <person>

## `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.**

Expand All @@ -10155,7 +10155,7 @@ linear sync [options]
| `--max-pages <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`

Expand Down Expand Up @@ -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 <n>` | rows per page, 1–500. Default: `50`. |
| `--page <n>` | 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
Expand Down
5 changes: 4 additions & 1 deletion docs/dev/test-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
|---|---|---|---|
Expand Down Expand Up @@ -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` | ✅ | |
Expand Down
1 change: 1 addition & 0 deletions lint/baseline/unknown-resource.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["sprints"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions scripts/live.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand All @@ -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

Expand Down Expand Up @@ -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"
2 changes: 2 additions & 0 deletions src/documents/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
62 changes: 56 additions & 6 deletions src/generated/wirecat-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
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: {
Expand Down Expand Up @@ -236,6 +236,54 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
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",
Expand All @@ -244,7 +292,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
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",
Expand All @@ -259,7 +307,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
},
},
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: {
Expand All @@ -268,7 +316,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
first: 50,
includeArchived: true,
},
selection: "nodes { id } pageInfo { hasNextPage endCursor }",
selection: "nodes { id trashed } pageInfo { hasNextPage endCursor }",
},
map: {
externalId: "id",
Expand All @@ -278,6 +326,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
state: "state.id",
team: "team.id",
project: "project.id",
sprint: "cycle.id",
assignee: "assignee.id",
creator: "creator.id",
labels: {
Expand All @@ -290,6 +339,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
completedAt: "completedAt",
canceledAt: "canceledAt",
url: "url",
deleted: "trashed",
createdAt: "createdAt",
updatedAt: "updatedAt",
archivedAt: "archivedAt",
Expand Down Expand Up @@ -355,7 +405,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
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: {
Expand All @@ -365,7 +415,7 @@ export const SOURCE: Readonly<Record<string, unknown>> & {
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: {
Expand Down
2 changes: 1 addition & 1 deletion src/tracker-options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading
Loading