specweave 0.30.14 → 0.30.16

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 (52) hide show
  1. package/README.md +32 -0
  2. package/bin/specweave.js +28 -0
  3. package/dist/src/cli/commands/commits.d.ts +7 -0
  4. package/dist/src/cli/commands/commits.d.ts.map +1 -0
  5. package/dist/src/cli/commands/commits.js +42 -0
  6. package/dist/src/cli/commands/commits.js.map +1 -0
  7. package/dist/src/cli/commands/living-docs.d.ts +29 -0
  8. package/dist/src/cli/commands/living-docs.d.ts.map +1 -0
  9. package/dist/src/cli/commands/living-docs.js +350 -0
  10. package/dist/src/cli/commands/living-docs.js.map +1 -0
  11. package/dist/src/cli/helpers/ado-area-selector.js +1 -1
  12. package/dist/src/cli/helpers/ado-area-selector.js.map +1 -1
  13. package/dist/src/core/background/index.d.ts +2 -2
  14. package/dist/src/core/background/index.d.ts.map +1 -1
  15. package/dist/src/core/background/index.js +1 -1
  16. package/dist/src/core/background/index.js.map +1 -1
  17. package/dist/src/core/living-docs/living-docs-sync.d.ts +34 -10
  18. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  19. package/dist/src/core/living-docs/living-docs-sync.js +223 -32
  20. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  21. package/dist/src/importers/ado-importer.js +2 -2
  22. package/dist/src/importers/ado-importer.js.map +1 -1
  23. package/dist/src/importers/item-converter.d.ts +6 -1
  24. package/dist/src/importers/item-converter.d.ts.map +1 -1
  25. package/dist/src/importers/item-converter.js +15 -2
  26. package/dist/src/importers/item-converter.js.map +1 -1
  27. package/dist/src/integrations/ado/ado-pat-provider.d.ts +3 -3
  28. package/dist/src/integrations/ado/ado-pat-provider.js +3 -3
  29. package/dist/src/living-docs/epic-id-allocator.d.ts +1 -1
  30. package/dist/src/living-docs/epic-id-allocator.js +1 -1
  31. package/dist/src/living-docs/fs-id-allocator.d.ts +1 -1
  32. package/dist/src/living-docs/fs-id-allocator.js +1 -1
  33. package/dist/src/utils/auth-helpers.d.ts +23 -0
  34. package/dist/src/utils/auth-helpers.d.ts.map +1 -1
  35. package/dist/src/utils/auth-helpers.js +51 -0
  36. package/dist/src/utils/auth-helpers.js.map +1 -1
  37. package/dist/src/utils/feature-id-collision.d.ts +48 -5
  38. package/dist/src/utils/feature-id-collision.d.ts.map +1 -1
  39. package/dist/src/utils/feature-id-collision.js +251 -19
  40. package/dist/src/utils/feature-id-collision.js.map +1 -1
  41. package/dist/src/utils/validators/ado-validator.js +2 -2
  42. package/dist/src/utils/validators/ado-validator.js.map +1 -1
  43. package/package.json +1 -2
  44. package/plugins/specweave/commands/specweave-living-docs.md +321 -0
  45. package/plugins/specweave/hooks/v2/handlers/github-sync-handler.sh +10 -1
  46. package/plugins/specweave/hooks/v2/handlers/living-docs-handler.sh +10 -1
  47. package/plugins/specweave-ado/agents/ado-manager/AGENT.md +58 -0
  48. package/plugins/specweave-ado/commands/pull.md +30 -0
  49. package/plugins/specweave-ado/commands/push.md +30 -0
  50. package/plugins/specweave-ado/commands/sync.md +31 -0
  51. package/plugins/specweave-github/agents/github-manager/AGENT.md +22 -0
  52. package/plugins/specweave-jira/agents/jira-manager/AGENT.md +30 -0
