dhurandhar 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.
Files changed (54) hide show
  1. package/.dhurandhar-session-start.md +242 -0
  2. package/LICENSE +21 -0
  3. package/README.md +416 -0
  4. package/docs/ARCHITECTURE_V2.md +249 -0
  5. package/docs/DECISION_REGISTRY.md +357 -0
  6. package/docs/IMPLEMENTATION_PERSONAS.md +406 -0
  7. package/docs/PLUGGABLE_STRATEGIES.md +439 -0
  8. package/docs/SYSTEM_OBSERVER.md +433 -0
  9. package/docs/TEST_FIRST_AGILE.md +359 -0
  10. package/docs/architecture.md +279 -0
  11. package/docs/engineering-first-philosophy.md +263 -0
  12. package/docs/getting-started.md +218 -0
  13. package/docs/module-development.md +323 -0
  14. package/docs/strategy-example.md +299 -0
  15. package/docs/test-first-example.md +392 -0
  16. package/package.json +79 -0
  17. package/src/core/README.md +92 -0
  18. package/src/core/agent-instructions/backend-developer.md +412 -0
  19. package/src/core/agent-instructions/devops-engineer.md +372 -0
  20. package/src/core/agent-instructions/dhurandhar-council.md +547 -0
  21. package/src/core/agent-instructions/edge-case-hunter.md +322 -0
  22. package/src/core/agent-instructions/frontend-developer.md +494 -0
  23. package/src/core/agent-instructions/lead-system-architect.md +631 -0
  24. package/src/core/agent-instructions/system-observer.md +319 -0
  25. package/src/core/agent-instructions/test-architect.md +284 -0
  26. package/src/core/module.yaml +54 -0
  27. package/src/core/schemas/design-module-schema.yaml +995 -0
  28. package/src/core/schemas/system-design-map-schema.yaml +324 -0
  29. package/src/modules/example/README.md +130 -0
  30. package/src/modules/example/module.yaml +252 -0
  31. package/tools/cli/commands/audit.js +267 -0
  32. package/tools/cli/commands/config.js +113 -0
  33. package/tools/cli/commands/context.js +170 -0
  34. package/tools/cli/commands/decisions.js +398 -0
  35. package/tools/cli/commands/entity.js +218 -0
  36. package/tools/cli/commands/epic.js +125 -0
  37. package/tools/cli/commands/install.js +172 -0
  38. package/tools/cli/commands/module.js +109 -0
  39. package/tools/cli/commands/service.js +167 -0
  40. package/tools/cli/commands/story.js +225 -0
  41. package/tools/cli/commands/strategy.js +294 -0
  42. package/tools/cli/commands/test.js +277 -0
  43. package/tools/cli/commands/validate.js +107 -0
  44. package/tools/cli/dhurandhar.js +212 -0
  45. package/tools/lib/config-manager.js +170 -0
  46. package/tools/lib/filesystem.js +126 -0
  47. package/tools/lib/module-installer.js +61 -0
  48. package/tools/lib/module-manager.js +149 -0
  49. package/tools/lib/sdm-manager.js +982 -0
  50. package/tools/lib/test-engine.js +255 -0
  51. package/tools/lib/test-templates/api-client.template.js +100 -0
  52. package/tools/lib/test-templates/vitest.config.template.js +37 -0
  53. package/tools/lib/validators/config-validator.js +113 -0
  54. package/tools/lib/validators/module-validator.js +137 -0
