specweave 0.30.0 → 0.30.2

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 (92) hide show
  1. package/dist/plugins/specweave-ado/lib/ado-permission-gate.d.ts +113 -0
  2. package/dist/plugins/specweave-ado/lib/ado-permission-gate.d.ts.map +1 -0
  3. package/dist/plugins/specweave-ado/lib/ado-permission-gate.js +169 -0
  4. package/dist/plugins/specweave-ado/lib/ado-permission-gate.js.map +1 -0
  5. package/dist/plugins/specweave-ado/lib/ado-profile-resolver.d.ts +137 -0
  6. package/dist/plugins/specweave-ado/lib/ado-profile-resolver.d.ts.map +1 -0
  7. package/dist/plugins/specweave-ado/lib/ado-profile-resolver.js +200 -0
  8. package/dist/plugins/specweave-ado/lib/ado-profile-resolver.js.map +1 -0
  9. package/dist/src/cli/commands/sync-scheduled.d.ts.map +1 -1
  10. package/dist/src/cli/commands/sync-scheduled.js +1 -0
  11. package/dist/src/cli/commands/sync-scheduled.js.map +1 -1
  12. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.d.ts +3 -1
  13. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.d.ts.map +1 -1
  14. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.js +9 -7
  15. package/dist/src/cli/helpers/issue-tracker/sync-config-writer.js.map +1 -1
  16. package/dist/src/core/background/job-launcher.d.ts +5 -0
  17. package/dist/src/core/background/job-launcher.d.ts.map +1 -1
  18. package/dist/src/core/background/job-launcher.js +14 -3
  19. package/dist/src/core/background/job-launcher.js.map +1 -1
  20. package/dist/src/core/errors/index.d.ts +174 -0
  21. package/dist/src/core/errors/index.d.ts.map +1 -0
  22. package/dist/src/core/errors/index.js +238 -0
  23. package/dist/src/core/errors/index.js.map +1 -0
  24. package/dist/src/core/scheduler/session-sync-executor.d.ts +3 -0
  25. package/dist/src/core/scheduler/session-sync-executor.d.ts.map +1 -1
  26. package/dist/src/core/scheduler/session-sync-executor.js +27 -2
  27. package/dist/src/core/scheduler/session-sync-executor.js.map +1 -1
  28. package/dist/src/core/specs/spec-metadata-manager.d.ts +5 -1
  29. package/dist/src/core/specs/spec-metadata-manager.d.ts.map +1 -1
  30. package/dist/src/core/specs/spec-metadata-manager.js +4 -2
  31. package/dist/src/core/specs/spec-metadata-manager.js.map +1 -1
  32. package/dist/src/importers/item-converter.d.ts +5 -0
  33. package/dist/src/importers/item-converter.d.ts.map +1 -1
  34. package/dist/src/importers/item-converter.js +15 -4
  35. package/dist/src/importers/item-converter.js.map +1 -1
  36. package/dist/src/integrations/ado/ado-client-factory.d.ts +102 -0
  37. package/dist/src/integrations/ado/ado-client-factory.d.ts.map +1 -0
  38. package/dist/src/integrations/ado/ado-client-factory.js +115 -0
  39. package/dist/src/integrations/ado/ado-client-factory.js.map +1 -0
  40. package/dist/src/integrations/ado/ado-client.d.ts +24 -1
  41. package/dist/src/integrations/ado/ado-client.d.ts.map +1 -1
  42. package/dist/src/integrations/ado/ado-client.js +48 -17
  43. package/dist/src/integrations/ado/ado-client.js.map +1 -1
  44. package/dist/src/integrations/ado/ado-pat-provider.d.ts +45 -0
  45. package/dist/src/integrations/ado/ado-pat-provider.d.ts.map +1 -0
  46. package/dist/src/integrations/ado/ado-pat-provider.js +70 -0
  47. package/dist/src/integrations/ado/ado-pat-provider.js.map +1 -0
  48. package/dist/src/integrations/jira/jira-client.d.ts +5 -0
  49. package/dist/src/integrations/jira/jira-client.d.ts.map +1 -1
  50. package/dist/src/integrations/jira/jira-client.js +24 -13
  51. package/dist/src/integrations/jira/jira-client.js.map +1 -1
  52. package/dist/src/integrations/jira/jira-incremental-mapper.d.ts +5 -0
  53. package/dist/src/integrations/jira/jira-incremental-mapper.d.ts.map +1 -1
  54. package/dist/src/integrations/jira/jira-incremental-mapper.js +13 -2
  55. package/dist/src/integrations/jira/jira-incremental-mapper.js.map +1 -1
  56. package/dist/src/integrations/jira/jira-mapper.d.ts +5 -0
  57. package/dist/src/integrations/jira/jira-mapper.d.ts.map +1 -1
  58. package/dist/src/integrations/jira/jira-mapper.js +14 -3
  59. package/dist/src/integrations/jira/jira-mapper.js.map +1 -1
  60. package/dist/src/sync/sync-coordinator.d.ts +11 -0
  61. package/dist/src/sync/sync-coordinator.d.ts.map +1 -1
  62. package/dist/src/sync/sync-coordinator.js +80 -3
  63. package/dist/src/sync/sync-coordinator.js.map +1 -1
  64. package/dist/src/testing/test-generator.d.ts +5 -0
  65. package/dist/src/testing/test-generator.d.ts.map +1 -1
  66. package/dist/src/testing/test-generator.js +17 -6
  67. package/dist/src/testing/test-generator.js.map +1 -1
  68. package/dist/src/utils/fs-native.d.ts +5 -2
  69. package/dist/src/utils/fs-native.d.ts.map +1 -1
  70. package/dist/src/utils/fs-native.js +6 -2
  71. package/dist/src/utils/fs-native.js.map +1 -1
  72. package/dist/src/utils/logger.d.ts +5 -1
  73. package/dist/src/utils/logger.d.ts.map +1 -1
  74. package/dist/src/utils/logger.js +6 -3
  75. package/dist/src/utils/logger.js.map +1 -1
  76. package/package.json +1 -1
  77. package/plugins/specweave/lib/vendor/utils/fs-native.d.ts +5 -2
  78. package/plugins/specweave/lib/vendor/utils/fs-native.js +6 -2
  79. package/plugins/specweave/lib/vendor/utils/fs-native.js.map +1 -1
  80. package/plugins/specweave/lib/vendor/utils/logger.d.ts +5 -1
  81. package/plugins/specweave/lib/vendor/utils/logger.js +6 -3
  82. package/plugins/specweave/lib/vendor/utils/logger.js.map +1 -1
  83. package/plugins/specweave-ado/agents/ado-manager/AGENT.md +62 -4
  84. package/plugins/specweave-ado/commands/specweave-ado-close-workitem.md +197 -12
  85. package/plugins/specweave-ado/commands/specweave-ado-create-workitem.md +148 -24
  86. package/plugins/specweave-ado/commands/specweave-ado-sync.md +170 -77
  87. package/plugins/specweave-ado/lib/ado-permission-gate.js +127 -0
  88. package/plugins/specweave-ado/lib/ado-permission-gate.ts +231 -0
  89. package/plugins/specweave-ado/lib/ado-profile-resolver.js +153 -0
  90. package/plugins/specweave-ado/lib/ado-profile-resolver.ts +323 -0
  91. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +84 -0
  92. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +126 -0
