@sppg2001/atomize 1.2.4 → 2.0.0-alpha.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,257 @@
1
+ # Authentication & Connection Profiles
2
+
3
+ Atomize manages credentials as named profiles. Instead of passing a token on every command, you save a profile once and reference it by name — or rely on the default for your platform.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Profile Types](#profile-types)
8
+ - [Credential Storage](#credential-storage)
9
+ - [Quick Setup](#quick-setup)
10
+ - [Profile Resolution Order](#profile-resolution-order)
11
+ - [Managing Multiple Profiles](#managing-multiple-profiles)
12
+ - [CI/CD Setup](#cicd-setup)
13
+ - [Rotating Tokens](#rotating-tokens)
14
+ - [Troubleshooting](#troubleshooting)
15
+
16
+ ---
17
+
18
+ ## Profile Types
19
+
20
+ | Type | Used for | Set up with |
21
+ |------|----------|-------------|
22
+ | **Azure DevOps** | `generate`, `validate`, `fields list`, `queries list` | `atomize auth add` → select Azure DevOps |
23
+ | **GitHub Models** | AI-assisted template generation (`template create --ai`) | `atomize auth add` → select GitHub Models |
24
+
25
+ Each type has its own independent default. You can have a default ADO profile and a default GitHub Models profile at the same time — they do not conflict.
26
+
27
+ ---
28
+
29
+ ## Credential Storage
30
+
31
+ Atomize stores tokens in the most secure available location, trying each tier in order:
32
+
33
+ | Tier | Storage | When used |
34
+ |------|---------|-----------|
35
+ | 1 | **OS keychain** — macOS Keychain, Windows Credential Manager, Linux secret service (libsecret) | Default when keychain is available |
36
+ | 2 | **Encrypted local file** — AES-256-GCM, stored at `~/.atomize/`, opt-in only | When keychain is unavailable and `--insecure-storage` is passed |
37
+ | 3 | **Refuse to persist** | When neither is available and `--insecure-storage` was not passed |
38
+
39
+ `auth list` shows which tier is in use for each profile: `[keychain]` or `[file]`.
40
+
41
+ ### When the keychain is unavailable
42
+
43
+ Some environments do not have a working keychain — headless servers, Docker containers, and the Atomize standalone binary (`bun build --compile` cannot load native keychain bindings). In these cases:
44
+
45
+ - Interactive runs display a warning and ask whether you want to use the local file fallback.
46
+ - Non-interactive runs (CI/CD) require `--insecure-storage` to be passed explicitly to `auth add`.
47
+
48
+ ```bash
49
+ echo "$AZURE_DEVOPS_PAT" | atomize auth add ci \
50
+ --org-url https://dev.azure.com/myorg \
51
+ --project MyProject \
52
+ --team MyTeam \
53
+ --default \
54
+ --pat-stdin \
55
+ --insecure-storage
56
+ ```
57
+
58
+ In CI, prefer injecting the token from your secrets store and creating the profile inside the job workspace — see [CI/CD Setup](#cicd-setup).
59
+
60
+ ---
61
+
62
+ ## Quick Setup
63
+
64
+ ### Local development
65
+
66
+ ```bash
67
+ # Azure DevOps profile
68
+ atomize auth add work-ado
69
+ # → prompted for org URL, project, team, and PAT
70
+ # → set as default when prompted
71
+
72
+ # Verify it works
73
+ atomize auth test work-ado
74
+
75
+ # GitHub Models profile (only needed for template create --ai)
76
+ atomize auth add my-ai
77
+ # → prompted for a GitHub PAT with models:read scope
78
+ atomize auth test my-ai
79
+ ```
80
+
81
+ **Getting a PAT:**
82
+ - Azure DevOps: `https://dev.azure.com/{org}/_usersSettings/tokens` — scopes: Work Items (Read, Write)
83
+ - GitHub Models: `https://github.com/settings/tokens` — scope: `models:read` (under Models)
84
+
85
+ ### Verify your profiles
86
+
87
+ ```bash
88
+ atomize auth list
89
+ ```
90
+
91
+ ```
92
+ work-ado (Azure DevOps · default)
93
+ URL: https://dev.azure.com/myorg
94
+ Project: MyProject
95
+ Team: MyTeam
96
+ Token: [keychain]
97
+ Created: 1/3/2026, 10:00:00 AM
98
+
99
+ my-ai (GitHub Models (AI) · default)
100
+ Token: [keychain]
101
+ Created: 1/3/2026, 10:05:00 AM
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Profile Resolution Order
107
+
108
+ When a command needs credentials, Atomize resolves them in this order:
109
+
110
+ **For ADO commands** (`generate`, `validate`, `fields list`, `queries list`):
111
+
112
+ 1. `--profile <name>` flag on the command
113
+ 2. `ATOMIZE_PROFILE` environment variable
114
+ 3. Default ADO profile (set via `atomize auth use`)
115
+ 4. `ATOMIZE_PAT` environment variable (legacy, no profile needed)
116
+ 5. Interactive prompt
117
+
118
+ **For AI commands** (`template create --ai`):
119
+
120
+ 1. `--ai-profile <name>` flag
121
+ 2. `ATOMIZE_AI_PROFILE` environment variable
122
+ 3. Default GitHub Models profile (set via `atomize auth use`)
123
+
124
+ If resolution fails and the session is interactive, Atomize prompts for credentials and offers to save a new profile.
125
+
126
+ ---
127
+
128
+ ## Managing Multiple Profiles
129
+
130
+ You can have as many profiles as you need — one per organization, project, or environment.
131
+
132
+ ```bash
133
+ # Two ADO profiles — personal and work
134
+ atomize auth add personal --org-url https://dev.azure.com/personal-org ...
135
+ atomize auth add work --org-url https://dev.azure.com/work-org ...
136
+
137
+ # Switch between them per-run
138
+ atomize generate template:backend-api --profile personal
139
+ atomize generate template:backend-api --profile work
140
+
141
+ # Or change the default
142
+ atomize auth use work
143
+ ```
144
+
145
+ ### Switching the default
146
+
147
+ ```bash
148
+ atomize auth use # pick interactively
149
+ atomize auth use work-ado # set by name
150
+ ```
151
+
152
+ Each platform type has its own default. Changing the ADO default does not affect the GitHub Models default.
153
+
154
+ ### Removing a profile
155
+
156
+ ```bash
157
+ atomize auth remove old-profile
158
+ atomize auth rm old-profile # alias
159
+ ```
160
+
161
+ If the removed profile was the default for its platform, Atomize prompts you to assign a new default.
162
+
163
+ ---
164
+
165
+ ## CI/CD Setup
166
+
167
+ For automated environments, inject the PAT via stdin and create a short-lived profile in the job workspace.
168
+
169
+ ```yaml
170
+ - name: Generate Tasks
171
+ env:
172
+ AZURE_DEVOPS_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
173
+ run: |
174
+ echo "$AZURE_DEVOPS_PAT" | atomize auth add ci \
175
+ --org-url "${{ secrets.AZURE_DEVOPS_ORG_URL }}" \
176
+ --project "${{ secrets.AZURE_DEVOPS_PROJECT }}" \
177
+ --team "${{ secrets.AZURE_DEVOPS_TEAM }}" \
178
+ --default \
179
+ --pat-stdin \
180
+ --insecure-storage
181
+
182
+ atomize generate template:backend-api \
183
+ --execute \
184
+ --auto-approve \
185
+ --continue-on-error
186
+ ```
187
+
188
+ **Why `--pat-stdin`?** Passing the token as a flag (`--pat abc123`) risks it appearing in process listings (`ps aux`) or shell history. Reading from stdin keeps it out of both.
189
+
190
+ If your runner has a working OS keychain, you can omit `--insecure-storage`. On headless runners, the flag explicitly opts into Atomize's local encrypted file fallback for that job.
191
+
192
+ You can also provide the PAT through `ATOMIZE_PAT` while still creating a profile:
193
+
194
+ ```yaml
195
+ - name: Generate Tasks
196
+ env:
197
+ ATOMIZE_PAT: ${{ secrets.AZURE_DEVOPS_PAT }}
198
+ run: |
199
+ atomize auth add ci \
200
+ --org-url "${{ secrets.AZURE_DEVOPS_ORG_URL }}" \
201
+ --project "${{ secrets.AZURE_DEVOPS_PROJECT }}" \
202
+ --team "${{ secrets.AZURE_DEVOPS_TEAM }}" \
203
+ --default \
204
+ --insecure-storage
205
+
206
+ atomize generate template:backend-api --execute --auto-approve
207
+ ```
208
+
209
+ ---
210
+
211
+ ## Rotating Tokens
212
+
213
+ When a PAT expires, update it in place without removing the profile:
214
+
215
+ ```bash
216
+ atomize auth rotate work-ado
217
+ # → prompted for the new token
218
+ # → replaces the stored token; all other profile settings are preserved
219
+ ```
220
+
221
+ After rotating, verify the connection:
222
+
223
+ ```bash
224
+ atomize auth test work-ado
225
+ ```
226
+
227
+ ---
228
+
229
+ ## Troubleshooting
230
+
231
+ ### "No default profile found"
232
+
233
+ You have not set a default profile for this platform. Either pass `--profile <name>` explicitly or run:
234
+
235
+ ```bash
236
+ atomize auth use
237
+ ```
238
+
239
+ ### "Authentication failed: 401 Unauthorized"
240
+
241
+ - The PAT has expired — rotate it: `atomize auth rotate <name>`
242
+ - The PAT does not have the required scopes (Work Items Read/Write for ADO, `models:read` for GitHub Models)
243
+ - The org URL, project, or team name is wrong — remove the profile and re-add it
244
+
245
+ ### "Keychain unavailable"
246
+
247
+ The OS keychain could not be accessed. Options:
248
+ - Re-run with `--insecure-storage` to fall back to an encrypted local file
249
+ - Use environment variables (`ATOMIZE_PAT`) and skip persistent storage
250
+
251
+ ### "Profile not found: <name>"
252
+
253
+ The profile name does not match any saved profile. Run `atomize auth list` to see exact names.
254
+
255
+ ### Token visible in process list
256
+
257
+ Always use `--pat-stdin` or environment variables in CI — never pass the token as a flag argument.