@@ -0,0 +1,359 @@
1
+ # Test-First Agile Decomposition
2
+
3
+ ## Overview
4
+
5
+ Dhurandhar v2.1 integrates a **Test-First Agile Decomposition** layer that bridges natural language requirements with engineering-first implementation through contract-driven testing.
6
+
7
+ ## Philosophy
8
+
9
+ ### Traditional Agile (Anti-Pattern)
10
+
11
+ ```
12
+ Requirements → User Stories → Discussion → Planning → Implementation → Tests
13
+ [Weeks of overhead before any code]
14
+ ```
15
+
16
+ ### Dhurandhar Test-First Agile
17
+
18
+ ```
19
+ Epic → Story → API Contract → Tests → Implementation
20
+ [Tests written in minutes, define the contract]
21
+ ```
22
+
23
+ **Key Principle**: Tests are technical specifications, not afterthoughts.
24
+
25
+ ## Architecture
26
+
27
+ ### Epic-Story-Task Hierarchy
28
+
29
+ ```
30
+ EPIC (System Capability)
31
+ └── STORY (User Journey)
32
+ ├── Interaction Boundary (API Contract)
33
+ │ ├── Service
34
+ │ ├── Endpoint
35
+ │ ├── Request/Response Schema
36
+ │ └── Error States
37
+ ├── Technical Acceptance Criteria
38
+ └── TASKS
39
+ ├── Test Task (contract tests)
40
+ └── Implementation Tasks
41
+ ```
42
+
43
+ ### Integration with SDM
44
+
45
+ All Epic/Story/Task data lives in `SYSTEM_DESIGN_MAP.yaml`:
46
+
47
+ ```yaml
48
+ agile_blueprint:
49
+ epics:
50
+ - id: EPIC-001
51
+ name: "User Authentication & Authorization"
52
+ stories:
53
+ - id: STORY-001
54
+ name: "OAuth2 Social Login Flow"
55
+ interaction_boundary:
56
+ service: auth-service
57
+ api_endpoint: /api/v1/auth/oauth/callback
58
+ method: POST
59
+ request_contract:
60
+ provider: string
61
+ code: string
62
+ state: string
63
+ response_contract:
64
+ access_token: string
65
+ refresh_token: string
66
+ error_states: [400, 401, 500]
67
+ tasks:
68
+ - id: TASK-001-001
69
+ description: "Write contract tests"
70
+ type: test
71
+ status: not_started
72
+ - id: TASK-001-002
73
+ description: "Implement OAuth callback"
74
+ type: implementation
75
+ status: not_started
76
+
77
+ test_suite_status:
78
+ total_stories: 1
79
+ tested_stories: 0
80
+ coverage_percentage: 0
81
+ ```
82
+
83
+ ## Specialized Agent Personas
84
+
85
+ ### 1. Test Architect
86
+
87
+ **Role**: Translate Stories into executable test specifications
88
+
89
+ **Process**:
90
+ 1. User provides Story name
91
+ 2. Test Architect asks **max 3 technical questions**:
92
+ - Which service?
93
+ - API endpoint?
94
+ - HTTP method?
95
+ 3. Generates:
96
+ - Interaction boundary definition
97
+ - Contract test suite (standard flows, errors, edge cases)
98
+ - Technical acceptance criteria
99
+ - Linked tasks
100
+
101
+ **Output**: Executable tests that define the contract
102
+
103
+ ### 2. Edge Case Hunter
104
+
105
+ **Role**: Systematically identify boundary conditions and failure modes
106
+
107
+ **Checklist** (6 categories):
108
+ 1. **Input Boundaries**: Empty, null, size limits, type boundaries
109
+ 2. **Auth/Security**: Missing auth, invalid tokens, permission bypasses
110
+ 3. **Concurrency**: Race conditions, resource contention, idempotency
111
+ 4. **Data Integrity**: Injection attacks, XSS, path traversal, SSRF
112
+ 5. **Resource Exhaustion**: Memory bombs, CPU exhaustion, rate limits
113
+ 6. **Network**: Timeouts, partial failures, network splits
114
+
115
+ **Output**: Additional edge case tests for each Story
116
+
117
+ ## Workflow
118
+
119
+ ### Complete Test-First Cycle
120
+
121
+ ```bash
122
+ # 1. Define capability
123
+ dhurandhar epic add "User Authentication & Authorization"
124
+
125
+ # 2. Define user journey
126
+ dhurandhar story add "OAuth2 Social Login" --epic EPIC-001
127
+
128
+ # Test Architect asks 3 questions:
129
+ # - Service? auth-service
130
+ # - Endpoint? /api/v1/auth/oauth/callback
131
+ # - Method? POST
132
+
133
+ # 3. Generate contract tests
134
+ dhurandhar test --generate
135
+
136
+ # Output:
137
+ # ✓ tests/contracts/story-001-standard.test.js
138
+ # ✓ tests/contracts/story-001-errors.test.js
139
+ # ✓ tests/edge-cases/story-001-edge.test.js
140
+
141
+ # 4. Run tests (they will fail - no implementation yet)
142
+ npm test
143
+
144
+ # Expected: All tests fail (this is correct!)
145
+
146
+ # 5. Implement service to pass the tests
147
+ # (Implementation guided by test contracts)
148
+
149
+ # 6. Run tests again
150
+ npm test
151
+
152
+ # Expected: All tests pass
153
+
154
+ # 7. Validate coverage
155
+ dhurandhar test --validate
156
+
157
+ # Output:
158
+ # Total Stories: 1
159
+ # Test Coverage: 100%
160
+ # Implementation: 100%
161
+ ```
162
+
163
+ ## Test Generation
164
+
165
+ ### Generated Test Structure
166
+
167
+ For each Story, 3 test files are generated:
168
+
169
+ #### 1. Standard Flow Tests
170
+ **File**: `tests/contracts/story-001-standard.test.js`
171
+
172
+ ```javascript
173
+ describe('OAuth2 Social Login - Standard Flows', () => {
174
+ it('should exchange valid OAuth code for tokens', async () => {
175
+ const response = await apiClient.post('/api/v1/auth/oauth/callback', {
176
+ provider: 'google',
177
+ code: 'valid_code',
178
+ state: 'valid_state',
179
+ });
180
+
181
+ expect(response.status).toBe(200);
182
+ expect(response.data).toHaveProperty('access_token');
183
+ expect(response.data).toHaveProperty('refresh_token');
184
+ });
185
+ });
186
+ ```
187
+
188
+ #### 2. Error State Tests
189
+ **File**: `tests/contracts/story-001-errors.test.js`
190
+
191
+ ```javascript
192
+ describe('OAuth2 Social Login - Error States', () => {
193
+ it('should return 400 for invalid OAuth code', async () => {
194
+ try {
195
+ await apiClient.post('/api/v1/auth/oauth/callback', {
196
+ provider: 'google',
197
+ code: 'invalid_code',
198
+ state: 'valid_state',
199
+ });
200
+ fail('Should have thrown');
201
+ } catch (error) {
202
+ expect(error.response.status).toBe(400);
203
+ }
204
+ });
205
+
206
+ it('should return 401 for CSRF mismatch', async () => {
207
+ // Test state parameter validation
208
+ });
209
+ });
210
+ ```
211
+
212
+ #### 3. Edge Case Tests
213
+ **File**: `tests/edge-cases/story-001-edge.test.js`
214
+
215
+ ```javascript
216
+ describe('OAuth2 Social Login - Edge Cases', () => {
217
+ it('should prevent OAuth code reuse', async () => {
218
+ // Replay attack test
219
+ });
220
+
221
+ it('should handle concurrent callbacks', async () => {
222
+ // Race condition test
223
+ });
224
+
225
+ it('should handle provider timeout', async () => {
226
+ // Network failure test
227
+ });
228
+ });
229
+ ```
230
+
231
+ ## CLI Commands
232
+
233
+ ### Epic Management
234
+
235
+ ```bash
236
+ # List epics
237
+ dhurandhar epic --list
238
+
239
+ # Add epic
240
+ dhurandhar epic add "User Authentication & Authorization"
241
+ ```
242
+
243
+ ### Story Management
244
+
245
+ ```bash
246
+ # List stories
247
+ dhurandhar story --list
248
+
249
+ # Add story
250
+ dhurandhar story add "OAuth2 Login" --epic EPIC-001
251
+
252
+ # Add story interactively
253
+ dhurandhar story add
254
+ ```
255
+
256
+ ### Test Operations
257
+
258
+ ```bash
259
+ # Initialize test infrastructure
260
+ dhurandhar test --init
261
+
262
+ # Generate all tests from Agile Blueprint
263
+ dhurandhar test --generate
264
+
265
+ # Validate coverage
266
+ dhurandhar test --validate
267
+
268
+ # Generate edge cases for specific story
269
+ dhurandhar test --edge-cases STORY-001
270
+ ```
271
+
272
+ ## Engineering-First Approach
273
+
274
+ ### What We Ask (Technical)
275
+
276
+ ✅ **Good Questions**:
277
+ - "Which service handles this?"
278
+ - "API endpoint path?"
279
+ - "Request/response schema?"
280
+ - "Expected error codes?"
281
+
282
+ ### What We Don't Ask (Business)
283
+
284
+ ❌ **Bad Questions**:
285
+ - "What's the business value?"
286
+ - "Why do you need this feature?"
287
+ - "Have you considered alternatives?"
288
+ - "Who are the stakeholders?"
289
+
290
+ ## Benefits
291
+
292
+ ### 1. Contract-First Development
293
+
294
+ Tests define the API contract before implementation:
295
+ - Clear expectations
296
+ - No ambiguity
297
+ - Implementation guided by tests
298
+
299
+ ### 2. Zero Cognitive Fatigue
300
+
301
+ - Max 3 questions per Story
302
+ - No justification loops
303
+ - Direct action
304
+
305
+ ### 3. Complete Coverage Tracking
306
+
307
+ ```bash
308
+ $ dhurandhar test --validate
309
+
310
+ Coverage Report:
311
+ Total Stories: 10
312
+ Test Coverage: 100% (10/10)
313
+ Implementation: 70% (7/10)
314
+
315
+ Uncovered Stories:
316
+ 🔴 STORY-008: Password Reset Flow
317
+ Pending tasks: 2
318
+ 🔴 STORY-009: Email Verification
319
+ Pending tasks: 3
320
+ ```
321
+
322
+ ### 4. Cross-Session Persistence
323
+
324
+ All Epic/Story/Task data in SDM:
325
+ - Instant context rehydration
326
+ - Definition of Done tracked
327
+ - No rediscovery needed
328
+
329
+ ## Definition of Done
330
+
331
+ A Story is "Done" when:
332
+
333
+ 1. ✅ Contract tests generated
334
+ 2. ✅ Edge case tests generated
335
+ 3. ✅ All tests passing
336
+ 4. ✅ All tasks marked `complete` in SDM
337
+
338
+ Check status:
339
+ ```bash
340
+ dhurandhar test --validate
341
+ ```
342
+
343
+ ## Integration with Engineering-First
344
+
345
+ Test-First Agile **complements** (not replaces) the engineering-first approach:
346
+
347
+ | Layer | Focus | Artifacts |
348
+ |-------|-------|-----------|
349
+ | Engineering-First | Services, Entities, Tech Stack | SDM: services, entities |
350
+ | Test-First Agile | User Journeys, API Contracts | SDM: epics, stories, tasks |
351
+ | Both | Implementation | Code that passes tests |
352
+
353
+ ## Example: Complete Flow
354
+
355
+ See `docs/test-first-example.md` for a complete walkthrough.
356
+
357
+ ---
358
+
359
+ **Dhurandhar: Engineering-First + Test-First = Zero Cognitive Overhead**
@@ -0,0 +1,279 @@
1
+ # Dhurandhar Architecture
2
+
3
+ This document describes the internal architecture of the Dhurandhar framework.
4
+
5
+ ## Overview
6
+
7
+ Dhurandhar is built as a modular, YAML-driven framework for system design. It consists of:
8
+
9
+ 1. **CLI Layer**: Command-line interface for user interaction
10
+ 2. **Core Libraries**: Business logic and utilities
11
+ 3. **Module System**: Pluggable design modules
12
+ 4. **Configuration Engine**: YAML-based configuration management
13
+ 5. **Validation System**: Schema and rule validation
14
+
15
+ ## Architecture Diagram
16
+
17
+ ```
18
+ ┌─────────────────────────────────────────────────────┐
19
+ │ CLI Layer │
20
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
21
+ │ │ install │ │ config │ │ module │ ... │
22
+ │ └──────────┘ └──────────┘ └──────────┘ │
23
+ └─────────────────────┬───────────────────────────────┘
24
+
25
+ ┌─────────────────────▼───────────────────────────────┐
26
+ │ Core Libraries │
27
+ │ ┌─────────────────┐ ┌─────────────────┐ │
28
+ │ │ ConfigManager │ │ ModuleManager │ │
29
+ │ └─────────────────┘ └─────────────────┘ │
30
+ │ ┌─────────────────┐ ┌─────────────────┐ │
31
+ │ │ FileSystem │ │ Validators │ │
32
+ │ └─────────────────┘ └─────────────────┘ │
33
+ └─────────────────────┬───────────────────────────────┘
34
+
35
+ ┌─────────────────────▼───────────────────────────────┐
36
+ │ Module System │
37
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
38
+ │ │ Core │ │ Example │ │ Custom │ │
39
+ │ └──────────┘ └──────────┘ └──────────┘ │
40
+ └──────────────────────────────────────────────────────┘
41
+ ```
42
+
43
+ ## Components
44
+
45
+ ### CLI Layer (`tools/cli/`)
46
+
47
+ **Purpose**: User interface and command routing
48
+
49
+ **Components**:
50
+ - `dhurandhar.js`: Main CLI entry point
51
+ - `commands/install.js`: Framework installation
52
+ - `commands/config.js`: Configuration management
53
+ - `commands/module.js`: Module operations
54
+ - `commands/validate.js`: Validation operations
55
+
56
+ **Technologies**:
57
+ - `commander`: CLI framework
58
+ - `@clack/prompts`: Interactive prompts
59
+ - `chalk`: Terminal styling
60
+
61
+ ### Core Libraries (`tools/lib/`)
62
+
63
+ #### ConfigManager
64
+
65
+ **Purpose**: Manages YAML-based configuration
66
+
67
+ **Key Features**:
68
+ - Load/save configuration files
69
+ - Variable substitution (`{variable}` syntax)
70
+ - Nested value access (dot notation)
71
+ - Configuration validation
72
+
73
+ **File**: `tools/lib/config-manager.js`
74
+
75
+ #### ModuleManager
76
+
77
+ **Purpose**: Module discovery and lifecycle management
78
+
79
+ **Key Features**:
80
+ - List available modules
81
+ - Install/uninstall modules
82
+ - Dependency resolution
83
+ - Module metadata parsing
84
+
85
+ **File**: `tools/lib/module-manager.js`
86
+
87
+ #### FileSystem
88
+
89
+ **Purpose**: File system operations abstraction
90
+
91
+ **Key Features**:
92
+ - Directory management
93
+ - File copying
94
+ - Pattern matching (glob)
95
+ - JSON/YAML helpers
96
+
97
+ **File**: `tools/lib/filesystem.js`
98
+
99
+ #### Validators
100
+
101
+ **Purpose**: Configuration and module validation
102
+
103
+ **Components**:
104
+ - `ConfigValidator`: Validates configuration structure
105
+ - `ModuleValidator`: Validates module definitions
106
+
107
+ **Files**: `tools/lib/validators/`
108
+
109
+ ### Module System (`src/`)
110
+
111
+ #### Core Module (`src/core/`)
112
+
113
+ **Purpose**: Essential framework components
114
+
115
+ **Contents**:
116
+ - Base templates for design modules
117
+ - Schema definitions
118
+ - Core utilities
119
+
120
+ #### Design Modules (`src/modules/`)
121
+
122
+ **Purpose**: Pluggable system designs
123
+
124
+ **Structure**:
125
+ ```
126
+ module-name/
127
+ ├── module.yaml # Module definition
128
+ ├── README.md # Documentation
129
+ ├── templates/ # Design templates
130
+ └── utilities/ # Helper scripts
131
+ ```
132
+
133
+ ## Data Flow
134
+
135
+ ### Installation Flow
136
+
137
+ ```
138
+ User runs: dhurandhar install
139
+
140
+ CLI prompts for configuration
141
+
142
+ ConfigManager creates .dhurandhar/config.yaml
143
+
144
+ FileSystem creates directory structure
145
+
146
+ ModuleInstaller copies selected modules
147
+
148
+ Installation complete
149
+ ```
150
+
151
+ ### Module Installation Flow
152
+
153
+ ```
154
+ User runs: dhurandhar module --add example
155
+
156
+ ModuleManager finds module in src/modules/
157
+
158
+ Checks dependencies
159
+
160
+ Installs dependencies first (recursive)
161
+
162
+ FileSystem copies module to .dhurandhar/modules/
163
+
164
+ ConfigManager updates config.yaml
165
+
166
+ Module installed
167
+ ```
168
+
169
+ ### Validation Flow
170
+
171
+ ```
172
+ User runs: dhurandhar validate
173
+
174
+ ConfigValidator checks .dhurandhar/config.yaml
175
+
176
+ ModuleValidator checks each installed module
177
+
178
+ Returns errors and warnings
179
+
180
+ Exit with appropriate status code
181
+ ```
182
+
183
+ ## Configuration System
184
+
185
+ ### Configuration File Structure
186
+
187
+ ```yaml
188
+ version: "0.1.0"
189
+ projectName: my-project
190
+ userName: User
191
+ outputFolder: _dhurandhar-output
192
+ modules: [core, example]
193
+ settings:
194
+ created: "2024-01-01T00:00:00Z"
195
+ lastModified: "2024-01-01T00:00:00Z"
196
+ variables:
197
+ projectRoot: /path/to/project
198
+ configDir: /path/to/project/.dhurandhar
199
+ ```
200
+
201
+ ### Variable Substitution
202
+
203
+ Variables use `{key}` syntax:
204
+
205
+ ```yaml
206
+ output: "{projectRoot}/{outputFolder}/designs"
207
+ # Resolves to: "/path/to/project/_dhurandhar-output/designs"
208
+ ```
209
+
210
+ ## Module System
211
+
212
+ ### Module Definition Schema
213
+
214
+ See `src/core/schemas/design-module-schema.yaml` for complete schema.
215
+
216
+ Key fields:
217
+ - **code**: Unique identifier
218
+ - **name**: Display name
219
+ - **version**: Semantic version
220
+ - **dependencies**: Required modules
221
+ - **design_components**: System components
222
+ - **relationships**: Component connections
223
+ - **build_processes**: Workflows
224
+
225
+ ### Dependency Resolution
226
+
227
+ Modules can depend on other modules. Dependencies are:
228
+ 1. Declared in `module.yaml`
229
+ 2. Automatically installed when parent is installed
230
+ 3. Validated before uninstallation
231
+ 4. Recursively resolved
232
+
233
+ ## Extension Points
234
+
235
+ Dhurandhar is designed to be extended:
236
+
237
+ 1. **Custom Modules**: Create new design modules
238
+ 2. **Custom Validators**: Add validation rules
239
+ 3. **Custom Commands**: Extend CLI
240
+ 4. **Custom Templates**: Add design templates
241
+ 5. **Custom Utilities**: Add helper scripts
242
+
243
+ ## File Structure
244
+
245
+ ```
246
+ .dhurandhar/ # Framework installation
247
+ ├── config.yaml # Project configuration
248
+ ├── modules/ # Installed modules
249
+ │ ├── core/
250
+ │ └── example/
251
+ └── cache/ # Cache directory
252
+
253
+ _dhurandhar-output/ # Generated outputs
254
+ └── designs/ # Design artifacts
255
+ ```
256
+
257
+ ## Design Philosophy
258
+
259
+ Inspired by Bmad-Method, Dhurandhar adopts:
260
+
261
+ 1. **Skills-based Architecture** → Module System
262
+ 2. **YAML Configuration** → Design Definitions
263
+ 3. **CLI Installer** → Framework Setup
264
+ 4. **Validation Framework** → Quality Assurance
265
+ 5. **Modular Structure** → Extensibility
266
+
267
+ ## Technology Stack
268
+
269
+ - **Runtime**: Node.js 20+
270
+ - **CLI**: Commander, Clack
271
+ - **Configuration**: js-yaml, yaml
272
+ - **File System**: fs-extra, glob
273
+ - **Utilities**: chalk, picocolors
274
+
275
+ ## Next Steps
276
+
277
+ - [Getting Started](getting-started.md)
278
+ - [Module Development](module-development.md)
279
+ - [CLI Reference](cli-reference.md)