@@ -13,40 +13,225 @@ description: Close Azure DevOps work item when increment complete
13
13
 
14
14
  ## Command Behavior
15
15
 
16
- When user runs this command, invoke `ado-manager` agent to:
16
+ When user runs this command, Claude should:
17
17
 
18
- 1. Validate increment is 100% complete (all tasks done)
19
- 2. Generate completion summary
20
- 3. PATCH work item state Closed
21
- 4. POST final comment with deliverables
22
- 5. Display confirmation
18
+ ### 1. Check Permission Gate (MANDATORY FIRST STEP)
19
+
20
+ **Before ANY ADO API calls**, check if status updates are allowed:
21
+
22
+ ```typescript
23
+ // Read .specweave/config.json
24
+ const config = JSON.parse(await fs.readFile('.specweave/config.json', 'utf-8'));
25
+ const canUpdateExternal = config?.sync?.settings?.canUpdateExternalItems ?? false;
26
+ const canUpdateStatus = config?.sync?.settings?.canUpdateStatus ?? false;
27
+
28
+ // Close requires both permissions (write to close, status to change state)
29
+ if (!canUpdateExternal || !canUpdateStatus) {
30
+ const missing = [];
31
+ if (!canUpdateExternal) missing.push('canUpdateExternalItems');
32
+ if (!canUpdateStatus) missing.push('canUpdateStatus');
33
+
34
+ console.log(`
35
+ ❌ Permission Denied
36
+
37
+ Closing ADO work items requires these permissions:
38
+ ${missing.map(p => ` - sync.settings.${p} = false (required: true)`).join('\n')}
39
+
40
+ To enable, update .specweave/config.json:
41
+ {
42
+ "sync": {
43
+ "settings": {
44
+ "canUpdateExternalItems": true,
45
+ "canUpdateStatus": true
46
+ }
47
+ }
48
+ }
49
+ `);
50
+ return;
51
+ }
52
+ ```
53
+
54
+ ### 2. Resolve ADO Profile
55
+
56
+ Use the increment's stored profile or fall back to global activeProfile:
57
+
58
+ ```typescript
59
+ // Load increment metadata
60
+ const metadataPath = `.specweave/increments/${incrementId}/metadata.json`;
61
+ const metadata = JSON.parse(await fs.readFile(metadataPath, 'utf-8'));
62
+
63
+ // Priority: increment profile > global activeProfile
64
+ let profileName = metadata?.external_sync?.ado?.profile;
65
+ if (!profileName) {
66
+ profileName = config?.sync?.activeProfile;
67
+ }
68
+
69
+ // Validate profile exists
70
+ const profileConfig = config?.sync?.profiles?.[profileName];
71
+ if (!profileConfig || profileConfig.provider !== 'ado') {
72
+ console.log(`❌ ADO profile "${profileName}" not found`);
73
+ return;
74
+ }
75
+
76
+ const { organization, project } = profileConfig.config;
77
+ ```
78
+
79
+ ### 3. Validate Increment Completion
80
+
81
+ Before closing, verify the increment is actually complete:
82
+
83
+ ```typescript
84
+ // Check tasks.md for completion
85
+ const tasksPath = `.specweave/increments/${incrementId}/tasks.md`;
86
+ const tasksContent = await fs.readFile(tasksPath, 'utf-8');
87
+
88
+ const totalTasks = (tasksContent.match(/### T-\d+/g) || []).length;
89
+ const completedTasks = (tasksContent.match(/\[x\] completed/gi) || []).length;
90
+
91
+ if (completedTasks < totalTasks) {
92
+ console.log(`
93
+ ⚠️ Increment not complete
94
+
95
+ Tasks: ${completedTasks}/${totalTasks} completed
96
+ Cannot close ADO work item until all tasks are done.
97
+
98
+ Complete remaining tasks first, then re-run this command.
99
+ `);
100
+ return;
101
+ }
102
+ ```
103
+
104
+ ### 4. Invoke ADO Manager Agent
23
105
 
24
- **Agent Invocation**:
25
106
  ```
26
107
  Use Task tool with subagent_type: "specweave-ado:ado-manager:ado-manager"
27
108
 
28
- Prompt: "Close ADO work item for completed increment 0005-payment-integration.
109
+ Prompt: "Close ADO work item for completed increment {increment-id}.
110
+
111
+ IMPORTANT:
112
+ - Permission verified: canUpdateExternalItems=true, canUpdateStatus=true
113
+ - Using profile: {profileName} (org: {organization}, project: {project})
29
114
 
30
115
  Steps:
31
116
  1. Validate: All tasks in tasks.md complete
32
117
  2. Generate: Completion summary (duration, deliverables)
33
- 3. Load work item ID from increment-metadata.json
34
- 4. PATCH work item: state = Closed
118
+ 3. Load work item ID from metadata.json
119
+ 4. PATCH work item: state = Closed (using org: {organization}, project: {project})
35
120
  5. POST final comment with summary
36
- 6. Display: Closure confirmation"
121
+ 6. Display: Closure confirmation with profile used"
122
+ ```
123
+
124
+ ### 5. Display Result
125
+
126
+ ```
127
+ ✅ Closed ADO Work Item
128
+
129
+ Work Item: #{workItemId}
130
+ Profile: {profileName}
131
+ Organization: {organization}
132
+ Project: {project}
133
+
134
+ Increment: {increment-id}
135
+ Status: 100% complete ({total}/{total} tasks)
136
+ Duration: {days} days
137
+
138
+ Summary posted to ADO work item
139
+ URL: https://dev.azure.com/{organization}/{project}/_workitems/edit/{workItemId}
37
140
  ```
