Skip to content

feat(jtk): add issues rank to re-order issues before or after another - #509

Closed
flythebluesky wants to merge 1 commit into
open-cli-collective:mainfrom
flythebluesky:feat/jtk-issues-rank
Closed

flythebluesky wants to merge 1 commit into
open-cli-collective:mainfrom
flythebluesky:feat/jtk-issues-rank

Conversation

@flythebluesky

Copy link
Copy Markdown

Summary

Adds jtk issues rank. It moves one or more issues to sit immediately before or after another issue in Jira's rank, the order boards and backlogs show. Today the only way to re-order a backlog is dragging cards in the web UI.

jtk issues rank PROJ-7 --before PROJ-3
jtk issues rank PROJ-7 PROJ-8 PROJ-9 --after PROJ-3   # keeps the given order

Behaviour

  • Uses the Agile endpoint PUT /rest/agile/1.0/issue/rank, via a new api.Client.RankIssues.
  • Exactly one of --before / --after is required. Cobra enforces this: the two are mutually exclusive and one is required. The anchor may not be one of the issues being ranked.
  • Lists longer than 50 issues (the endpoint's per-call limit) are sent in chunks that keep the given order. With --before, every chunk is placed before the anchor. With --after, each chunk anchors on the previous chunk's last issue.
  • Partial failures: a 207 Multi-Status response names each refused issue and Jira's reason in the error, and the command exits non-zero. Issues that were ranked are not reported as failures.
  • Output: on success, Ranked PROJ-7, PROJ-8 before PROJ-3. With --id, it emits only the ranked keys.
  • No prompt and no --force: re-ranking moves issues within the order and loses no data (GUARDRAILS §5.1).

Design notes for review

  • Verb: rank isn't in the GUARDRAILS §1 verb table. I chose it because it's Jira's own term for this operation, and move already means "move to another project" here. Happy to rename if you'd prefer another verb.
  • Flags: --before / --after are long-only, following §4.4 (one-off operation knobs). The issues are the positional subject (§2.2).

Tests

  • api/rank_test.go: before and after bodies, 207 parsing, chunking in both directions, the exactly-one-anchor guard, and an API error stopping at the failing chunk.
  • internal/cmd/issues/rank_test.go: success output, --id, flag validation, refusing the anchor among the issues, and reporting refused issues.
  • golangci-lint run ./... in tools/jtk: 0 issues.
  • I developed on Windows. There, three existing tests fail with or without this change. One is in internal/config, a file-permission mode. One is in internal/cmd/refresh, which found real credentials on the machine. One is in api, TestAddAttachment, a path separator. Your Linux/macOS CI should show the real picture.

Docs

  • A tools/jtk/README.md section.
  • Rows in skills/Jira/CliReference.md and skills/Jira/SKILL.md.

Verified live

Against a Jira Cloud site: I ranked an issue before another, read the order back with jtk issues search --jql '... ORDER BY rank', then restored it with --after.

🤖 Generated with Claude Code

`jtk issues rank <issue-key>... (--before <issue-key> | --after <issue-key>)`
moves issues, in the order given, to sit immediately before or after
another issue in Jira's rank - the order boards and backlogs show - through
the Agile `PUT /rest/agile/1.0/issue/rank` endpoint.

- Exactly one of --before / --after (cobra mutually-exclusive + one-required);
  the anchor may not be among the ranked issues.
- Lists over the endpoint's 50-issue cap go in order-preserving chunks
  (each --after chunk anchors on the previous chunk's last issue).
- A 207 Multi-Status names each refused issue in the error (non-zero exit);
  --id emits the ranked keys.
- No prompt: re-ranking loses no data (GUARDRAILS 5.1).

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

Copy link
Copy Markdown
Author

Moved to a same-repo branch: #510.

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