azdo-cli 0.2.5 → 0.4.0

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.
Files changed (3) hide show
  1. package/README.md +152 -1
  2. package/dist/index.js +1002 -174
  3. package/package.json +7 -6
package/README.md CHANGED
@@ -12,9 +12,12 @@ Azure DevOps CLI focused on work item read/write workflows.
12
12
  - Update work item state (`set-state`)
13
13
  - Assign and unassign work items (`assign`)
14
14
  - Set any work item field by reference name (`set-field`)
15
+ - Create or update Tasks from markdown documents (`upsert`)
15
16
  - Read rich-text fields as markdown (`get-md-field`)
16
17
  - Set rich-text fields as markdown from inline text, file, or stdin (`set-md-field`)
18
+ - Check branch pull request status, open PRs to `develop`, and review active comments (`pr`)
17
19
  - Persist org/project/default fields in local config (`config`)
20
+ - List all fields of a work item (`list-fields`)
18
21
  - Store PAT in OS credential store (or use `AZDO_PAT`)
19
22
 
20
23
  ## Installation
@@ -47,18 +50,24 @@ azdo get-item 12345
47
50
 
48
51
  # 3) Update state
49
52
  azdo set-state 12345 "Active"
53
+
54
+ # 4) Create or update a Task from markdown
55
+ azdo upsert --content $'---\nTitle: Improve markdown import UX\nState: New\n---'
50
56
  ```
51
57
 
52
58
  ## Command Cheat Sheet
53
59
 
54
60
  | Command | Purpose | Common Flags |
55
61
  | --- | --- | --- |
56
- | `azdo get-item <id>` | Read a work item | `--short`, `--fields`, `--org`, `--project` |
62
+ | `azdo get-item <id>` | Read a work item | `--short`, `--fields`, `--markdown`, `--org`, `--project` |
57
63
  | `azdo set-state <id> <state>` | Change work item state | `--json`, `--org`, `--project` |
58
64
  | `azdo assign <id> [name]` | Assign or unassign owner | `--unassign`, `--json`, `--org`, `--project` |
59
65
  | `azdo set-field <id> <field> <value>` | Update any field | `--json`, `--org`, `--project` |
66
+ | `azdo upsert [id]` | Create or update a Task from markdown | `--content`, `--file`, `--json`, `--org`, `--project` |
60
67
  | `azdo get-md-field <id> <field>` | Get field as markdown | `--org`, `--project` |
61
68
  | `azdo set-md-field <id> <field> [content]` | Set markdown field | `--file`, `--json`, `--org`, `--project` |
69
+ | `azdo list-fields <id>` | List all fields of a work item | `--json`, `--org`, `--project` |
70
+ | `azdo pr <subcommand>` | Manage pull requests for the current branch | `status`, `open`, `comments`, `--json`, `--org`, `--project` |
62
71
  | `azdo config <subcommand>` | Manage saved settings | `set`, `get`, `list`, `unset`, `wizard`, `--json` |
63
72
  | `azdo clear-pat` | Remove stored PAT | none |
64
73
 
@@ -75,6 +84,12 @@ azdo get-item 12345 --short
75
84
 
76
85
  # Include extra fields for this call
77
86
  azdo get-item 12345 --fields "System.Tags,Microsoft.VSTS.Common.Priority"
87
+
88
+ # Convert rich text fields to markdown
89
+ azdo get-item 12345 --markdown
90
+
91
+ # Disable markdown even if config is on
92
+ azdo get-item 12345 --no-markdown
78
93
  ```
79
94
 
80
95
  ```bash
@@ -89,6 +104,24 @@ azdo assign 12345 --unassign
89
104
  azdo set-field 12345 System.Title "Updated title"
90
105
  ```
91
106
 
107
+ ### List Fields
108
+
109
+ ```bash
110
+ # List all fields with values (rich text fields preview first 5 lines)
111
+ azdo list-fields 12345
112
+
113
+ # JSON output
114
+ azdo list-fields 12345 --json
115
+ ```
116
+
117
+ ### Markdown Display
118
+
119
+ The `get-item` command can convert HTML rich-text fields to readable markdown. Resolution order:
120
+
121
+ 1. `--markdown` / `--no-markdown` flag (highest priority)
122
+ 2. Config setting: `azdo config set markdown true`
123
+ 3. Default: off (HTML stripped to plain text)
124
+
92
125
  ### Markdown Field Commands
93
126
 
94
127
  ```bash
@@ -105,6 +138,120 @@ azdo set-md-field 12345 System.Description --file ./description.md
105
138
  cat description.md | azdo set-md-field 12345 System.Description
106
139
  ```
107
140
 