38
141
 
39
142
  ---
40
143
 
144
+ ## Permission Requirements
145
+
146
+ This command requires **both** permissions:
147
+
148
+ | Permission | Required | Purpose |
149
+ |------------|----------|---------|
150
+ | canUpdateExternalItems | true | Write to ADO work item |
151
+ | canUpdateStatus | true | Change work item state to Closed |
152
+
153
+ ---
154
+
41
155
  ## Example Output
42
156
 
157
+ ### Success
158
+
43
159
  ```
160
+ User: /specweave-ado:close-workitem 0005-payment-integration
161
+
162
+ Claude:
163
+ Checking permissions...
164
+ canUpdateExternalItems: true
165
+ canUpdateStatus: true
166
+
167
+ Resolving ADO profile...
168
+ Using: ado-nova-x-sandbox (from increment)
169
+ Organization: nova-systems
170
+ Project: Nova X Sandbox
171
+
172
+ Validating completion...
173
+ Tasks: 10/10 complete
174
+
175
+ Closing work item...
176
+
44
177
  ✅ Closed ADO Epic #12345
45
178
 
179
+ Profile: ado-nova-x-sandbox
46
180
  Increment: 0005-payment-integration
47
181
  Status: 100% complete (10/10 tasks)
48
182
  Duration: 3 days
49
183
 
50
184
  Summary posted to ADO work item
51
- URL: https://dev.azure.com/myorg/MyProject/_workitems/edit/12345
185
+ URL: https://dev.azure.com/nova-systems/Nova%20X%20Sandbox/_workitems/edit/12345
186
+ ```
187
+
188
+ ### Permission Denied
189
+
190
+ ```
191
+ User: /specweave-ado:close-workitem 0005
192
+
193
+ Claude:
194
+ Checking permissions...
195
+ canUpdateExternalItems: false
196
+ canUpdateStatus: false
197
+
198
+ ❌ Permission Denied
199
+
200
+ Closing ADO work items requires:
201
+ - sync.settings.canUpdateExternalItems = true
202
+ - sync.settings.canUpdateStatus = true
203
+
204
+ Update .specweave/config.json to enable these permissions.
205
+ ```
206
+
207
+ ### Incomplete Increment
208
+
209
+ ```
210
+ User: /specweave-ado:close-workitem 0005
211
+
212
+ Claude:
213
+ Checking permissions...
214
+ canUpdateExternalItems: true
215
+ canUpdateStatus: true
216
+
217
+ Validating completion...
218
+
219
+ ⚠️ Increment not complete
220
+
221
+ Tasks: 6/10 completed
222
+ Cannot close ADO work item until all tasks are done.
223
+
224
+ Complete remaining tasks:
225
+ - T-007: Add refund functionality
226
+ - T-008: Implement subscriptions
227
+ - T-009: Add analytics
228
+ - T-010: Security audit
52
229
  ```