@@ -0,0 +1,321 @@
1
+ ---
2
+ name: specweave:living-docs
3
+ description: Launch or resume Living Docs Builder independently. Generates documentation from codebase analysis with AI-powered insights.
4
+ usage: /specweave:living-docs [--resume <jobId>] [--depth <level>] [--priority <modules>] [--sources <folders>] [--depends-on <jobIds>] [--foreground]
5
+ ---
6
+
7
+ # Living Docs Builder (Standalone)
8
+
9
+ **Usage**: `/specweave:living-docs [options]`
10
+
11
+ ---
12
+
13
+ ## Purpose
14
+
15
+ Launch the Living Docs Builder independently of `specweave init`. This is essential for:
16
+ - **Resuming after crash** - Claude Code crashed after init, need to restart living docs
17
+ - **On-demand analysis** - Re-analyze codebase after major changes
18
+ - **Large brownfield projects** - Run targeted analysis on specific modules
19
+ - **CI/CD integration** - Automate documentation generation
20
+
21
+ ---
22
+
23
+ ## Command Options
24
+
25
+ | Option | Description |
26
+ |--------|-------------|
27
+ | (none) | Interactive mode - prompts for configuration |
28
+ | `--resume <jobId>` | Resume orphaned/paused living-docs job |
29
+ | `--depth <level>` | Analysis depth: `quick`, `standard`, `deep-native`, `deep-api` |
30
+ | `--priority <modules>` | Priority modules (comma-separated): `auth,payments,api` |
31
+ | `--sources <folders>` | Additional doc folders (comma-separated): `docs/,wiki/` |
32
+ | `--depends-on <jobIds>` | Wait for jobs before starting (comma-separated) |
33
+ | `--foreground` | Run in current session instead of background |
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ### Launch New Analysis (Interactive)
40
+
41
+ ```bash
42
+ /specweave:living-docs
43
+
44
+ # Prompts for:
45
+ # 1. Analysis depth (quick/standard/deep-native/deep-api)
46
+ # 2. Priority modules to focus on
47
+ # 3. Additional documentation sources
48
+ # 4. Confirmation to launch
49
+ ```
50
+
51
+ ### Resume After Crash
52
+
53
+ ```bash
54
+ # Check for orphaned jobs first
55
+ /specweave:jobs
56
+
57
+ # If you see an orphaned living-docs-builder job:
58
+ /specweave:living-docs --resume abc12345
59
+
60
+ # Or let it auto-detect:
61
+ /specweave:living-docs
62
+ # → "Found orphaned job abc12345. Resume? [Y/n]"
63
+ ```
64
+
65
+ ### Quick Analysis (Non-Interactive)
66
+
67
+ ```bash
68
+ # Quick scan - 5-10 minutes
69
+ /specweave:living-docs --depth quick
70
+
71
+ # Standard analysis - 15-30 minutes
72
+ /specweave:living-docs --depth standard --priority auth,payments
73
+
74
+ # AI-powered deep analysis (FREE with MAX subscription)
75
+ /specweave:living-docs --depth deep-native --priority core,api
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Analysis Depths
81
+
82
+ | Depth | Duration | What It Does | Cost |
83
+ |-------|----------|--------------|------|
84
+ | `quick` | ~5-10 min | Structure scan, tech detection, imports map | Free |
85
+ | `standard` | ~15-30 min | Module analysis, exports, dependencies | Free |
86
+ | `deep-native` | Progress-based | AI analysis via Claude Code CLI | FREE (MAX) |
87
+ | `deep-api` | Progress-based | AI analysis via API key | API costs |
88
+
89
+ ### Deep-Native (Recommended for MAX Users)
90
+
91
+ Uses your Claude MAX subscription via `claude --print`:
92
+ - **No extra cost** - included in MAX
93
+ - Runs in **background** - survives terminal close
94
+ - **Checkpoint/resume** - can resume from any phase
95
+ - Uses **Opus 4.5** for best quality
96
+
97
+ ```bash
98
+ /specweave:living-docs --depth deep-native
99
+
100
+ # Monitor progress:
101
+ /specweave:jobs --follow <jobId>
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Implementation Steps
107
+
108
+ When this command is invoked:
109
+
110
+ ### Step 1: Check for Orphaned Jobs
111
+
112
+ ```typescript
113
+ import { getOrphanedJobs, getJobManager } from '../../../src/core/background/job-launcher.js';
114
+
115
+ const orphaned = getOrphanedJobs(projectPath).filter(j => j.type === 'living-docs-builder');
116
+ if (orphaned.length > 0) {
117
+ // Prompt: "Found orphaned job {id}. Resume? [Y/n]"
118
+ // If yes: resume job
119
+ // If no: ask if they want to start fresh
120
+ }
121
+ ```
122
+
123
+ ### Step 2: Collect Configuration (if not --resume)
124
+
125
+ If no `--resume` flag and no auto-resume:
126
+
127
+ ```typescript
128
+ import { collectLivingDocsInputs } from '../../../src/cli/helpers/init/living-docs-preflight.js';
129
+
130
+ const result = await collectLivingDocsInputs({
131
+ projectPath,
132
+ language: 'en',
133
+ isCi: hasFlags, // Skip prompts if flags provided
134
+ });
135
+ ```
136
+
137
+ Override with flags:
138
+ - `--depth` → `result.userInputs.analysisDepth`
139
+ - `--priority` → `result.userInputs.priorityAreas`
140
+ - `--sources` → `result.userInputs.additionalSources`
141
+
142
+ ### Step 3: Launch Job
143
+
144
+ ```typescript
145
+ import { launchLivingDocsJob } from '../../../src/core/background/job-launcher.js';
146
+
147
+ const { job, pid, isBackground } = await launchLivingDocsJob({
148
+ projectPath,
149
+ userInputs: result.userInputs,
150
+ dependsOn: dependsOnJobIds,
151
+ foreground: hasForegroundFlag,
152
+ });
153
+ ```
154
+
155
+ ### Step 4: Display Status
156
+
157
+ ```
158
+ ✅ Living Docs Builder launched!
159
+
160
+ Job ID: ldb-abc12345
161
+ Depth: deep-native (Claude Code Opus 4.5)
162
+ Priority: auth, payments, api
163
+ PID: 45678
164
+
165
+ Monitor: /specweave:jobs --follow ldb-abc12345
166
+ Logs: /specweave:jobs --logs ldb-abc12345
167
+
168
+ 💡 This job runs in background and survives terminal close.
169
+ Output will be saved to:
170
+ - .specweave/docs/SUGGESTIONS.md
171
+ - .specweave/docs/ENTERPRISE-HEALTH.md
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Resume Behavior
177
+
178
+ When resuming a job:
179
+
180
+ 1. **Load checkpoint** from `.specweave/state/jobs/<jobId>/checkpoints/`
181
+ 2. **Skip completed phases**:
182
+ - `waiting` → dependency waiting
183
+ - `discovery` → codebase scanning
184
+ - `foundation` → high-level docs
185
+ - `integration` → work item matching
186
+ - `deep-dive` → module analysis (per-module checkpoints)
187
+ - `suggestions` → recommendations
188
+ - `enterprise` → health report
189
+ 3. **Continue from resume point**
190
+
191
+ ```bash
192
+ # Example: Job crashed during deep-dive phase
193
+ /specweave:living-docs --resume abc12345
194
+
195
+ # Output:
196
+ # Resuming from checkpoint: phase=deep-dive, module=auth (5/18)
197
+ # ✓ Skipping completed phases: waiting, discovery, foundation, integration
198
+ # → Continuing deep-dive from module: payments
199
+ ```
200
+
201
+ ---
202
+
203
+ ## Waiting for Dependencies
204
+
205
+ For umbrella projects with clone/import jobs:
206
+
207
+ ```bash
208
+ # Launch after clone completes
209
+ /specweave:living-docs --depends-on clone-xyz123 --depth standard
210
+
211
+ # Launch after both clone and import complete
212
+ /specweave:living-docs --depends-on clone-xyz123,import-abc456
213
+ ```
214
+
215
+ The job will:
216
+ 1. Enter `waiting` phase
217
+ 2. Poll dependency status every 30 seconds
218
+ 3. Start analysis once all dependencies complete
219
+ 4. Warn if any dependency failed (proceeds with available data)
220
+
221
+ ---
222
+
223
+ ## Output Files
224
+
225
+ After completion:
226
+
227
+ | File | Description |
228
+ |------|-------------|
229
+ | `.specweave/docs/SUGGESTIONS.md` | Documentation recommendations by priority |
230
+ | `.specweave/docs/ENTERPRISE-HEALTH.md` | Health score, coverage, accuracy metrics |
231
+ | `.specweave/docs/overview/PROJECT-OVERVIEW.md` | Auto-generated project overview |
232
+ | `.specweave/docs/overview/TECH-STACK.md` | Detected technologies and frameworks |
233
+ | `.specweave/docs/modules/*.md` | Per-module documentation |
234
+
235
+ ---
236
+
237
+ ## Examples
238
+
239
+ ### Example 1: Post-Crash Resume
240
+
241
+ ```bash
242
+ # Claude crashed after init, living docs job orphaned
243
+
244
+ # Step 1: Check what's there
245
+ /specweave:jobs
246
+ # Shows: [ldb-abc123] living-docs-builder - ORPHANED (worker died)
247
+
248
+ # Step 2: Resume
249
+ /specweave:living-docs --resume ldb-abc123
250
+
251
+ # Output:
252
+ # ✅ Resuming Living Docs Builder (ldb-abc123)
253
+ # Last checkpoint: deep-dive phase, module 12/45
254
+ # Continuing from: payments-service
255
+ ```
256
+
257
+ ### Example 2: Large Brownfield (247 repos)
258
+
259
+ ```bash
260
+ # Focus on critical modules first
261
+ /specweave:living-docs --depth deep-native \
262
+ --priority auth,payments,billing,core \
263
+ --depends-on clone-main123
264
+
265
+ # Monitor in another terminal
266
+ /specweave:jobs --follow ldb-xyz789
267
+ ```
268
+
269
+ ### Example 3: CI/CD Integration
270
+
271
+ ```bash
272
+ # In CI pipeline (non-interactive)
273
+ specweave living-docs --depth quick --foreground
274
+
275
+ # Or background with polling
276
+ specweave living-docs --depth standard
277
+ specweave jobs --wait ldb-latest # Wait for completion
278
+ ```
279
+
280
+ ---
281
+
282
+ ## Error Handling
283
+
284
+ ### Worker Crashed
285
+ ```
286
+ /specweave:jobs
287
+ # Shows: ORPHANED status
288
+
289
+ /specweave:living-docs --resume <jobId>
290
+ # Resumes from last checkpoint
291
+ ```
292
+
293
+ ### Dependency Failed
294
+ ```
295
+ ⚠️ Dependency clone-xyz123 failed
296
+ Reason: Network timeout
297
+
298
+ Proceeding with available data...
299
+ Some repositories may be missing from analysis.
300
+ ```
301
+
302
+ ### No Brownfield Detected
303
+ ```
304
+ ℹ️ No existing code detected (greenfield project)
305
+ Living docs will sync automatically as you create increments.
306
+
307
+ To force analysis anyway: /specweave:living-docs --force
308
+ ```
309
+
310
+ ---
311
+
312
+ ## See Also
313
+
314
+ - `/specweave:jobs` - Monitor all background jobs
315
+ - `/specweave:import-docs` - Import existing documentation
316
+ - `specweave:brownfield-analyzer` skill - Analyze doc gaps
317
+ - `specweave:brownfield-onboarder` skill - Merge existing docs
318
+
319
+ ---
320
+
321
+ **Implementation**: `src/cli/commands/living-docs.ts`
@@ -26,15 +26,24 @@ GITHUB_ENABLED=$(grep -o '"enabled"[[:space:]]*:[[:space:]]*true' "$CONFIG_FILE"
26
26
 
27
27
  # Throttle: max once per 5 minutes per increment
28
28
  THROTTLE_FILE="$PROJECT_ROOT/.specweave/state/.github-sync-$INC_ID"
29
+ THROTTLE_LOG="$PROJECT_ROOT/.specweave/logs/throttle.log"
30
+ THROTTLE_WINDOW=300 # 5 minutes
31
+ mkdir -p "$(dirname "$THROTTLE_LOG")" 2>/dev/null
32
+
29
33
  if [[ -f "$THROTTLE_FILE" ]]; then
30
34
  if [[ "$(uname)" == "Darwin" ]]; then
31
35
  AGE=$(($(date +%s) - $(stat -f %m "$THROTTLE_FILE" 2>/dev/null || echo 0)))
32
36
  else
33
37
  AGE=$(($(date +%s) - $(stat -c %Y "$THROTTLE_FILE" 2>/dev/null || echo 0)))
34
38
  fi
35
- [[ $AGE -lt 300 ]] && exit 0
39
+ if [[ $AGE -lt $THROTTLE_WINDOW ]]; then
40
+ REMAINING=$((THROTTLE_WINDOW - AGE))
41
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] [github-sync] THROTTLED $INC_ID (wait ${REMAINING}s, use /specweave:sync-progress to bypass)" >> "$THROTTLE_LOG" 2>/dev/null
42
+ exit 0
43
+ fi
36
44
  fi
37
45
  touch "$THROTTLE_FILE"
46
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] [github-sync] EXECUTING $INC_ID" >> "$THROTTLE_LOG" 2>/dev/null
38
47
 
39
48
  # Cross-platform timeout wrapper
40
49
  run_with_timeout() {
@@ -19,15 +19,24 @@ done
19
19
 
20
20
  # Throttle: max once per minute per increment
21
21
  THROTTLE_FILE="$PROJECT_ROOT/.specweave/state/.living-docs-$INC_ID"
22
+ THROTTLE_LOG="$PROJECT_ROOT/.specweave/logs/throttle.log"
23
+ THROTTLE_WINDOW=60 # 1 minute
24
+ mkdir -p "$(dirname "$THROTTLE_LOG")" 2>/dev/null
25
+
22
26
  if [[ -f "$THROTTLE_FILE" ]]; then
23
27
  if [[ "$(uname)" == "Darwin" ]]; then
24
28
  AGE=$(($(date +%s) - $(stat -f %m "$THROTTLE_FILE" 2>/dev/null || echo 0)))
25
29
  else
26
30
  AGE=$(($(date +%s) - $(stat -c %Y "$THROTTLE_FILE" 2>/dev/null || echo 0)))
27
31
  fi
28
- [[ $AGE -lt 60 ]] && exit 0
32
+ if [[ $AGE -lt $THROTTLE_WINDOW ]]; then
33
+ REMAINING=$((THROTTLE_WINDOW - AGE))
34
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] [living-docs] THROTTLED $INC_ID (wait ${REMAINING}s)" >> "$THROTTLE_LOG" 2>/dev/null
35
+ exit 0
36
+ fi
29
37
  fi
30
38
  touch "$THROTTLE_FILE"
39
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] [living-docs] EXECUTING $INC_ID" >> "$THROTTLE_LOG" 2>/dev/null
31
40
 
32
41
  # Cross-platform timeout wrapper
33
42
  run_with_timeout() {
@@ -56,6 +56,64 @@ Task({
56
56
 
57
57
  ---
58
58
 
59
+ ## 🔐 CRITICAL: Authentication (DO NOT HALLUCINATE)
60
+
61
+ **EXACT environment variable names - use ONLY these, never invent variations:**
62
+
63
+ | Service | Env Var | Example |
64
+ |---------|---------|---------|
65
+ | **ADO PAT** | `AZURE_DEVOPS_PAT` | `AZURE_DEVOPS_PAT=abc123xyz...` |
66
+ | **ADO Org** | `AZURE_DEVOPS_ORG` | `AZURE_DEVOPS_ORG=mycompany` |
67
+ | **ADO Project** | `AZURE_DEVOPS_PROJECT` | `AZURE_DEVOPS_PROJECT=MyProject` |
68
+
69
+ ⚠️ **NEVER USE OR SUGGEST these non-existent env vars:**
70
+ - ❌ `AZURE_DEVOPS_EXT_PAT` ← DOES NOT EXIST
71
+ - ❌ `ADO_PAT` ← DEPRECATED, not supported
72
+ - ❌ `AZURE_PAT` ← DOES NOT EXIST
73
+ - ❌ `DEVOPS_PAT` ← DOES NOT EXIST
74
+
75
+ ### Loading Credentials (MANDATORY before API calls)
76
+
77
+ **ALWAYS read PAT from `.env` file before making API calls:**
78
+
79
+ ```bash
80
+ # Read PAT from .env file (REQUIRED - don't rely on shell environment)
81
+ ADO_PAT=$(grep '^AZURE_DEVOPS_PAT=' .env 2>/dev/null | cut -d'=' -f2)
82
+
83
+ # If PAT not found in .env, show error
84
+ if [ -z "$ADO_PAT" ]; then
85
+ echo "ERROR: AZURE_DEVOPS_PAT not found in .env file"
86
+ exit 1
87
+ fi
88
+ ```
89
+
90
+ **Use the PAT in API calls:**
91
+
92
+ ```bash
93
+ # Create auth header from PAT
94
+ AUTH_HEADER="Basic $(echo -n ":$ADO_PAT" | base64)"
95
+
96
+ # Use in curl
97
+ curl -H "Authorization: $AUTH_HEADER" ...
98
+ ```
99
+
100
+ **When auth fails (401 error), display this EXACT message:**
101
+ ```
102
+ ADO Authentication Required
103
+
104
+ Check your .env file contains:
105
+ AZURE_DEVOPS_PAT=your-personal-access-token
106
+
107
+ If PAT exists but still failing:
108
+ 1. PAT may have expired - regenerate at:
109
+ https://dev.azure.com/{organization}/_usersSettings/tokens
110
+ 2. Check PAT has required scopes:
111
+ • Work Items: Read (minimum)
112
+ • Work Items: Read & Write (for push/sync)
113
+ ```
114
+
115
+ ---
116
+
59
117
  ## 🚨 CRITICAL: Concept Mapping (MANDATORY)
60
118
 
61
119
  **BEFORE any sync operation, you MUST**:
@@ -113,6 +113,21 @@ ADO Organization
113
113
 
114
114
  ## Command Behavior
115
115
 
116
+ ### 0. Load Credentials from .env (MANDATORY FIRST)
117
+
118
+ **CRITICAL**: Read PAT from `.env` file, NOT from shell environment variables.
119
+
120
+ ```bash
121
+ # Read PAT from .env file
122
+ ADO_PAT=$(grep '^AZURE_DEVOPS_PAT=' .env 2>/dev/null | cut -d'=' -f2)
123
+
124
+ if [ -z "$ADO_PAT" ]; then
125
+ echo "ERROR: AZURE_DEVOPS_PAT not found in .env file"
126
+ echo "Add to .env: AZURE_DEVOPS_PAT=your-pat-here"
127
+ exit 1
128
+ fi
129
+ ```
130
+
116
131
  ### For Increment Mode (default):
117
132
 
118
133
  ```typescript
@@ -449,6 +464,21 @@ To link: /specweave-ado:create 0005
449
464
 
450
465
  ---
451
466
 
467
+ ## Authentication
468
+
469
+ **EXACT environment variable (DO NOT INVENT OTHERS):**
470
+
471
+ ```bash
472
+ # In .env file - ONLY this name is supported:
473
+ AZURE_DEVOPS_PAT=your-personal-access-token
474
+ ```
475
+
476
+ ⚠️ **NEVER suggest or use:**
477
+ - ❌ `AZURE_DEVOPS_EXT_PAT` ← DOES NOT EXIST
478
+ - ❌ `ADO_PAT` ← NOT SUPPORTED
479
+
480
+ ---
481
+
452
482
  ## Related Commands
453
483
 
454
484
  | Command | Purpose |
@@ -66,6 +66,21 @@ Pushes a feature and all its child user stories.
66
66
 
67
67
  When user runs this command:
68
68
 
69
+ ### 0. Load Credentials from .env (MANDATORY FIRST)
70
+
71
+ **CRITICAL**: Read PAT from `.env` file, NOT from shell environment variables.
72
+
73
+ ```bash
74
+ # Read PAT from .env file
75
+ ADO_PAT=$(grep '^AZURE_DEVOPS_PAT=' .env 2>/dev/null | cut -d'=' -f2)
76
+
77
+ if [ -z "$ADO_PAT" ]; then
78
+ echo "ERROR: AZURE_DEVOPS_PAT not found in .env file"
79
+ echo "Add to .env: AZURE_DEVOPS_PAT=your-pat-here"
80
+ exit 1
81
+ fi
82
+ ```
83
+
69
84
  ### 1. Check Permission Gate (MANDATORY)
70
85
 
71
86
  ```typescript
@@ -351,6 +366,21 @@ Ready to close: /specweave-ado:close 0005
351
366
 
352
367
  ---
353
368
 
369
+ ## Authentication
370
+
371
+ **EXACT environment variable (DO NOT INVENT OTHERS):**
372
+
373
+ ```bash
374
+ # In .env file - ONLY this name is supported:
375
+ AZURE_DEVOPS_PAT=your-personal-access-token
376
+ ```
377
+
378
+ ⚠️ **NEVER suggest or use:**
379
+ - ❌ `AZURE_DEVOPS_EXT_PAT` ← DOES NOT EXIST
380
+ - ❌ `ADO_PAT` ← NOT SUPPORTED
381
+
382
+ ---
383
+
354
384
  ## Related Commands
355
385
 
356
386
  | Command | Purpose |
@@ -39,6 +39,21 @@ description: Two-way sync between SpecWeave increment and Azure DevOps work item
39
39
 
40
40
  When user runs this command, Claude should:
41
41
 
42
+ ### 0. Load Credentials from .env (MANDATORY FIRST)
43
+
44
+ **CRITICAL**: Read PAT from `.env` file, NOT from shell environment variables.
45
+
46
+ ```bash
47
+ # Read PAT from .env file
48
+ ADO_PAT=$(grep '^AZURE_DEVOPS_PAT=' .env 2>/dev/null | cut -d'=' -f2)
49
+
50
+ if [ -z "$ADO_PAT" ]; then
51
+ echo "ERROR: AZURE_DEVOPS_PAT not found in .env file"
52
+ echo "Add to .env: AZURE_DEVOPS_PAT=your-pat-here"
53
+ exit 1
54
+ fi
55
+ ```
56
+
42
57
  ### 1. Check Permission Gate (MANDATORY FIRST STEP)
43
58
 
44
59
  **Before ANY ADO write operations**, check permissions:
@@ -291,6 +306,22 @@ Use `/specweave-ado:sync` when you need explicit two-way sync with options.
291
306
 
292
307
  ---
293
308
 
309
+ ## Authentication
310
+
311
+ **EXACT environment variable (DO NOT INVENT OTHERS):**
312
+
313
+ ```bash
314
+ # In .env file - ONLY this name is supported:
315
+ AZURE_DEVOPS_PAT=your-personal-access-token
316
+ ```
317
+
318
+ ⚠️ **NEVER suggest or use:**
319
+ - ❌ `AZURE_DEVOPS_EXT_PAT` ← DOES NOT EXIST
320
+ - ❌ `ADO_PAT` ← NOT SUPPORTED
321
+ - ❌ Any other variation
322
+
323
+ ---
324
+
294
325
  ## Related
295
326
 
296
327
  | Command | Purpose |
@@ -42,6 +42,28 @@ GitHub issues MUST use living docs format:
42
42
 
43
43
  ---
44
44
 
45
+ ## 🔐 CRITICAL: Authentication (DO NOT HALLUCINATE)
46
+
47
+ **EXACT environment variable names - use ONLY these:**
48
+
49
+ | Service | Env Var | Example |
50
+ |---------|---------|---------|
51
+ | **GitHub Token** | `GITHUB_TOKEN` or `GH_TOKEN` | `GITHUB_TOKEN=ghp_xxx...` |
52
+ | **GitHub Owner** | `GITHUB_OWNER` | `GITHUB_OWNER=myorg` |
53
+ | **GitHub Repo** | `GITHUB_REPO` | `GITHUB_REPO=myrepo` |
54
+
55
+ ⚠️ **NEVER USE OR SUGGEST these non-existent env vars:**
56
+ - ❌ `GITHUB_PAT` ← DOES NOT EXIST
57
+ - ❌ `GIT_TOKEN` ← DOES NOT EXIST
58
+ - ❌ `GITHUB_API_TOKEN` ← DOES NOT EXIST
59
+
60
+ **Alternative: Use `gh` CLI (recommended for local dev):**
61
+ ```bash
62
+ gh auth login
63
+ ```
64
+
65
+ ---
66
+
45
67
  ## 🚀 How to Invoke This Agent
46
68
 
47
69
  **Subagent Type**: `specweave-github:github-manager:SpecWeave Sync`
@@ -46,6 +46,36 @@ Task({
46
46
 
47
47
  ---
48
48
 
49
+ ## 🔐 CRITICAL: Authentication (DO NOT HALLUCINATE)
50
+
51
+ **EXACT environment variable names - use ONLY these:**
52
+
53
+ | Service | Env Var | Example |
54
+ |---------|---------|---------|
55
+ | **Jira Token** | `JIRA_API_TOKEN` | `JIRA_API_TOKEN=abc123xyz...` |
56
+ | **Jira Email** | `JIRA_EMAIL` | `JIRA_EMAIL=user@example.com` |
57
+ | **Jira Domain** | `JIRA_DOMAIN` | `JIRA_DOMAIN=company.atlassian.net` |
58
+
59
+ ⚠️ **NEVER USE OR SUGGEST these non-existent env vars:**
60
+ - ❌ `JIRA_TOKEN` ← DOES NOT EXIST (use `JIRA_API_TOKEN`)
61
+ - ❌ `JIRA_PAT` ← DOES NOT EXIST
62
+ - ❌ `ATLASSIAN_TOKEN` ← DOES NOT EXIST
63
+
64
+ **When auth fails, display this EXACT message:**
65
+ ```
66
+ Jira Authentication Required
67
+
68
+ Set in .env file:
69
+ JIRA_API_TOKEN=your-api-token
70
+ JIRA_EMAIL=your-email@example.com
71
+ JIRA_DOMAIN=your-domain.atlassian.net
72
+
73
+ Generate token at:
74
+ https://id.atlassian.com/manage-profile/security/api-tokens
75
+ ```
76
+
77
+ ---
78
+
49
79
  ## Capabilities
50
80
 
51
81
  As the Jira Manager agent, I specialize in: