bakery-devops 0.2.1

Azure DevOps work item scraper with OpenSpec integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# Bakery 🥐


> A beautiful Azure DevOps work item scraper with AI-powered OpenSpec integration.

Bakery is a professional CLI tool that scrapes Azure DevOps work items and generates comprehensive OpenSpec implementation plans using AI. Features beautiful terminal output, flexible configuration, and seamless OpenSpec CLI integration with automatic validation.

## ✨ Features


- 🚀 **Clean Terminal Output** - Minimal, professional interface with verbose mode available
- 🔧 **Flexible Configuration** - User-friendly TOML configuration system
- 📁 **Smart Storage Options** - Centralized or local project-based storage
- 🤖 **AI-Powered OpenSpec Integration** - Comprehensive implementation plan generation
-**Automatic Validation** - Built-in OpenSpec CLI validation and formatting
- 📋 **Proper OpenSpec Structure** - Creates changes/proposal.md, tasks.md, and specs/
- 🎯 **Complete Azure DevOps Integration** - Full work item content extraction
- 🔄 **Retry Logic** - Automatic retries for flaky Azure DevOps API calls
- 🖨️ **Machine-Readable Output** - `--print` flag for LLM/automation integration
- ⚙️ **Professional CLI** - Built with Rust for performance and reliability

## 🚀 Quick Start


### Installation


```bash
# Install from crates.io

cargo install bakery-devops

# The binary will be available as `bakery`

bakery --help

# Or build locally

git clone https://github.com/KyleEdwardDonaldson/bakery
cd bakery
cargo build --release
```

### Basic Usage


```bash
# Scrape a work item and generate OpenSpec change proposal

bakery -t 12345

# Machine-readable output for LLM integration

bakery -t 12345 --print

# Verbose mode with detailed logging

bakery -t 12345 --verbose

# Open configuration file

bakery config
```

### 📦 Package vs Binary Name


**Important Note:**
- **Package name on crates.io:** `bakery-devops`
- **Binary name after installation:** `bakery`

```bash
# ✅ Correct: Install the package

cargo install bakery-devops

# ✅ Correct: Use the binary

bakery --help

# ❌ Incorrect: package name ≠ binary name

bakery-devops --help
```

## ⚠️ Prerequisites


### Required:

- ✅ Azure DevOps Personal Access Token (PAT)
- ✅ Network access to `dev.azure.com`

### Optional for Full OpenSpec Integration:

- 🤖 **Claude CLI** or compatible AI tool - For plan generation
- 📋 **OpenSpec CLI** (`npm install -g openspec`) - For validation and workflow