230
+
231
+ ---
232
+
233
+ ## Related
234
+
235
+ - `/specweave-ado:create-workitem` - Create ADO work item
236
+ - `/specweave-ado:sync` - Sync progress to ADO
237
+ - `/specweave-ado:status` - Check sync status (read-only, always allowed)
@@ -15,39 +15,163 @@ description: Create Azure DevOps work item from SpecWeave increment
15
15
 
16
16
  When user runs this command, Claude should:
17
17
 
18
- 1. **Validate Prerequisites**:
19
- - Check ADO plugin installed
20
- - Check AZURE_DEVOPS_PAT environment variable set
21
- - Check ADO configured in .specweave/config.json
18
+ ### 1. Check Permission Gate (MANDATORY FIRST STEP)
19
+
20
+ **Before ANY ADO API calls**, check if write operations are allowed:
21
+
22
+ ```typescript
23
+ // Read .specweave/config.json
24
+ const config = JSON.parse(await fs.readFile('.specweave/config.json', 'utf-8'));
25
+ const canUpdateExternal = config?.sync?.settings?.canUpdateExternalItems ?? false;
26
+
27
+ if (!canUpdateExternal) {
28
+ // STOP HERE - Permission denied
29
+ console.log(`
30
+ ❌ Permission Denied
31
+
32
+ ADO write operations are disabled.
33
+ Setting: sync.settings.canUpdateExternalItems = false
34
+
35
+ To enable, update .specweave/config.json:
36
+ {
37
+ "sync": {
38
+ "settings": {
39
+ "canUpdateExternalItems": true
40
+ }
41
+ }
42
+ }
43
+
44
+ Or run: jq '.sync.settings.canUpdateExternalItems = true' .specweave/config.json > tmp && mv tmp .specweave/config.json
45
+ `);
46
+ return; // DO NOT proceed to create work item
47
+ }
48
+ ```
49
+
50
+ If `canUpdateExternalItems` is `false`, display the error and **STOP**. Do not invoke the ADO Manager agent.
51
+
52
+ ### 2. Resolve ADO Profile
53
+
54
+ Use the increment's stored profile or fall back to global activeProfile:
55
+
56
+ ```typescript
57
+ // Load increment metadata
58
+ const metadata = JSON.parse(await fs.readFile(
59
+ `.specweave/increments/${incrementId}/metadata.json`, 'utf-8'
60
+ ));
61
+
62
+ // Check for increment-specific profile
63
+ let profileName = metadata?.external_sync?.ado?.profile;
64
+
65
+ // Fall back to global activeProfile
66
+ if (!profileName) {
67
+ profileName = config?.sync?.activeProfile;
68
+ }
69
+
70
+ // Get profile config
71
+ const profileConfig = config?.sync?.profiles?.[profileName];
72
+ if (!profileConfig || profileConfig.provider !== 'ado') {
73
+ console.log(`❌ Profile "${profileName}" not found or not an ADO profile`);
74
+ return;
75
+ }
76
+
77
+ const { organization, project } = profileConfig.config;
78
+ ```
79
+
80
+ ### 3. Validate Prerequisites
81
+
82
+ - Check ADO plugin installed
83
+ - Check AZURE_DEVOPS_PAT environment variable set
84
+ - Check ADO profile has organization and project
85
+
86
+ ### 4. Invoke ADO Manager Agent
87
+
88
+ ```
89
+ Use Task tool with subagent_type: "specweave-ado:ado-manager:ado-manager"
90
+
91
+ Prompt: "Create ADO work item for increment {increment-id}.
92
+
93
+ IMPORTANT: Permission already verified (canUpdateExternalItems=true).
94
+ Use profile: {profileName} (org: {organization}, project: {project})
95
+
96
+ Steps:
97
+ 1. Read .specweave/increments/{increment-id}/spec.md
98
+ 2. Extract title and description
99
+ 3. Use ADO organization: {organization}, project: {project}
100
+ 4. Create work item via ADO REST API
101
+ 5. Store work item ID in increment metadata.json
102
+ 6. Store profile name in metadata.json external_sync.ado.profile
103
+ 7. Display: Work Item ID, URL, and confirmation"
104
+ ```
105
+
106
+ ### 5. Display Result
107
+
108
+ ```
109
+ ✅ Created ADO Epic
110
+
111
+ Work Item: #12345
112
+ URL: https://dev.azure.com/{organization}/{project}/_workitems/edit/12345
113
+ Profile: {profileName}
114
+
115
+ Linked to increment: {increment-id}
116
+ ```
22
117
 