141
+ ### Pull Request Commands
142
+
143
+ The `pr` command group uses the current git branch and the Azure DevOps `origin` remote automatically. It requires a PAT with `Code (Read)` scope for read operations and `Code (Read & Write)` for pull request creation.
144
+
145
+ ```bash
146
+ # Check whether the current branch already has pull requests
147
+ azdo pr status
148
+
149
+ # Open a pull request to develop
150
+ azdo pr open --title "Add PR handling" --description "Implements pr status, pr open, pr comments commands"
151
+
152
+ # Review active comments for the current branch's active pull request
153
+ azdo pr comments
154
+ ```
155
+
156
+ `azdo pr status`
157
+
158
+ - Lists all pull requests for the current branch, including active, completed, and abandoned PRs
159
+ - Prints `No pull requests found for branch <branch>.` when no PRs exist
160
+ - Supports `--json` for machine-readable output
161
+
162
+ `azdo pr open`
163
+
164
+ - Requires both `--title <title>` and `--description <description>`
165
+ - Targets `develop` automatically
166
+ - Creates a new active pull request when none exists
167
+ - Reuses the existing active PR when one already matches the branch and target
168
+ - Fails with a clear error when run from `develop` or when multiple active PRs already exist
169
+
170
+ `azdo pr comments`
171
+
172
+ - Resolves the single active pull request for the current branch
173
+ - Returns only active or pending threads with visible, non-deleted comments
174
+ - Groups text output by thread and shows file context when available
175
+ - Prints `Pull request #<id> has no active comments.` when the PR has no active comment threads
176
+ - Fails instead of guessing when no active PR or multiple active PRs exist
177
+
178
+ ## azdo upsert
179
+
180
+ `azdo upsert` accepts a single markdown task document and either creates a new Azure DevOps Task or updates an existing one. Omit `[id]` to create; pass `[id]` to update that work item in place.
181
+
182
+ ```bash
183
+ # Create from inline content
184
+ azdo upsert --content $'---\nTitle: Improve markdown import UX\nAssigned To: user@example.com\nState: New\n---'
185
+
186
+ # Update from a file
187
+ azdo upsert 12345 --file ./task-import.md
188
+
189
+ # JSON output
190
+ azdo upsert 12345 --content $'---\nSystem.Title: Improve markdown import UX\n---' --json
191
+ ```
192
+
193
+ The command requires exactly one source flag:
194
+
195
+ - `azdo upsert [id] --content <markdown>`
196
+ - `azdo upsert [id] --file <path>`
197
+
198
+ If `--file` succeeds, the source file is deleted after the Azure DevOps write completes. If parsing, validation, or the API call fails, the file is preserved. If deletion fails after a successful write, the command still succeeds and prints a warning.
199
+
200
+ ### Task Document Format
201
+
202
+ The document starts with YAML front matter for scalar fields, followed by optional `##` heading sections for markdown rich-text fields.
203
+
204
+ ```md
205
+ ---
206
+ Title: Improve markdown import UX
207
+ Assigned To: user@example.com
208
+ State: New
209
+ Tags: cli; markdown
210
+ Priority: null
211
+ ---
212
+
213
+ ## Description
214
+
215
+ Implement a single-command task import flow.
216
+
217
+ ## Acceptance Criteria
218
+
219
+ - Supports create when no ID is passed
220
+ - Supports update when an ID is passed
221
+ - Deletes imported files only after success
222
+ ```
223
+
224
+ Supported friendly field names:
225
+
226
+ - `Title`
227
+ - `Assigned To` / `assignedTo`
228
+ - `State`
229
+ - `Description`
230
+ - `Acceptance Criteria` / `acceptanceCriteria`
231
+ - `Tags`
232
+ - `Priority`
233
+
234
+ Raw Azure DevOps reference names are also accepted anywhere a field name is expected, for example `System.Title` or `Microsoft.VSTS.Common.AcceptanceCriteria`.
235
+
236
+ Clear semantics:
237
+
238
+ - Scalar YAML fields with `null` or an empty value are treated as clears on update.
239
+ - Rich-text heading sections with an empty body are treated as clears on update.
240
+ - Omitted fields are untouched on update.
241
+
242
+ `--json` output shape:
243
+
244
+ ```json
245
+ {
246
+ "action": "created",
247
+ "id": 12345,
248
+ "fields": {
249
+ "System.Title": "Improve markdown import UX",
250
+ "System.Description": "Implement a single-command task import flow."
251
+ }
252
+ }
253
+ ```
254
+
108
255
  ### Configuration
109
256
 
110
257
  ```bash
@@ -114,6 +261,9 @@ azdo config list
114
261
  # Interactive setup
115
262
  azdo config wizard
116
263
 
264
+ # Enable markdown display for all get-item calls
265
+ azdo config set markdown true
266
+
117
267
  # Set/get/unset values
118
268
  azdo config set fields "System.Tags,Custom.Priority"
119
269
  azdo config get fields
@@ -133,6 +283,7 @@ azdo clear-pat
133
283
  ## JSON Output
134
284
 
135
285
  These commands support `--json` for machine-readable output:
286
+ - `list-fields`
136
287
  - `set-state`
137
288
  - `assign`
138
289
  - `set-field`