**If you don't have OpenSpec CLI**, Bakery will still:
- ✅ Scrape work items perfectly
- ✅ Generate AI plans (if AI configured)
- ⚠️ Skip validation (you'll see a warning)

**If you don't have AI CLI configured**:
```bash
# Disable OpenSpec generation

bakery -t 12345 --no-openspec

# Or disable in config

[openspec]
auto_generate = false
```

## 📋 Configuration


Bakery automatically creates a configuration file at:
- **Windows**: `%USERPROFILE%\.bakery\bakery-config.toml`
- **Mac/Linux**: `~/.bakery/bakery-config.toml`

Run `bakery config` to open and edit the configuration.

### Configuration Example


```toml
[azure_devops]
organization = "your-organization"
project = "YourProject"
pat_token = "your-pat-token-here"
api_version = "7.1"

[storage]
base_directory = "~/devops-data"
tickets_subdir = "Tickets"
openspec_subdir = "openspec"
local_baking = false  # Set true to use current directory

[openspec]
ai_command_template = "claude --print \"{prompt}\""
auto_generate = true
```

## 🔧 Azure DevOps Setup


1. **Create a Personal Access Token (PAT):**
   - Go to https://dev.azure.com/{organization}/_usersSettings/tokens
   - Click "New Token"
   - Name: "Bakery Scraper"
   - Scope: Work Items → Read (vso.work)
   - Copy token to configuration

2. **Configure Bakery:**
   ```bash
   bakery config

   # Update organization, project, pat_token

   ```

## 📁 OpenSpec Directory Structure


Bakery creates proper OpenSpec change proposals:

```
{base_directory}/
├── Tickets/
│   └── 12345/
│       ├── work_item.json
│       ├── attachments/
│       └── images/
└── openspec/
    ├── AGENTS.md         # Created by openspec init
    ├── project.md        # Project context
    ├── specs/            # Current specifications
    └── changes/          # Change proposals
        └── add-12345-feature-name/
            ├── proposal.md    # Why, What, Impact
            ├── tasks.md       # Implementation checklist
            └── specs/         # Spec deltas
                └── feature/
                    └── spec.md  # ADDED/MODIFIED/REMOVED Requirements
```

### Local Baking Mode

Set `local_baking = true` to create folders in current working directory.

## 🤖 AI Integration


Bakery uses stdin piping for maximum compatibility with AI CLIs:

### Claude CLI (Recommended)

```bash
# In config:

ai_command_template = "claude --print \"{prompt}\""
```

### Custom AI Tools

Any tool that accepts stdin or command-line prompts:
```bash
ai_command_template = "your-ai-tool --input \"{prompt}\""
```

## 📋 OpenSpec Integration


Bakery generates **proper OpenSpec change proposals** following the official methodology:

### What Gets Created:


#### 1. **proposal.md**

```markdown
# Change: Feature Name


## Why

[Problem/opportunity explanation]

## What Changes

- [Bullet list of changes]
- [Breaking changes marked]

## Impact

- Affected specs: [capabilities]
- Affected code: [files/systems]
```

#### 2. **tasks.md**
```markdown
## 1. Analysis and Planning
- [ ] 1.1 Review existing specs
- [ ] 1.2 Check for conflicts

## 2. Implementation
- [ ] 2.1 Implement feature
- [ ] 2.2 Write tests
- [ ] 2.3 Update docs

## 3. Verification
- [ ] 3.1 Run openspec validate --strict
- [ ] 3.2 Test scenarios
- [ ] 3.3 Get approval
```

#### 3. **specs/{capability}/spec.md** (if requirements included)

```markdown
## ADDED Requirements

### Requirement: Feature Name

The system SHALL provide...

#### Scenario: Success Case

- **WHEN** user performs action
- **THEN** expected result

## MODIFIED Requirements

[Full updated requirements]

## REMOVED Requirements

[Deprecated features]
```

### Automatic Validation


Bakery automatically runs `openspec validate --strict` on generated changes and reports results:
- **Passed**: Change is properly formatted
- ⚠️ **Issues**: Shows validation command to fix errors
- ⚙️ **CLI not found**: Continues without validation

### OpenSpec Commands


After generating a change:
```bash
# List all changes

openspec list

# View interactive dashboard

openspec view

# Show change details

openspec show add-12345-feature-name

# Validate change

openspec validate add-12345-feature-name --strict

# After implementation, archive the change

openspec archive add-12345-feature-name
```

## 📖 Command Line Options


```bash
bakery [OPTIONS] [COMMAND]

Commands:
  config  Open Bakery configuration file

Options:
  -t, --ticket-id <TICKET_ID>            Azure DevOps work item ID to scrape
      --organization <ORGANIZATION>      Override config organization
      --project <PROJECT>                Override config project
      --pat-token <PAT_TOKEN>            Override config PAT token
      --base-directory <BASE_DIRECTORY>  Override config base directory
      --no-openspec                      Skip OpenSpec plan generation
  -v, --verbose                          Enable verbose logging
  -p, --print                            Machine-readable output for LLMs
  -h, --help                             Print help
  -V, --version                          Print version
```

## 🔍 Examples


### Basic Usage

```bash
# Clean output (default)

bakery -t 12345

# Verbose output with all details

bakery -t 12345 --verbose

# Skip OpenSpec generation

bakery -t 12345 --no-openspec
```

### Machine-Readable Output

```bash
# Perfect for LLM/automation integration

bakery -t 12345 --print

# Output:

# --- BAKERY OUTPUT ---

# work_item_id: 12345

# work_item_title: Feature Name

# ticket_path: /path/to/Tickets/12345

# change_path: /path/to/openspec/changes/add-12345-feature-name

# status: success

```

### Override Configuration

```bash
# Different organization

bakery -t 12345 --organization my-org

# Custom storage location

bakery -t 12345 --base-directory ./my-tickets
```

## 🎯 Output Modes


### Default Mode (Clean & Concise)

```
🔄 Fetching work item #12345...
✓ Feature implementation

┌─────────────────────────────────────────────────────┐
│  🤖 AI Generating OpenSpec Plan...             │
└─────────────────────────────────────────────────────┘
✓ Validation passed
✓ 3 new requirement(s)
📁 /path/to/openspec/changes/add-12345-feature-name

✓ Complete

Next: openspec list  or openspec view
```

### Verbose Mode (`-v`)

- Detailed progress messages
- File paths for all operations
- Full summary with statistics
- Debug logging information

### Print Mode (`-p`)

- Machine-readable key-value output
- No decorations or progress indicators
- Perfect for parsing by LLMs or scripts

## 🔄 Reliability Features


### Automatic Retry Logic

- Azure DevOps API calls retry up to 3 times
- Exponential backoff (500ms base delay)
- Failures only shown in verbose/debug mode
- Handles flaky network connections gracefully

### Error Handling

- Clear error messages for common issues
- Graceful degradation (works without AI/OpenSpec CLI)
- Detailed logging in verbose mode

## 🔧 Development


### Building from Source

```bash
git clone https://github.com/KyleEdwardDonaldson/bakery
cd bakery
cargo build --release
```

### Running Tests

```bash
cargo test
```

### Development Run

```bash
cargo run -- -t 12345 --verbose
```

## 🤝 Contributing


Contributions welcome! Please:
1. Open an issue for major changes
2. Follow Rust best practices
3. Add tests for new features
4. Update documentation

## 📄 License


MIT License - see [LICENSE](LICENSE) file for details.

## 👨‍💻 Author


**Kyle Edward Donaldson**
- Email: kyle@ked.dev
- GitHub: @KyleEdwardDonaldson

## 🙏 Acknowledgments


### OpenSpec

This tool fully integrates with **OpenSpec**, the specification-driven development framework. Bakery generates proper OpenSpec change proposals that follow the official three-stage workflow.

### Built With

- [Rust]https://www.rust-lang.org/ - Systems programming language
- [clap]https://clap.rs/ - Command line parsing
- [colored]https://crates.io/crates/colored - Terminal colors
- [tokio]https://tokio.rs/ - Async runtime
- [reqwest]https://docs.rs/reqwest/ - HTTP client
- [scraper]https://crates.io/crates/scraper - HTML parsing
- [indicatif]https://crates.io/crates/indicatif - Progress indicators
- [serde]https://serde.rs/ - Serialization

### Integrations

- [Azure DevOps]https://dev.azure.com/ - Work item management
- [OpenSpec]https://github.com/Fission-AI/OpenSpec - Spec-driven development
- [Claude CLI]https://claude.ai/ - AI-powered plan generation

## 📚 Resources


- [Azure DevOps REST API]https://docs.microsoft.com/en-us/rest/api/azure/devops/
- [OpenSpec GitHub]https://github.com/Fission-AI/OpenSpec
- [OpenSpec Methodology]https://openspec.dev/
- [Rust Documentation]https://doc.rust-lang.org/

---

**Bakery v0.2.0** - Transform Azure DevOps work items into comprehensive OpenSpec change proposals with AI-powered analysis and automatic validation. 🚀