@sppg2001/atomize 1.2.4 → 2.0.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.
@@ -0,0 +1,662 @@
1
+ # Platform Guide
2
+
3
+ Setup and configuration guide for different work item management platforms.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Overview](#overview)
8
+ - [Azure DevOps](#azure-devops)
9
+ - [GitHub Models (AI)](#github-models-ai)
10
+ - [Mock Platform](#mock-platform)
11
+ - [Adding New Platforms](#adding-new-platforms)
12
+
13
+ ---
14
+
15
+ ## Overview
16
+
17
+ Atomize connects to two kinds of external service — work item platforms (where tasks are created) and AI providers (for template generation). Each is configured as a named profile.
18
+
19
+ **Work item platforms:**
20
+
21
+ | Platform | Status | Features |
22
+ |----------|--------|----------|
23
+ | Azure DevOps | ✅ Production | Full support with WIQL queries |
24
+ | Mock | ✅ Production | Testing and development |
25
+ | Jira | 🚧 Planned | Coming soon |
26
+ | GitHub Issues | 🚧 Planned | Coming soon |
27
+
28
+ **AI providers:**
29
+
30
+ | Provider | Status | Used for |
31
+ |----------|--------|----------|
32
+ | GitHub Models | ✅ Production | `template create --ai` |
33
+
34
+ ---
35
+
36
+ ## Azure DevOps
37
+
38
+ Complete setup guide for Azure DevOps Services.
39
+
40
+ ### Prerequisites
41
+
42
+ - Azure DevOps organization and project
43
+ - Personal Access Token (PAT) with Work Items permissions
44
+ - Node.js 18+ or Bun runtime
45
+
46
+ ### Quick Start
47
+
48
+ 1. **Get your organization URL and project name**
49
+
50
+ Your Azure DevOps URL looks like:
51
+ ```
52
+ https://dev.azure.com/{organization}
53
+ ```
54
+
55
+ Example: `https://dev.azure.com/contoso`
56
+
57
+ 2. **Create a Personal Access Token (PAT)**
58
+
59
+ - Go to `https://dev.azure.com/{organization}/_usersSettings/tokens`
60
+ - Click "New Token"
61
+ - Set scopes: **Work Items (Read, Write)**
62
+ - Copy the token (you won't see it again!)
63
+
64
+ 3. **Save a connection profile**
65
+
66
+ Interactive (recommended for local setup):
67
+ ```bash
68
+ atomize auth add work-ado
69
+ # Prompts for org URL, project, team, and PAT
70
+ # Set as default when prompted
71
+ ```
72
+
73
+ Non-interactive for CI/CD (use `--pat-stdin` to avoid token exposure in env vars):
74
+ ```bash
75
+ echo "$AZURE_DEVOPS_PAT" | atomize auth add ci \
76
+ --org-url https://dev.azure.com/myorg \
77
+ --project MyProject \
78
+ --team MyTeam \
79
+ --default \
80
+ --pat-stdin
81
+ ```
82
+
83
+ 4. **Test connection**
84
+
85
+ ```bash
86
+ atomize auth test work-ado
87
+ ```
88
+
89
+ ### Configuration
90
+
91
+ Credentials are managed as named profiles using the `auth` commands. PATs are stored in the OS keychain when available. If the keychain is unavailable, `--insecure-storage` explicitly opts into an insecure local file fallback under `~/.atomize/`.
92
+
93
+ **Add a profile:**
94
+ ```bash
95
+ atomize auth add <name>
96
+ ```
97
+
98
+ **Use a specific profile for generate:**
99
+ ```bash
100
+ atomize generate template:backend-api --profile work-ado
101
+ ```
102
+
103
+ **Set a profile as default (used when `--profile` is not specified):**
104
+ ```bash
105
+ atomize auth use work-ado
106
+ ```
107
+
108
+ **Select a profile via environment variable:**
109
+ ```bash
110
+ export ATOMIZE_PROFILE=work-ado
111
+ atomize generate template:backend-api
112
+ ```
113
+
114
+ **Multiple profiles example:**
115
+ ```bash
116
+ atomize auth add personal --org-url https://dev.azure.com/personal-org ...
117
+ atomize auth add work --org-url https://dev.azure.com/work-org ...
118
+
119
+ atomize generate template.yaml --profile personal
120
+ atomize generate template.yaml --profile work
121
+ ```
122
+
123
+ ### PAT Permissions
124
+
125
+ Your Personal Access Token needs these scopes:
126
+
127
+ | Scope | Access Level | Required |
128
+ |-------|--------------|----------|
129
+ | Work Items | Read | ✅ Yes |
130
+ | Work Items | Write | ✅ Yes |
131
+ | Project and Team | Read | ⚪ Optional |
132
+
133
+ **Minimum permissions:**
134
+ - Read work items
135
+ - Write work items
136
+ - Create work item links
137
+
138
+ ### Azure DevOps Concepts
139
+
140
+ #### Work Item Types
141
+
142
+ Default Azure DevOps work item types:
143
+
144
+ ```yaml
145
+ filter:
146
+ workItemTypes:
147
+ - "User Story" # Scrum
148
+ - "Product Backlog Item" # Agile
149
+ - "Bug"
150
+ - "Task"
151
+ - "Epic"
152
+ - "Feature"
153
+ ```
154
+
155
+ #### States
156
+
157
+ Common work item states:
158
+
159
+ ```yaml
160
+ filter:
161
+ states:
162
+ - "New" # Just created
163
+ - "Active" # In progress
164
+ - "Resolved" # Completed, awaiting verification
165
+ - "Closed" # Verified and done
166
+ - "Removed" # Cancelled
167
+ ```
168
+
169
+ #### Area Paths
170
+
171
+ Organize work items by product area:
172
+
173
+ ```yaml
174
+ filter:
175
+ areaPaths:
176
+ - "MyProject\\Backend"
177
+ - "MyProject\\Frontend"
178
+ - "MyProject\\Infrastructure"
179
+ ```
180
+
181
+ #### Iteration Paths
182
+
183
+ Organize work items by sprint/iteration:
184
+
185
+ ```yaml
186
+ filter:
187
+ iterations:
188
+ - "MyProject\\Sprint 23"
189
+ - "MyProject\\Sprint 24"
190
+ ```
191
+
192
+ ### WIQL Queries
193
+
194
+ Azure DevOps uses Work Item Query Language (WIQL) for filtering.
195
+
196
+ **Basic query structure:**
197
+ ```sql
198
+ SELECT [System.Id]
199
+ FROM WorkItems
200
+ WHERE [System.TeamProject] = 'MyProject'
201
+ AND [System.WorkItemType] = 'User Story'
202
+ AND [System.State] = 'New'
203
+ ```
204
+
205
+ **Template filter to WIQL:**
206
+
207
+ Template:
208
+ ```yaml
209
+ filter:
210
+ workItemTypes: ["User Story"]
211
+ states: ["New", "Active"]
212
+ tags:
213
+ include: ["backend"]
214
+ ```
215
+
216
+ Generated WIQL:
217
+ ```sql
218
+ SELECT [System.Id]
219
+ FROM WorkItems
220
+ WHERE [System.TeamProject] = 'MyProject'
221
+ AND [System.WorkItemType] IN ('User Story')
222
+ AND [System.State] IN ('New', 'Active')
223
+ AND [System.Tags] CONTAINS 'backend'
224
+ ```
225
+
226
+ ### Custom Fields
227
+
228
+ Azure DevOps supports custom fields for work items.
229
+
230
+ **Common custom fields:**
231
+
232
+ ```yaml
233
+ filter:
234
+ customFields:
235
+ - field: "Custom.Team"
236
+ operator: "equals"
237
+ value: "Platform Engineering"
238
+
239
+ - field: "Custom.Complexity"
240
+ operator: "greaterThan"
241
+ value: 3
242
+
243
+ - field: "Microsoft.VSTS.Common.Priority"
244
+ operator: "lessThan"
245
+ value: 3
246
+ ```
247
+
248
+ **Field reference format:**
249
+ - System fields: `System.FieldName` (e.g., `System.State`)
250
+ - Microsoft fields: `Microsoft.VSTS.*.FieldName`
251
+ - Custom fields: `Custom.FieldName`
252
+
253
+ **Common system fields:**
254
+ - `System.Id` - Work item ID
255
+ - `System.Title` - Title
256
+ - `System.State` - Current state
257
+ - `System.WorkItemType` - Type
258
+ - `System.AssignedTo` - Assigned user
259
+ - `System.Tags` - Tags (semicolon-separated)
260
+ - `System.AreaPath` - Area path
261
+ - `System.IterationPath` - Iteration path
262
+ - `System.CreatedDate` - Creation date
263
+ - `System.ChangedDate` - Last modified date
264
+
265
+ **Common Microsoft fields:**
266
+ - `Microsoft.VSTS.Scheduling.StoryPoints` - Story points
267
+ - `Microsoft.VSTS.Scheduling.RemainingWork` - Remaining work (hours)
268
+ - `Microsoft.VSTS.Common.Priority` - Priority (1-5)
269
+ - `Microsoft.VSTS.Common.Activity` - Activity type
270
+ - `Microsoft.VSTS.Common.BacklogPriority` - Backlog priority
271
+
272
+ ### Task Creation
273
+
274
+ When creating tasks, Atomize sets these fields:
275
+
276
+ ```yaml
277
+ # Task definition
278
+ tasks:
279
+ - title: "Implement API"
280
+ description: "Implementation details"
281
+ estimationPercent: 40
282
+ tags: ["backend", "api"]
283
+ activity: "Development"
284
+ assignTo: "john@company.com"
285
+ priority: 2
286
+ ```
287
+
288
+ Maps to Azure DevOps fields:
289
+ - `System.Title` ← title
290
+ - `System.Description` ← description
291
+ - `Microsoft.VSTS.Scheduling.RemainingWork` ← estimationPercent * story points
292
+ - `System.Tags` ← tags (joined with "; ")
293
+ - `Microsoft.VSTS.Common.Activity` ← activity
294
+ - `System.AssignedTo` ← assignTo
295
+ - `Microsoft.VSTS.Common.Priority` ← priority
296
+
297
+ ### Troubleshooting
298
+
299
+ #### Authentication Failures
300
+
301
+ **Problem:** `Authentication failed: 401 Unauthorized`
302
+
303
+ **Solutions:**
304
+ 1. Verify PAT hasn't expired — rotate it with `atomize auth rotate <name>`
305
+ 2. Check PAT has correct scopes (Work Items Read/Write)
306
+ 3. Verify organization URL format: `https://dev.azure.com/org`
307
+ 4. Don't include project in organization URL
308
+ 5. Test the profile: `atomize auth test <name>`
309
+
310
+ #### No Work Items Found
311
+
312
+ **Problem:** `Found 0 stories matching filter criteria`
313
+
314
+ **Solutions:**
315
+ 1. Check work item types match your project's process template
316
+ 2. Verify states exist in your project
317
+ 3. Check area/iteration paths are correct (case-sensitive)
318
+ 4. Test with mock platform first:
319
+ ```bash
320
+ atomize generate template:backend-api --platform mock
321
+ ```
322
+
323
+ #### Permission Errors
324
+
325
+ **Problem:** `Failed to create task: Access Denied`
326
+
327
+ **Solutions:**
328
+ 1. Verify PAT has Write permissions
329
+ 2. Check project permissions (Project Contributor role)
330
+ 3. Verify you can create work items manually in the web UI
331
+
332
+ #### Connection Timeouts
333
+
334
+ **Problem:** `Request timeout` or `ECONNRESET`
335
+
336
+ **Solutions:**
337
+ 1. Check network connectivity
338
+ 2. Verify organization URL is accessible
339
+ 3. Check if behind corporate proxy (configure proxy settings)
340
+ 4. Try with increased timeout
341
+
342
+ ---
343
+
344
+ ## GitHub Models (AI)
345
+
346
+ GitHub Models is the AI provider used by `template create --ai`. It is not a work item platform — no tasks are created through it — but it requires its own connection profile.
347
+
348
+ ### Prerequisites
349
+
350
+ - A GitHub personal access token with the `models:read` scope
351
+ - Create one at `https://github.com/settings/tokens`
352
+
353
+ ### Setup
354
+
355
+ ```bash
356
+ atomize auth add my-ai
357
+ # → select "GitHub Models (AI template generation)" when prompted for platform type
358
+ # → enter your GitHub PAT
359
+
360
+ atomize auth test my-ai
361
+ ```
362
+
363
+ ### Usage
364
+
365
+ Once the profile is saved, pass it when generating AI templates:
366
+
367
+ ```bash
368
+ atomize template create --ai # uses default GitHub Models profile
369
+ atomize template create --ai --ai-profile my-ai # explicit profile
370
+ atomize template create --ai --ground --profile work-ado # grounded with ADO context
371
+ ```
372
+
373
+ `ATOMIZE_AI_PROFILE` can be set as an alternative to `--ai-profile`.
374
+
375
+ See [Template Creation Wizard — AI-Assisted Generation](./template-wizard-guide.md#ai-assisted-generation) for the full workflow.
376
+
377
+ ---
378
+
379
+ ## Mock Platform
380
+
381
+ The mock platform provides sample data for testing and development.
382
+
383
+ ### Usage
384
+
385
+ ```bash
386
+ atomize generate template:backend-api --platform mock
387
+ ```
388
+
389
+ ### Features
390
+
391
+ - No configuration required
392
+ - Sample user stories with various states and tags
393
+ - Simulated network delays
394
+ - Perfect for template development and testing
395
+
396
+ ### Sample Data
397
+
398
+ The mock platform includes 7 sample stories:
399
+
400
+ ```
401
+ STORY-001: Implement user authentication API
402
+ State: New, Tags: backend, api, security
403
+ Estimation: 8 points
404
+
405
+ STORY-002: Create user profile dashboard
406
+ State: Active, Tags: frontend, react, ui
407
+ Estimation: 5 points
408
+
409
+ STORY-003: Implement payment processing
410
+ State: New, Tags: backend, api, payment
411
+ Estimation: 13 points
412
+
413
+ STORY-004: Add search functionality
414
+ State: Approved, Tags: fullstack, search, api, frontend
415
+ Estimation: 8 points
416
+
417
+ STORY-005: Optimize database queries
418
+ State: New, Tags: backend, database, performance
419
+ Estimation: 3 points
420
+
421
+ STORY-006: Mobile responsive design
422
+ State: New, Tags: frontend, mobile, css
423
+ Estimation: 5 points
424
+
425
+ STORY-007: Implement data export feature
426
+ State: Active, Tags: backend, api, export
427
+ Estimation: 8 points (has 1 existing task)
428
+ ```
429
+
430
+ ### Testing Workflows
431
+
432
+ **1. Template Development:**
433
+ ```bash
434
+ # Create template
435
+ atomize template create --scratch --save-as test-template
436
+
437
+ # Test with mock data
438
+ atomize generate test-template.yaml --platform mock
439
+
440
+ # Iterate until satisfied
441
+ ```
442
+
443
+ **2. Filter Testing:**
444
+ ```bash
445
+ # Test different filters
446
+ atomize generate test-template.yaml --platform mock
447
+
448
+ # Check which stories match
449
+ # Adjust filter criteria
450
+ # Repeat
451
+ ```
452
+
453
+ **3. CI/CD Testing:**
454
+ ```yaml
455
+ # .github/workflows/test.yml
456
+ - name: Test Templates
457
+ run: |
458
+ for template in templates/*.yaml; do
459
+ atomize validate "$template"
460
+ atomize generate "$template" --platform mock
461
+ done
462
+ ```
463
+
464
+ ---
465
+
466
+ ## Adding New Platforms
467
+
468
+ Want to add support for Jira, GitHub, or another platform? Here's how.
469
+
470
+ ### Architecture
471
+
472
+ All platforms implement the `IPlatformAdapter` interface:
473
+
474
+ ```typescript
475
+ interface IPlatformAdapter {
476
+ authenticate(config?: AuthConfig): Promise<void>;
477
+ queryWorkItems(filter: FilterCriteria): Promise<WorkItem[]>;
478
+ createTask(parentId: string, task: TaskDefinition): Promise<WorkItem>;
479
+ createTasksBulk(parentId: string, tasks: TaskDefinition[]): Promise<WorkItem[]>;
480
+ getPlatformMetadata(): PlatformMetadata;
481
+
482
+ // Optional methods
483
+ getWorkItem?(id: string): Promise<WorkItem | null>;
484
+ testConnection?(): Promise<boolean>;
485
+ getChildren?(parentId: string): Promise<WorkItem[]>;
486
+ updateWorkItem?(id: string, updates: Partial<WorkItem>): Promise<WorkItem>;
487
+ deleteWorkItem?(id: string): Promise<boolean>;
488
+ }
489
+ ```
490
+
491
+ ### Steps to Add a Platform
492
+
493
+ #### 1. Create Adapter Class
494
+
495
+ ```typescript
496
+ // src/platforms/adapters/jira/jira.adapter.ts
497
+ import { IPlatformAdapter } from "@platforms/interfaces/platform.interface";
498
+
499
+ export interface JiraConfig extends PlatformConfig {
500
+ baseUrl: string;
501
+ email: string;
502
+ apiToken: string;
503
+ projectKey: string;
504
+ }
505
+
506
+ export class JiraAdapter implements IPlatformAdapter {
507
+ constructor(private config: JiraConfig) {}
508
+
509
+ async authenticate(config?: AuthConfig): Promise<void> {
510
+ // Implement authentication
511
+ }
512
+
513
+ async queryWorkItems(filter: FilterCriteria): Promise<WorkItem[]> {
514
+ // Convert filter to JQL
515
+ // Query Jira API
516
+ // Convert results to WorkItem[]
517
+ }
518
+
519
+ async createTask(parentId: string, task: TaskDefinition): Promise<WorkItem> {
520
+ // Create subtask in Jira
521
+ }
522
+
523
+ // ... implement other methods
524
+ }
525
+ ```
526
+
527
+ #### 2. Add to Platform Factory
528
+
529
+ ```typescript
530
+ // src/platforms/platform-factory.ts
531
+ import { JiraAdapter } from "./adapters/jira/jira.adapter";
532
+
533
+ export class PlatformFactory {
534
+ static create(type: PlatformType, config?: PlatformConfig): IPlatformAdapter {
535
+ switch (type) {
536
+ case "jira":
537
+ return new JiraAdapter(config as JiraConfig);
538
+ // ... other cases
539
+ }
540
+ }
541
+ }
542
+ ```
543
+
544
+ #### 3. Add Configuration Helper
545
+
546
+ ```typescript
547
+ // src/config/jira.config.ts
548
+ export async function getJiraConfigInteractive(): Promise<JiraConfig> {
549
+ const answers = await inquirer.prompt([
550
+ {
551
+ type: "input",
552
+ name: "baseUrl",
553
+ message: "Jira base URL (e.g., https://yourcompany.atlassian.net):",
554
+ },
555
+ {
556
+ type: "input",
557
+ name: "email",
558
+ message: "Email:",
559
+ },
560
+ {
561
+ type: "password",
562
+ name: "apiToken",
563
+ message: "API Token:",
564
+ },
565
+ {
566
+ type: "input",
567
+ name: "projectKey",
568
+ message: "Project key:",
569
+ },
570
+ ]);
571
+
572
+ return {
573
+ type: "jira",
574
+ ...answers,
575
+ };
576
+ }
577
+ ```
578
+
579
+ #### 4. Update Types
580
+
581
+ ```typescript
582
+ // src/platforms/interfaces/platform.interface.ts
583
+ export type PlatformType =
584
+ | "mock"
585
+ | "azure-devops"
586
+ | "jira" // Add new type
587
+ | "github";
588
+ ```
589
+
590
+ #### 5. Write Tests
591
+
592
+ ```typescript
593
+ // src/platforms/adapters/jira/jira.test.ts
594
+ describe("JiraAdapter", () => {
595
+ test("should authenticate with valid credentials", async () => {
596
+ // Test implementation
597
+ });
598
+
599
+ test("should query issues with JQL", async () => {
600
+ // Test implementation
601
+ });
602
+
603
+ // More tests...
604
+ });
605
+ ```
606
+
607
+ #### 6. Add Documentation
608
+
609
+ Update this guide with:
610
+ - Setup instructions
611
+ - Configuration options
612
+ - Field mappings
613
+ - Examples
614
+ - Troubleshooting
615
+
616
+ ### Field Mapping
617
+
618
+ Each platform has different field names. Map them to the common `WorkItem` interface:
619
+
620
+ ```typescript
621
+ private convertToWorkItem(jiraIssue: JiraIssue): WorkItem {
622
+ return {
623
+ id: jiraIssue.key, // PROJ-123
624
+ title: jiraIssue.fields.summary,
625
+ type: this.mapIssueType(jiraIssue.fields.issuetype.name),
626
+ state: jiraIssue.fields.status.name,
627
+ assignedTo: jiraIssue.fields.assignee?.emailAddress,
628
+ estimation: jiraIssue.fields.customfield_10016, // Story points
629
+ tags: jiraIssue.fields.labels,
630
+ description: jiraIssue.fields.description,
631
+ priority: this.mapPriority(jiraIssue.fields.priority.name),
632
+ platformSpecific: jiraIssue, // Keep original data
633
+ };
634
+ }
635
+ ```
636
+
637
+ ### Contributing
638
+
639
+ See [CONTRIBUTING.md](../CONTRIBUTING.md) for guidelines on submitting new platform adapters.
640
+
641
+ ---
642
+
643
+ ## Platform Comparison
644
+
645
+ | Feature | Azure DevOps | Mock | Jira | GitHub |
646
+ |---------|--------------|------|------|--------|
647
+ | Authentication | PAT | None | API Token | PAT |
648
+ | Work Items | ✅ | ✅ | 🚧 | 🚧 |
649
+ | Custom Fields | ✅ | ✅ | 🚧 | 🚧 |
650
+ | Bulk Creation | ✅ | ✅ | 🚧 | 🚧 |
651
+ | Work Item Links | ✅ | ✅ | 🚧 | 🚧 |
652
+ | Query Language | WIQL | Simple | JQL | - |
653
+ | Real-time | ✅ | ✅ | 🚧 | 🚧 |
654
+
655
+ ---
656
+
657
+ ## See Also
658
+
659
+ - [Auth Guide](./Auth-Guide.md) - Credential storage, profile resolution, and CI/CD setup
660
+ - [CLI Reference](./Cli-Reference.md) - Command-line usage
661
+ - [Template Reference](./Template-Reference.md) - Template schema
662
+ - [Examples](../examples/) - Real-world examples