astragentic 1.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,582 @@
1
+ # Brownfield Workflow
2
+
3
+ > Atlas-first: scan codebase → clarify gaps → generate complete atlas → auto-expand
4
+
5
+ ---
6
+
7
+ ## When to Use
8
+
9
+ - Existing codebase with little or no documentation
10
+ - Taking over a project from another team
11
+ - Need to understand and document what exists
12
+
13
+ ---
14
+
15
+ ## Flow Overview
16
+
17
+ ```
18
+ /astra:start --scan
19
+
20
+
21
+ [1. Scan]
22
+
23
+
24
+ [2. Clarify]
25
+
26
+ ◆ Human fills gaps
27
+ │ (ALL domains, ALL flows)
28
+
29
+
30
+ [3. Generate Complete Atlas]
31
+
32
+ ◆ Human Approves Atlas
33
+
34
+
35
+ [4. Auto-Expand to Full Structure]
36
+
37
+
38
+ [Ready to Build]
39
+ ```
40
+
41
+ **Key principle:** Scan everything, clarify once, generate everything at once. No per-domain iteration.
42
+
43
+ ---
44
+
45
+ ## Phase 1: Scan
46
+
47
+ **Goal:** Analyze entire codebase comprehensively
48
+
49
+ **Actions:**
50
+
51
+ ### 1.1 Core Structure
52
+ 1. Map directory structure
53
+ 2. Identify frameworks, languages, patterns
54
+ 3. Detect ALL domain boundaries (by folder, module, or namespace)
55
+ 4. Find entry points (main, routes, handlers)
56
+
57
+ ### 1.2 Database & Models
58
+ 5. Extract ALL database schemas (ORM, migrations, raw SQL)
59
+ 6. Map ALL entities and relationships
60
+ 7. Identify cross-domain data references
61
+
62
+ ### 1.3 API & Endpoints
63
+ 8. Detect ALL routes and endpoints
64
+ 9. Extract request/response patterns
65
+ 10. Identify authentication/authorization patterns
66
+
67
+ ### 1.4 Configuration & Environment
68
+ 11. Locate config files (`.env.example`, `config/`, etc.)
69
+ 12. Identify environment variables
70
+ 13. Find secrets patterns
71
+ 14. Check for feature flags
72
+
73
+ ### 1.5 Testing & CI/CD
74
+ 15. Detect test frameworks and patterns
75
+ 16. Map test directory structure
76
+ 17. Detect CI/CD pipelines
77
+ 18. Find deployment configurations
78
+
79
+ ### 1.6 Existing Documentation
80
+ 19. Check for README files
81
+ 20. Find API documentation (OpenAPI, Swagger)
82
+ 21. Locate architecture docs or diagrams
83
+
84
+ **Output:** Comprehensive Codebase Report
85
+
86
+ ```markdown
87
+ ## Codebase Analysis
88
+
89
+ ### Tech Stack
90
+ | Layer | Technology | Version | Confidence |
91
+ |-------|------------|---------|------------|
92
+ | Runtime | {detected} | {version} | High/Medium |
93
+ | Framework | {detected} | {version} | High/Medium |
94
+ | Database | {detected} | {version} | High/Medium |
95
+ | Cache | {detected} | {version} | High/Medium |
96
+
97
+ ### Domains Detected
98
+ | Domain | Source Folders | Entities | Endpoints | Confidence |
99
+ |--------|----------------|----------|-----------|------------|
100
+ | {domain} | {folders} | {count} | {count} | High/Medium/Low |
101
+ {ALL domains listed}
102
+
103
+ ### Database Schema
104
+ | Table/Model | Domain | Columns | Relationships | Confidence |
105
+ |-------------|--------|---------|---------------|------------|
106
+ {ALL tables/models listed}
107
+
108
+ ### API Endpoints
109
+ | Method | Path | Domain | Auth | Confidence |
110
+ |--------|------|--------|------|------------|
111
+ {ALL endpoints listed}
112
+
113
+ ### Infrastructure
114
+ - **Containerized:** {yes/no}
115
+ - **CI/CD:** {platform}
116
+ - **Deployment:** {method}
117
+ - **Cloud:** {provider}
118
+
119
+ ### Existing Docs
120
+ - **README:** {quality assessment}
121
+ - **API docs:** {OpenAPI/Swagger/None}
122
+ - **Architecture:** {found/not found}
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Phase 2: Clarify
128
+
129
+ **Goal:** Fill gaps that code analysis cannot determine
130
+
131
+ **Actions:**
132
+ 1. Generate Gaps Report from scan
133
+ 2. Present structured questions
134
+ 3. Accept user inputs
135
+ 4. Mark confidence levels
136
+
137
+ ### Gaps Report
138
+
139
+ ```markdown
140
+ ## Gaps Identified
141
+
142
+ Based on my scan, I need clarification on:
143
+
144
+ ### High Priority (Blocks Atlas Generation)
145
+
146
+ | Area | What I Found | What I Need |
147
+ |------|--------------|-------------|
148
+ | Domain Boundaries | {detected domains} | Are these correct? Any to merge/split? |
149
+ | Database | {tables found} | Is this complete? Any raw SQL? |
150
+ | API Routes | {endpoints found} | Which are public vs internal? Deprecated? |
151
+
152
+ ### Medium Priority (Improves Accuracy)
153
+
154
+ | Area | What I Found | What I Need |
155
+ |------|--------------|-------------|
156
+ | Tech Rationale | {stack detected} | Why these choices? |
157
+ | External APIs | {integrations found} | What does each do? |
158
+ | Auth Pattern | {auth detected} | External IdP or self-managed? |
159
+
160
+ ### Business Context (Cannot Infer from Code)
161
+
162
+ | Area | What I Need |
163
+ |------|-------------|
164
+ | Product Vision | What is this system for? |
165
+ | Users/Actors | Who uses this? |
166
+ | Critical Flows | What are the key user journeys? |
167
+ | Compliance | GDPR, PCI, HIPAA requirements? |
168
+ ```
169
+
170
+ ### Structured Questions
171
+
172
+ ```markdown
173
+ ## Questions
174
+
175
+ ### 1. Domain Boundaries
176
+
177
+ I detected these domains from folder structure:
178
+
179
+ | Domain | Folders | Entities | Confidence |
180
+ |--------|---------|----------|------------|
181
+ {ALL detected domains}
182
+
183
+ **Questions:**
184
+ - Are these domain boundaries correct?
185
+ - Should any be merged or split?
186
+ - Are there domains I missed?
187
+
188
+ **Your input:** {free text}
189
+
190
+ ---
191
+
192
+ ### 2. Complete Database Schema
193
+
194
+ I found:
195
+ - {ORM}: {count} models
196
+ - Migrations: {count} files
197
+
198
+ **Questions:**
199
+ - Is this the complete schema?
200
+ - Any raw SQL not in ORM?
201
+ - Which are core vs supporting entities?
202
+
203
+ **Your input:** {free text}
204
+
205
+ ---
206
+
207
+ ### 3. API Completeness
208
+
209
+ I detected {count} endpoints:
210
+
211
+ | Method | Path | Confidence |
212
+ |--------|------|------------|
213
+ {sample endpoints}
214
+
215
+ **Questions:**
216
+ - Which are public-facing vs internal?
217
+ - Any deprecated endpoints?
218
+ - Webhooks or callbacks I missed?
219
+
220
+ **Your input:** {free text}
221
+
222
+ ---
223
+
224
+ ### 4. Business Context
225
+
226
+ Code cannot tell me:
227
+ - What is this product for?
228
+ - Who are the main users?
229
+ - What are the critical business flows?
230
+ - Any compliance requirements?
231
+
232
+ **Your input:** {free text}
233
+
234
+ ---
235
+
236
+ ### 5. Screens/UI (if frontend exists)
237
+
238
+ I detected {count} routes/pages:
239
+
240
+ | Route | Component | Confidence |
241
+ |-------|-----------|------------|
242
+ {detected routes}
243
+
244
+ **Questions:**
245
+ - Are these all the screens?
246
+ - Any screens behind feature flags?
247
+ - Which are public vs authenticated?
248
+
249
+ **Your input:** {free text}
250
+ ```
251
+
252
+ ### Confidence Update
253
+
254
+ After clarification, update confidence:
255
+
256
+ | Item | Before | After | Source |
257
+ |------|--------|-------|--------|
258
+ | Domain: auth | Inferred (High) | **Confirmed** | User verified |
259
+ | Domain: payment | Inferred (Low) | **Confirmed** | User corrected |
260
+ | Database schema | Inferred (Medium) | **Confirmed** | User provided context |
261
+ | Business context | Unknown | **Confirmed** | User provided |
262
+
263
+ **Human Gate:** Proceed when all high-priority gaps are resolved.
264
+
265
+ ---
266
+
267
+ ## Phase 3: Generate Complete Atlas
268
+
269
+ **Goal:** Produce comprehensive Atlas from scan + clarifications (ALL domains at once)
270
+
271
+ **Actions:**
272
+ 1. Create `.astraler-docs/` folder structure
273
+ 2. Generate complete `atlas/` folder
274
+ 3. Generate supporting files
275
+
276
+ ### Atlas Generation
277
+
278
+ Generate ALL of these in one pass:
279
+
280
+ #### `atlas/index.md`
281
+ - Product vision (from clarification)
282
+ - Complete tech stack (from scan)
283
+ - ALL domains with purpose and priority
284
+ - Domain relationship diagram
285
+ - Project structure (from scan)
286
+ - External integrations
287
+
288
+ #### `atlas/database.md`
289
+ - Complete ERD showing ALL entities (from scan)
290
+ - ALL tables with columns, types, constraints
291
+ - ALL relationships (detected + confirmed)
292
+ - Indexes (from scan)
293
+ - Cross-domain references
294
+ - Confidence markers for inferred sections
295
+
296
+ #### `atlas/screens.md` (if UI exists)
297
+ - Navigation map showing ALL screens
298
+ - ALL screens table (route, domain, auth)
299
+ - Screen details (from scan + clarification)
300
+
301
+ #### `atlas/api.md`
302
+ - Base URL and authentication (from scan)
303
+ - ALL endpoints summary (from scan)
304
+ - Endpoint details (detected + confirmed)
305
+ - Webhooks (if found)
306
+ - Confidence markers for inferred sections
307
+
308
+ #### `atlas/tasks.md`
309
+ - Documentation completion tasks
310
+ - Technical debt identified
311
+ - Suggested improvements
312
+ - Priority based on domain importance
313
+
314
+ ### Confidence Markers
315
+
316
+ Mark sections with confidence:
317
+
318
+ ```markdown
319
+ ## Users Table
320
+
321
+ > **Confidence:** Confirmed (from Prisma schema + user validation)
322
+
323
+ | Column | Type | Constraints |
324
+ |--------|------|-------------|
325
+ | id | uuid | PK |
326
+ | email | varchar | UK, NOT NULL |
327
+ ...
328
+ ```
329
+
330
+ ```markdown
331
+ ## Payment Flow
332
+
333
+ > **Confidence:** Inferred (Medium) - based on code analysis, needs validation
334
+
335
+ 1. User initiates checkout
336
+ 2. Payment intent created via Stripe
337
+ 3. ...
338
+ ```
339
+
340
+ ---
341
+
342
+ ### Human Gate: Atlas Approval
343
+
344
+ ```markdown
345
+ ## Atlas Complete
346
+
347
+ ### Generated from Scan + Clarification
348
+
349
+ | File | Content | Confidence |
350
+ |------|---------|------------|
351
+ | `atlas/index.md` | {X} domains, tech stack | Mixed |
352
+ | `atlas/database.md` | {Y} tables, {Z} relationships | {breakdown} |
353
+ | `atlas/screens.md` | {W} screens | {breakdown} |
354
+ | `atlas/api.md` | {V} endpoints | {breakdown} |
355
+ | `atlas/tasks.md` | {U} tasks | N/A |
356
+
357
+ ### Confidence Summary
358
+
359
+ | Level | Count | Action Needed |
360
+ |-------|-------|---------------|
361
+ | Confirmed | {count} | None |
362
+ | Inferred (High) | {count} | Light review |
363
+ | Inferred (Medium) | {count} | Validate |
364
+ | Inferred (Low) | {count} | Likely needs correction |
365
+
366
+ ### Sections Needing Review
367
+ 1. {section}: {reason}
368
+ 2. {section}: {reason}
369
+
370
+ ---
371
+ **Approve Atlas?**
372
+ [y] Yes, expand to full structure | [e] Edit specific file | [v] Validate low-confidence sections first
373
+ ```
374
+
375
+ ---
376
+
377
+ ## Phase 4: Auto-Expand to Full Structure
378
+
379
+ **Goal:** Automatically generate complete Astraler Docs structure from Atlas
380
+
381
+ **This phase is automatic — no human iteration required.**
382
+
383
+ ### Expansion Mapping
384
+
385
+ | Atlas Source | Generates |
386
+ |--------------|-----------|
387
+ | `atlas/index.md` | `02-spec/core/overview.md` |
388
+ | `atlas/index.md` | `03-arch/overview.md` |
389
+ | `atlas/index.md` (domains) | `02-spec/domains/{domain}.md` (overview) |
390
+ | `atlas/database.md` | `03-arch/data-schema.md` |
391
+ | `atlas/database.md` (per domain) | `03-arch/domains/{domain}.arch.md` |
392
+ | `atlas/screens.md` (per domain) | `02-spec/domains/{domain}.md` (screens) |
393
+ | `atlas/api.md` (cross-domain) | `02-spec/core/flows.md` |
394
+ | `atlas/api.md` (per domain) | `02-spec/domains/{domain}.md` (API) |
395
+ | `atlas/tasks.md` | `04-tasks/milestones.md` |
396
+ | `atlas/tasks.md` (per domain) | `04-tasks/domains/{domain}.tasks.md` |
397
+ | Scan results | `context/constraints.md` |
398
+ | Clarification | `context/assumptions.md` |
399
+ | Code analysis | `context/glossary.md` |
400
+
401
+ ### Generated Structure
402
+
403
+ ```
404
+ .astraler-docs/
405
+ ├── _index.md
406
+ ├── atlas/ # SOURCE (human-approved)
407
+ │ ├── index.md
408
+ │ ├── database.md
409
+ │ ├── screens.md
410
+ │ ├── api.md
411
+ │ └── tasks.md
412
+
413
+ ├── 02-spec/ # AUTO-GENERATED from Atlas
414
+ │ ├── _index.md
415
+ │ ├── core/
416
+ │ │ ├── overview.md
417
+ │ │ ├── flows.md
418
+ │ │ └── rules.md
419
+ │ └── domains/
420
+ │ └── {domain}.md # One per detected domain
421
+
422
+ ├── 03-arch/ # AUTO-GENERATED from Atlas
423
+ │ ├── _index.md
424
+ │ ├── overview.md
425
+ │ ├── data-schema.md
426
+ │ ├── standards.md # From detected patterns
427
+ │ ├── decisions.md # Template + detected decisions
428
+ │ └── domains/
429
+ │ └── {domain}.arch.md # One per detected domain
430
+
431
+ ├── 04-tasks/ # AUTO-GENERATED from Atlas
432
+ │ ├── _index.md
433
+ │ ├── milestones.md
434
+ │ └── domains/
435
+ │ └── {domain}.tasks.md # One per detected domain
436
+
437
+ ├── 05-changes/
438
+ │ ├── _index.md
439
+ │ ├── changelog.md
440
+ │ └── impact/
441
+
442
+ ├── context/
443
+ │ ├── constraints.md # From scan (tech constraints)
444
+ │ ├── assumptions.md # From clarification
445
+ │ └── glossary.md # From code analysis
446
+
447
+ └── ai/
448
+ ├── guardrails.md # Based on detected patterns
449
+ └── quality_gates.md # Based on existing CI/CD
450
+ ```
451
+
452
+ ### Expansion Rules
453
+
454
+ 1. **Preserve confidence markers** in generated files
455
+ 2. **All generated files include proper headers** (status, version, owner)
456
+ 3. **All generated files include required Mermaid diagrams**
457
+ 4. **Files with low-confidence sections are marked `status: Draft`**
458
+ 5. **Atlas remains the source of truth**
459
+
460
+ ### Post-Expansion Summary
461
+
462
+ ```markdown
463
+ ## Expansion Complete
464
+
465
+ ### Files Generated
466
+ | Folder | Files | Confidence |
467
+ |--------|-------|------------|
468
+ | 02-spec/core/ | 3 | {breakdown} |
469
+ | 02-spec/domains/ | {N} | {breakdown} |
470
+ | 03-arch/ | 4 | {breakdown} |
471
+ | 03-arch/domains/ | {N} | {breakdown} |
472
+ | 04-tasks/ | 1 | N/A |
473
+ | 04-tasks/domains/ | {N} | N/A |
474
+ | context/ | 3 | {breakdown} |
475
+ | ai/ | 2 | {breakdown} |
476
+ | **Total** | **{total}** | |
477
+
478
+ ### Low-Confidence Sections
479
+ These sections need human validation:
480
+ 1. `03-arch/domains/payment.arch.md` — State machine inferred
481
+ 2. `02-spec/domains/order.md` — Business rules unclear
482
+
483
+ ### Ready to Build
484
+ - Start with: `04-tasks/domains/{first-priority-domain}.tasks.md`
485
+ - Validate: Low-confidence sections before implementation
486
+ - Reference: `atlas/` for complete picture
487
+ - Changes: Use `/astra:change` to modify approved docs
488
+ ```
489
+
490
+ ---
491
+
492
+ ## Completion
493
+
494
+ After expansion:
495
+ 1. **Atlas** = Source of truth (Approved status)
496
+ 2. **Expanded files** = Detailed views (Draft/Approved based on confidence)
497
+ 3. **Low-confidence sections** = Need validation before implementation
498
+ 4. **Implementation** = Start from `04-tasks/`
499
+ 5. **Changes** = Modify Atlas first, re-expand affected sections
500
+
501
+ ---
502
+
503
+ ## Quick Reference
504
+
505
+ ```
506
+ /astra:start --scan
507
+
508
+
509
+ [1. Scan] ─────► Analyze entire codebase
510
+
511
+
512
+ [2. Clarify] ──► Fill gaps (domains, schema, business)
513
+
514
+ ◆ Human provides context
515
+
516
+
517
+ [3. Generate Atlas] ──► Complete atlas (ALL domains)
518
+
519
+ ◆ Human Approves
520
+
521
+
522
+ [4. Auto-Expand] ──► Full Astraler Docs structure
523
+
524
+
525
+ [Ready to Build]
526
+ ```
527
+
528
+ ---
529
+
530
+ ## Checklist
531
+
532
+ ### Phase 1: Scan Complete
533
+ - [ ] Directory structure mapped
534
+ - [ ] Tech stack identified
535
+ - [ ] ALL domains detected
536
+ - [ ] ALL database tables found
537
+ - [ ] ALL endpoints detected
538
+ - [ ] CI/CD analyzed
539
+
540
+ ### Phase 2: Clarification Complete
541
+ - [ ] Domain boundaries confirmed
542
+ - [ ] Database schema validated
543
+ - [ ] API completeness verified
544
+ - [ ] Business context provided
545
+ - [ ] High-priority gaps resolved
546
+
547
+ ### Phase 3: Atlas Complete
548
+ - [ ] `atlas/index.md` — All domains, tech stack
549
+ - [ ] `atlas/database.md` — All entities, relationships
550
+ - [ ] `atlas/screens.md` — All screens (if UI)
551
+ - [ ] `atlas/api.md` — All endpoints
552
+ - [ ] `atlas/tasks.md` — Documentation + improvement tasks
553
+
554
+ ### Phase 4: Expansion Complete
555
+ - [ ] `02-spec/` — Core + all domain specs
556
+ - [ ] `03-arch/` — Overview + all domain arch
557
+ - [ ] `04-tasks/` — Milestones + all domain tasks
558
+ - [ ] `context/` — Constraints, assumptions, glossary
559
+ - [ ] `ai/` — Guardrails, quality gates
560
+ - [ ] All files have proper headers
561
+ - [ ] Low-confidence sections marked
562
+
563
+ ---
564
+
565
+ ## Confidence Levels
566
+
567
+ | Level | Meaning | Source | Action |
568
+ |-------|---------|--------|--------|
569
+ | **Confirmed** | User verified | Clarification | Trust |
570
+ | **Inferred (High)** | Strong code signals | Scan | Light review |
571
+ | **Inferred (Medium)** | Unclear signals | Scan | Validate |
572
+ | **Inferred (Low)** | Educated guess | Scan | Likely needs correction |
573
+
574
+ ---
575
+
576
+ ## Limitations
577
+
578
+ - Cannot infer business intent from code alone
579
+ - May miss undocumented business rules
580
+ - Confidence varies by code quality/naming
581
+ - Always requires human validation for low-confidence sections
582
+ - Clarification phase reduces but doesn't eliminate guesswork