23
- 2. **Invoke ADO Manager Agent**:
24
- ```
25
- Use Task tool with subagent_type: "specweave-ado:ado-manager:ado-manager"
118
+ ---
26
119
 
27
- Prompt: "Create ADO work item for increment 0005-payment-integration.
120
+ ## Permission Denied Output
28
121
 
29
- Steps:
30
- 1. Read .specweave/increments/0005-payment-integration/spec.md
31
- 2. Extract title and description
32
- 3. Load ADO config from .specweave/config.json
33
- 4. Create work item via ADO REST API
34
- 5. Store work item ID in increment-metadata.json
35
- 6. Display: Work Item ID, URL, and confirmation"
36
- ```
122
+ If `canUpdateExternalItems` is false:
37
123
 
38
- 3. **Display Result**:
39
- ```
40
- ✅ Created ADO Epic
124
+ ```
125
+ ❌ Permission Denied: ADO Write Operations Disabled
41
126
 
42
- Work Item: #12345
43
- URL: https://dev.azure.com/myorg/MyProject/_workitems/edit/12345
127
+ Your configuration prevents creating/updating ADO work items.
44
128
 
45
- Linked to increment: 0005-payment-integration
46
- ```
129
+ Current setting:
130
+ sync.settings.canUpdateExternalItems = false
131
+
132
+ To enable ADO writes:
133
+ 1. Edit .specweave/config.json
134
+ 2. Set sync.settings.canUpdateExternalItems to true
135
+ 3. Re-run this command
136
+
137
+ This setting was configured during 'specweave init'.
138
+ ```
47
139
 
48
140
  ---
49
141
 
50
142
  ## Example Usage
51
143
 
52
144
  ```
53
- User: /specweave-ado:create-workitem 0005
145
+ User: /specweave-ado:create-workitem 0005-payment-integration
146
+
147
+ # If permission granted:
148
+ Claude: Checking ADO permissions...
149
+ ✓ canUpdateExternalItems: true
150
+
151
+ Resolving ADO profile...
152
+ ✓ Using profile: ado-nova-x-sandbox (from increment)
153
+ ✓ Organization: nova-systems
154
+ ✓ Project: Nova X Sandbox
155
+
156
+ Creating work item...
157
+ [Invokes ADO Manager Agent]
158
+
159
+ ✅ Created ADO Epic #12345
160
+ URL: https://dev.azure.com/nova-systems/Nova%20X%20Sandbox/_workitems/edit/12345
161
+
162
+ # If permission denied:
163
+ Claude: Checking ADO permissions...
164
+ ❌ Permission Denied
165
+
166
+ sync.settings.canUpdateExternalItems = false
167
+
168
+ To enable: Edit .specweave/config.json and set canUpdateExternalItems to true
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Related
174
+
175
+ - `/specweave-ado:sync` - Sync progress to existing work item
176
+ - `/specweave-ado:status` - Check ADO sync status (read-only, always allowed)
177
+ - `/specweave-ado:close-workitem` - Close work item when complete