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,392 @@
1
+ # Test-First Agile - Complete Example
2
+
3
+ ## Scenario: Building Authentication System
4
+
5
+ Let's build a complete authentication system using Dhurandhar's test-first approach.
6
+
7
+ ## Step 1: Initialize Framework
8
+
9
+ ```bash
10
+ $ dhurandhar install
11
+
12
+ 🔧 Dhurandhar - Engineering-First System Design
13
+
14
+ ? Project identifier: my-auth-system
15
+ ? Architecture type: microservices
16
+ ? Primary language: go
17
+
18
+ ✓ Framework installed!
19
+
20
+ System initialized:
21
+ SYSTEM_DESIGN_MAP.yaml - Persistent architecture state
22
+ ```
23
+
24
+ ## Step 2: Define Services (Engineering-First)
25
+
26
+ ```bash
27
+ $ dhurandhar service add "auth: JWT authentication and session management"
28
+
29
+ ? Framework: Echo
30
+ ? Database: PostgreSQL
31
+
32
+ ✓ auth-service added: Go/Echo/PostgreSQL on port 8080
33
+ ✓ Updated SYSTEM_DESIGN_MAP.yaml
34
+ ```
35
+
36
+ ## Step 3: Define Entities (Engineering-First)
37
+
38
+ ```bash
39
+ $ dhurandhar entity add User
40
+
41
+ ? Add custom attributes now? Yes
42
+ ? Attribute name: email
43
+ ? Type: varchar
44
+ ? Add another? Yes
45
+ ? Attribute name: password_hash
46
+ ? Type: varchar
47
+ ? Add another? No
48
+
49
+ ✓ User entity added to data model
50
+ ```
51
+
52
+ ```bash
53
+ $ dhurandhar entity add Session
54
+
55
+ ? Add custom attributes now? Yes
56
+ ? Attribute name: token
57
+ ? Type: varchar
58
+ ? Add another? Yes
59
+ ? Attribute name: expires_at
60
+ ? Type: timestamp
61
+ ? Add another? No
62
+
63
+ ✓ Session entity added
64
+ ```
65
+
66
+ ```bash
67
+ $ dhurandhar entity --relate
68
+
69
+ ? From entity: Session
70
+ ? To entity: User
71
+ ? Relationship type: many_to_one
72
+
73
+ ✓ Relationship added: Session → User
74
+ ```
75
+
76
+ ## Step 4: Define Epic (Test-First Agile)
77
+
78
+ ```bash
79
+ $ dhurandhar epic add "User Authentication & Authorization"
80
+
81
+ ? Technical description: JWT-based auth with email/password and OAuth2
82
+
83
+ ✓ Epic EPIC-001 added
84
+
85
+ Next: Add Stories
86
+ dhurandhar story add --epic EPIC-001
87
+ ```
88
+
89
+ ## Step 5: Define Stories (Test-First Agile)
90
+
91
+ ### Story 1: Email/Password Login
92
+
93
+ ```bash
94
+ $ dhurandhar story add "Email/Password Login" --epic EPIC-001
95
+
96
+ Technical specification (max 3 questions):
97
+
98
+ ? 1. Target service: auth-service
99
+ ? 2. API endpoint: /api/v1/auth/login
100
+ ? 3. HTTP method: POST
101
+
102
+ ✓ Story STORY-001 added with 2 tasks
103
+
104
+ Next: Generate contract tests
105
+ dhurandhar test --generate
106
+ ```
107
+
108
+ ### Story 2: Token Refresh
109
+
110
+ ```bash
111
+ $ dhurandhar story add "JWT Token Refresh" --epic EPIC-001
112
+
113
+ ? 1. Target service: auth-service
114
+ ? 2. API endpoint: /api/v1/auth/refresh
115
+ ? 3. HTTP method: POST
116
+
117
+ ✓ Story STORY-002 added with 2 tasks
118
+ ```
119
+
120
+ ### Story 3: Logout
121
+
122
+ ```bash
123
+ $ dhurandhar story add "User Logout" --epic EPIC-001
124
+
125
+ ? 1. Target service: auth-service
126
+ ? 2. API endpoint: /api/v1/auth/logout
127
+ ? 3. HTTP method: POST
128
+
129
+ ✓ Story STORY-003 added with 2 tasks
130
+ ```
131
+
132
+ ## Step 6: Generate Contract Tests
133
+
134
+ ```bash
135
+ $ dhurandhar test --init
136
+
137
+ 🔧 Initialize Test Infrastructure
138
+
139
+ ✓ Test infrastructure ready
140
+ ```
141
+
142
+ ```bash
143
+ $ dhurandhar test --generate
144
+
145
+ 📋 Generate Contract-First Test Suite
146
+
147
+ ✓ Generated 9 test suites
148
+
149
+ Generated files:
150
+ tests/contracts/story-001-standard.test.js
151
+ tests/contracts/story-001-errors.test.js
152
+ tests/edge-cases/story-001-edge.test.js
153
+ tests/contracts/story-002-standard.test.js
154
+ tests/contracts/story-002-errors.test.js
155
+ tests/edge-cases/story-002-edge.test.js
156
+ tests/contracts/story-003-standard.test.js
157
+ tests/contracts/story-003-errors.test.js
158
+ tests/edge-cases/story-003-edge.test.js
159
+
160
+ Next steps:
161
+ 1. Install test dependencies: npm install -D vitest
162
+ 2. Review generated tests in tests/ directory
163
+ 3. Run tests: npm test
164
+ 4. Implement services to pass the tests
165
+ ```
166
+
167
+ ## Step 7: Review Generated Tests
168
+
169
+ ### Example: tests/contracts/story-001-standard.test.js
170
+
171
+ ```javascript
172
+ /**
173
+ * Contract Test: Email/Password Login
174
+ * Story: STORY-001
175
+ * Service: auth-service
176
+ * Endpoint: POST /api/v1/auth/login
177
+ */
178
+
179
+ import { describe, it, expect } from 'vitest';
180
+ import { apiClient } from '../utils/api-client';
181
+
182
+ describe('Email/Password Login - Standard Flows', () => {
183
+ it('should login successfully with valid credentials', async () => {
184
+ const response = await apiClient.post('/api/v1/auth/login', {
185
+ email: 'user@example.com',
186
+ password: 'ValidPass123!',
187
+ });
188
+
189
+ expect(response.status).toBe(200);
190
+ expect(response.data).toHaveProperty('access_token');
191
+ expect(response.data).toHaveProperty('refresh_token');
192
+ expect(response.data).toHaveProperty('expires_in');
193
+ });
194
+
195
+ it('should return user information', async () => {
196
+ const response = await apiClient.post('/api/v1/auth/login', {
197
+ email: 'user@example.com',
198
+ password: 'ValidPass123!',
199
+ });
200
+
201
+ expect(response.data).toHaveProperty('user');
202
+ expect(response.data.user).toHaveProperty('id');
203
+ expect(response.data.user).toHaveProperty('email');
204
+ expect(response.data.user.email).toBe('user@example.com');
205
+ });
206
+ });
207
+ ```
208
+
209
+ ## Step 8: Run Tests (Before Implementation)
210
+
211
+ ```bash
212
+ $ npm install -D vitest
213
+ $ npm test
214
+
215
+ FAIL tests/contracts/story-001-standard.test.js
216
+ ✕ Email/Password Login - Standard Flows
217
+ ✕ should login successfully with valid credentials (0 ms)
218
+ NetworkError: connect ECONNREFUSED localhost:8080
219
+
220
+ FAIL tests/contracts/story-001-errors.test.js
221
+ ✕ Email/Password Login - Error States
222
+ ✕ should return 400 for missing email (0 ms)
223
+ ✕ should return 401 for invalid password (0 ms)
224
+
225
+ Test Suites: 9 failed, 9 total
226
+ Tests: 27 failed, 27 total
227
+ ```
228
+
229
+ **This is correct!** Tests fail because we haven't implemented the service yet.
230
+
231
+ ## Step 9: Implement Service (Guided by Tests)
232
+
233
+ Now implement `auth-service` to pass the contract tests:
234
+
235
+ 1. Create Go service with Echo framework
236
+ 2. Implement `/api/v1/auth/login` endpoint
237
+ 3. Follow the contract defined in tests:
238
+ - Accept `email` and `password` in request body
239
+ - Return `access_token`, `refresh_token`, `expires_in`, `user`
240
+ - Return 400 for missing fields
241
+ - Return 401 for invalid credentials
242
+
243
+ ## Step 10: Run Tests (After Implementation)
244
+
245
+ ```bash
246
+ $ npm test
247
+
248
+ PASS tests/contracts/story-001-standard.test.js
249
+ ✓ Email/Password Login - Standard Flows
250
+ ✓ should login successfully with valid credentials (45 ms)
251
+ ✓ should return user information (12 ms)
252
+
253
+ PASS tests/contracts/story-001-errors.test.js
254
+ ✓ Email/Password Login - Error States
255
+ ✓ should return 400 for missing email (8 ms)
256
+ ✓ should return 401 for invalid password (15 ms)
257
+
258
+ Test Suites: 9 passed, 9 total
259
+ Tests: 27 passed, 27 total
260
+ ```
261
+
262
+ **Success!** Implementation passes all contract tests.
263
+
264
+ ## Step 11: Validate Coverage
265
+
266
+ ```bash
267
+ $ dhurandhar test --validate
268
+
269
+ ✅ Validate Story Coverage
270
+
271
+ Coverage Report:
272
+ Total Stories: 3
273
+ Test Coverage: 100% (3/3)
274
+ Implementation: 100% (3/3)
275
+
276
+ ✓ Full coverage!
277
+ ```
278
+
279
+ ## Step 12: View Complete Architecture
280
+
281
+ ```bash
282
+ $ dhurandhar context --full
283
+
284
+ 🏗️ System Architecture Context
285
+
286
+ Project Metadata
287
+ Name: my-auth-system
288
+ Version: 1.0.0
289
+ Architecture: microservices
290
+
291
+ Tech Stack
292
+ Languages: Go
293
+ Frameworks: Echo
294
+ Databases: PostgreSQL
295
+
296
+ Entities (2)
297
+ User (5 attributes)
298
+ Session (4 attributes)
299
+ many_to_one → User
300
+
301
+ Services (1)
302
+ auth-service
303
+ JWT authentication and session management
304
+ Stack: Go/Echo/PostgreSQL
305
+ API: rest /api/v1/auth :8080
306
+
307
+ Agile Blueprint
308
+ Epics: 1
309
+ Stories: 3
310
+ Test Coverage: 100%
311
+
312
+ This context is persisted in SYSTEM_DESIGN_MAP.yaml
313
+ ```
314
+
315
+ ## Benefits Demonstrated
316
+
317
+ ### 1. Speed
318
+
319
+ - **Traditional**: 2-3 days of requirements gathering, planning, design
320
+ - **Dhurandhar**: 15 minutes from concept to complete test suite
321
+
322
+ ### 2. Clarity
323
+
324
+ - Tests define exact API contract
325
+ - No ambiguity about what to implement
326
+ - Implementation guided by failing tests
327
+
328
+ ### 3. Coverage
329
+
330
+ - 100% test coverage before implementation
331
+ - All error states tested
332
+ - Edge cases identified by Edge Case Hunter
333
+
334
+ ### 4. Persistence
335
+
336
+ - All decisions in SYSTEM_DESIGN_MAP.yaml
337
+ - Next session: instant context rehydration
338
+ - No rediscovery needed
339
+
340
+ ## Complete SYSTEM_DESIGN_MAP.yaml
341
+
342
+ ```yaml
343
+ metadata:
344
+ project_name: my-auth-system
345
+ architecture_type: microservices
346
+
347
+ services:
348
+ - name: auth-service
349
+ scope: "JWT authentication and session management"
350
+ tech_stack:
351
+ language: Go
352
+ framework: Echo
353
+ database: PostgreSQL
354
+
355
+ entities:
356
+ - name: User
357
+ attributes:
358
+ - name: email
359
+ type: varchar
360
+ - name: Session
361
+ relationships:
362
+ - type: many_to_one
363
+ target: User
364
+
365
+ agile_blueprint:
366
+ epics:
367
+ - id: EPIC-001
368
+ name: "User Authentication & Authorization"
369
+ stories:
370
+ - id: STORY-001
371
+ name: "Email/Password Login"
372
+ interaction_boundary:
373
+ service: auth-service
374
+ api_endpoint: /api/v1/auth/login
375
+ method: POST
376
+ tasks:
377
+ - id: TASK-001-001
378
+ type: test
379
+ status: complete
380
+ - id: TASK-001-002
381
+ type: implementation
382
+ status: complete
383
+
384
+ test_suite_status:
385
+ total_stories: 3
386
+ tested_stories: 3
387
+ coverage_percentage: 100
388
+ ```
389
+
390
+ ---
391
+
392
+ **Result**: Complete authentication system with 100% test coverage, defined and implemented in under 30 minutes.
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "dhurandhar",
4
+ "version": "1.0.0",
5
+ "description": "Engineering-First + Test-First + Strategy-Driven + Decision-Stocked Framework - Bmad-level maturity with zero cognitive fatigue",
6
+ "keywords": [
7
+ "system-design",
8
+ "architecture",
9
+ "framework",
10
+ "engineering-first",
11
+ "test-first",
12
+ "strategy-driven",
13
+ "decision-registry",
14
+ "drift-detection",
15
+ "bmad-method",
16
+ "system-design-map",
17
+ "sdm",
18
+ "architectural-patterns",
19
+ "code-generation",
20
+ "technical-decisions"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/rweb22/dhurandhar.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/rweb22/dhurandhar/issues"
28
+ },
29
+ "homepage": "https://github.com/rweb22/dhurandhar#readme",
30
+ "license": "MIT",
31
+ "author": "Dhurandhar Contributors",
32
+ "private": false,
33
+ "type": "module",
34
+ "main": "tools/cli/dhurandhar.js",
35
+ "bin": {
36
+ "dhurandhar": "tools/cli/dhurandhar.js"
37
+ },
38
+ "files": [
39
+ "tools/",
40
+ "src/",
41
+ "docs/",
42
+ "README.md",
43
+ "LICENSE",
44
+ ".dhurandhar-session-start.md"
45
+ ],
46
+ "scripts": {
47
+ "cli": "node tools/cli/dhurandhar.js",
48
+ "install:framework": "node tools/cli/dhurandhar.js install",
49
+ "config": "node tools/cli/dhurandhar.js config",
50
+ "test": "node --test test/unit/**/*.test.js",
51
+ "test:integration": "node --test test/integration/**/*.test.js",
52
+ "test:all": "npm run test && npm run test:integration",
53
+ "lint": "eslint . --ext .js,.mjs --max-warnings=0",
54
+ "lint:fix": "eslint . --ext .js,.mjs --fix",
55
+ "format:check": "prettier --check \"**/*.{js,mjs,json,yaml,yml,md}\"",
56
+ "format:fix": "prettier --write \"**/*.{js,mjs,json,yaml,yml,md}\"",
57
+ "validate:config": "node tools/lib/validators/config-validator.js",
58
+ "validate:modules": "node tools/lib/validators/module-validator.js"
59
+ },
60
+ "dependencies": {
61
+ "@clack/core": "^1.0.0",
62
+ "@clack/prompts": "^1.0.0",
63
+ "chalk": "^5.3.0",
64
+ "commander": "^14.0.0",
65
+ "fs-extra": "^11.3.0",
66
+ "glob": "^11.0.3",
67
+ "js-yaml": "^4.1.0",
68
+ "picocolors": "^1.1.1",
69
+ "yaml": "^2.7.0"
70
+ },
71
+ "devDependencies": {
72
+ "eslint": "^9.15.0",
73
+ "eslint-config-prettier": "^10.1.0",
74
+ "prettier": "^3.4.2"
75
+ },
76
+ "engines": {
77
+ "node": ">=20.0.0"
78
+ }
79
+ }
@@ -0,0 +1,92 @@
1
+ # Dhurandhar Core Module
2
+
3
+ The Core Module provides essential components and utilities for the Dhurandhar framework.
4
+
5
+ ## Overview
6
+
7
+ This module contains:
8
+
9
+ - **Base Templates**: Foundational templates for creating design modules
10
+ - **System Mapper**: Utilities for mapping and visualizing system architectures
11
+ - **Schema Definitions**: Standard schemas for design components and configurations
12
+
13
+ ## Components
14
+
15
+ ### Base Design Template
16
+
17
+ A standardized template for creating new design modules. Includes:
18
+
19
+ - Module metadata structure
20
+ - Configuration schema
21
+ - Component organization patterns
22
+ - Export definitions
23
+
24
+ ### System Mapper
25
+
26
+ Utilities for working with system designs:
27
+
28
+ - Component relationship mapping
29
+ - Dependency analysis
30
+ - Visualization helpers
31
+ - Export/import functionality
32
+
33
+ ### Schema Definitions
34
+
35
+ Standard schemas for:
36
+
37
+ - Design modules
38
+ - System components
39
+ - Configuration files
40
+ - Validation rules
41
+
42
+ ## Usage
43
+
44
+ The core module is automatically installed with the Dhurandhar framework and provides the foundation for all other modules.
45
+
46
+ ### Creating a Design Module
47
+
48
+ ```yaml
49
+ # Based on core templates
50
+ code: my-design
51
+ name: "My Design Module"
52
+ extends: core/base-design
53
+
54
+ components:
55
+ - name: frontend
56
+ type: application
57
+ - name: backend
58
+ type: service
59
+ ```
60
+
61
+ ### Using System Mapper
62
+
63
+ ```javascript
64
+ import { SystemMapper } from '@dhurandhar/core';
65
+
66
+ const mapper = new SystemMapper();
67
+ const system = await mapper.load('my-design');
68
+ const dependencies = mapper.analyzeDependencies(system);
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ The core module can be configured in `.dhurandhar/config.yaml`:
74
+
75
+ ```yaml
76
+ modules:
77
+ core:
78
+ enable_validation: true
79
+ cache_enabled: true
80
+ ```
81
+
82
+ ## Dependencies
83
+
84
+ None - this is the foundational module.
85
+
86
+ ## Version
87
+
88
+ 0.1.0
89
+
90
+ ## License
91
+
92
+ MIT