mdan-cli 2.5.0 → 2.6.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,379 @@
1
+ # Resume Protocol
2
+
3
+ > MDAN-AUTO v1.0 Context Resume Procedure
4
+
5
+ ## Overview
6
+
7
+ The resume protocol defines how MDAN-AUTO resumes execution from a saved context file, ensuring seamless continuation after token limits or interruptions.
8
+
9
+ ## Resume Command
10
+
11
+ ```bash
12
+ mdan auto resume /tmp/mdan-save-[timestamp].json
13
+ ```
14
+
15
+ ## Resume Process
16
+
17
+ ### Step 1: Load Save File
18
+
19
+ 1. Locate save file
20
+ 2. Validate file exists and is readable
21
+ 3. Parse JSON content
22
+ 4. Validate format version
23
+
24
+ ### Step 2: Validate Save State
25
+
26
+ Check:
27
+
28
+ - [ ] Version is compatible (1.0)
29
+ - [ ] All required fields present
30
+ - [ ] JSON is valid
31
+ - [ ] File is not corrupted
32
+ - [ ] Timestamp is recent (optional)
33
+
34
+ If validation fails:
35
+ - Log error
36
+ - Exit with error code
37
+ - Provide recovery instructions
38
+
39
+ ### Step 3: Restore State
40
+
41
+ Restore the following:
42
+
43
+ 1. **Project Information**
44
+ - Project name
45
+ - Description
46
+ - Tech stack
47
+
48
+ 2. **Phase State**
49
+ - Current phase
50
+ - Completed phases
51
+ - Phase status
52
+
53
+ 3. **Context**
54
+ - Conversation history
55
+ - Artifacts
56
+ - Decisions
57
+
58
+ 4. **Configuration**
59
+ - Token limit
60
+ - Save threshold
61
+ - Output directory
62
+ - Other settings
63
+
64
+ 5. **Debates**
65
+ - Debate history
66
+ - Decisions made
67
+
68
+ 6. **Quality Gates**
69
+ - Gate status for each phase
70
+
71
+ ### Step 4: Validate Environment
72
+
73
+ Check:
74
+
75
+ - [ ] Required tools installed (dotnet, docker, etc.)
76
+ - [ ] Output directory exists
77
+ - [ ] Sufficient disk space
78
+ - [ ] Network connectivity (if needed)
79
+ - [ ] API credentials valid
80
+
81
+ If environment check fails:
82
+ - Log error
83
+ - Exit with error code
84
+ - Provide setup instructions
85
+
86
+ ### Step 5: Resume Execution
87
+
88
+ 1. Log resume start
89
+ 2. Display resume summary
90
+ 3. Continue from `phases.current`
91
+ 4. Increment `metadata.resume_count`
92
+ 5. Execute remaining phases
93
+
94
+ ## Resume Summary
95
+
96
+ Display this summary when resuming:
97
+
98
+ ```
99
+ ╔════════════════════════════════════════════════════════════╗
100
+ ║ MDAN-AUTO v1.0 - Resume Execution ║
101
+ ╠════════════════════════════════════════════════════════════╣
102
+ ║ Project: MyProject ║
103
+ ║ Tech Stack: C#/.NET/Blazor/SQL Server/Azure ║
104
+ ║ ║
105
+ ║ Current Phase: IMPLEMENT ║
106
+ ║ Completed: LOAD, DISCOVER, PLAN, ARCHITECT ║
107
+ ║ Remaining: IMPLEMENT, TEST, DEPLOY, DOC ║
108
+ ║ ║
109
+ ║ Save File: /tmp/mdan-save-1705310400.json ║
110
+ ║ Save Time: 2024-01-15 10:23:45 UTC ║
111
+ ║ Resume Count: 1 ║
112
+ ║ ║
113
+ ║ Token Usage: 102,400 / 128,000 (80%) ║
114
+ ║ ║
115
+ ║ Resuming execution... ║
116
+ ╚════════════════════════════════════════════════════════════╝
117
+ ```
118
+
119
+ ## Phase Resume Logic
120
+
121
+ ### Resume from Pending Phase
122
+
123
+ If phase status is `pending`:
124
+ - Start phase from beginning
125
+ - Execute all phase tasks
126
+ - Mark as `in_progress`
127
+
128
+ ### Resume from In-Progress Phase
129
+
130
+ If phase status is `in_progress`:
131
+ - Check for partial artifacts
132
+ - Determine last completed task
133
+ - Continue from next task
134
+ - If cannot determine, restart phase
135
+
136
+ ### Resume from Failed Phase
137
+
138
+ If phase status is `failed`:
139
+ - Check error details
140
+ - Determine if recoverable
141
+ - If recoverable, retry phase
142
+ - If not recoverable, abort
143
+
144
+ ### Resume from Complete Phase
145
+
146
+ If phase status is `complete`:
147
+ - Skip phase
148
+ - Move to next phase
149
+ - Verify quality gate passed
150
+
151
+ ## Artifact Restoration
152
+
153
+ ### File Artifacts
154
+
155
+ For each artifact in `context.artifacts`:
156
+
157
+ 1. Check if file exists
158
+ 2. If exists, verify content matches
159
+ 3. If missing or different, recreate from saved content
160
+ 4. Update file timestamps
161
+
162
+ ### In-Memory Artifacts
163
+
164
+ For in-memory artifacts:
165
+ - Restore from `context.artifacts`
166
+ - Keep in memory for execution
167
+ - Save to disk when needed
168
+
169
+ ## Conversation History Restoration
170
+
171
+ ### History Validation
172
+
173
+ 1. Validate conversation history structure
174
+ 2. Check for corrupted entries
175
+ 3. Remove invalid entries
176
+ 4. Log any issues
177
+
178
+ ### History Trimming
179
+
180
+ If conversation history is too long:
181
+ - Keep last N messages (configurable)
182
+ - Keep system messages
183
+ - Keep critical decisions
184
+ - Log trim operation
185
+
186
+ ## Decision Restoration
187
+
188
+ Restore all decisions from `context.decisions`:
189
+
190
+ 1. Load decision history
191
+ 2. Apply decisions to current state
192
+ 3. Log restored decisions
193
+ 4. Use for future debates
194
+
195
+ ## Quality Gate Validation
196
+
197
+ For each completed phase:
198
+
199
+ 1. Check quality gate status
200
+ 2. If gate failed:
201
+ - Log warning
202
+ - Consider re-running phase
203
+ - Or continue with warning
204
+
205
+ ## Error Handling
206
+
207
+ ### Load Errors
208
+
209
+ If save file cannot be loaded:
210
+ - Log error with details
211
+ - Exit with error code 1
212
+ - Provide recovery instructions
213
+
214
+ ### Validation Errors
215
+
216
+ If save state is invalid:
217
+ - Log validation errors
218
+ - Exit with error code 2
219
+ - Provide fix instructions
220
+
221
+ ### Resume Errors
222
+
223
+ If resume fails:
224
+ - Log error with context
225
+ - Save current state
226
+ - Exit with error code 3
227
+ - Provide manual recovery steps
228
+
229
+ ## Recovery Instructions
230
+
231
+ ### Save File Not Found
232
+
233
+ ```
234
+ Error: Save file not found: /tmp/mdan-save-1705310400.json
235
+
236
+ Recovery:
237
+ 1. Check file path is correct
238
+ 2. Look for recent saves in /tmp/
239
+ 3. Use: ls -lt /tmp/mdan-save-*.json
240
+ 4. If no saves found, start new execution
241
+ ```
242
+
243
+ ### Invalid Save Format
244
+
245
+ ```
246
+ Error: Invalid save format: version mismatch
247
+
248
+ Recovery:
249
+ 1. Check save file version
250
+ 2. Update MDAN-AUTO to latest version
251
+ 3. Or manually migrate save file
252
+ ```
253
+
254
+ ### Missing Artifacts
255
+
256
+ ```
257
+ Error: Missing artifact: docs/discover.md
258
+
259
+ Recovery:
260
+ 1. Check if artifact was saved
261
+ 2. Recreate from saved content
262
+ 3. Or re-run DISCOVER phase
263
+ ```
264
+
265
+ ### Environment Issues
266
+
267
+ ```
268
+ Error: Required tool not found: dotnet
269
+
270
+ Recovery:
271
+ 1. Install missing tool
272
+ 2. Verify installation
273
+ 3. Resume execution
274
+ ```
275
+
276
+ ## Resume Logging
277
+
278
+ Log all resume operations:
279
+
280
+ ```
281
+ [2024-01-15 10:30:00] Starting resume from /tmp/mdan-save-1705310400.json
282
+ [2024-01-15 10:30:01] Loading save file...
283
+ [2024-01-15 10:30:02] Validating save state...
284
+ [2024-01-15 10:30:03] Restoring project state...
285
+ [2024-01-15 10:30:04] Restoring conversation history (45 messages)
286
+ [2024-01-15 10:30:05] Restoring artifacts (3 files)
287
+ [2024-01-15 10:30:06] Restoring decisions (2 decisions)
288
+ [2024-01-15 10:30:07] Validating environment...
289
+ [2024-01-15 10:30:08] Environment valid
290
+ [2024-01-15 10:30:09] Resuming from phase: IMPLEMENT
291
+ [2024-01-15 10:30:10] Resume count: 1
292
+ [2024-01-15 10:30:11] Continuing execution...
293
+ ```
294
+
295
+ ## Resume Count Tracking
296
+
297
+ Track resume attempts in `metadata.resume_count`:
298
+
299
+ - 0: First execution
300
+ - 1: First resume
301
+ - 2: Second resume
302
+ - etc.
303
+
304
+ If resume count > threshold (default 5):
305
+ - Log warning
306
+ - Consider aborting
307
+ - Require manual intervention
308
+
309
+ ## Auto-Resume
310
+
311
+ For automatic resume after context save:
312
+
313
+ 1. Detect context save
314
+ 2. Wait for token limit reset
315
+ 3. Automatically resume from latest save
316
+ 4. Continue execution
317
+
318
+ ## Manual Resume
319
+
320
+ For manual resume:
321
+
322
+ 1. User provides save file path
323
+ 2. Validate and load
324
+ 3. Display summary
325
+ 4. Ask for confirmation (optional)
326
+ 5. Resume execution
327
+
328
+ ## Resume Verification
329
+
330
+ After resume, verify:
331
+
332
+ - [ ] All artifacts restored
333
+ - [ ] Conversation history valid
334
+ - [ ] Decisions applied
335
+ - [ ] Environment ready
336
+ - [ ] Can continue execution
337
+
338
+ ## Resume Failure Recovery
339
+
340
+ If resume fails completely:
341
+
342
+ 1. Save error state
343
+ 2. Provide detailed error report
344
+ 3. Suggest recovery options:
345
+ - Fix and retry resume
346
+ - Start new execution
347
+ - Manual intervention
348
+
349
+ ## Example Resume Flow
350
+
351
+ ```
352
+ 1. User runs: mdan auto resume /tmp/mdan-save-1705310400.json
353
+ 2. MDAN-AUTO loads save file
354
+ 3. Validates save state (OK)
355
+ 4. Restores project state
356
+ 5. Restores conversation history
357
+ 6. Restores artifacts
358
+ 7. Validates environment (OK)
359
+ 8. Displays resume summary
360
+ 9. Resumes from IMPLEMENT phase
361
+ 10. Continues execution
362
+ 11. Completes remaining phases
363
+ 12. MISSION COMPLETE ✅
364
+ ```
365
+
366
+ ## Best Practices
367
+
368
+ 1. **Always validate** before resuming
369
+ 2. **Log everything** for debugging
370
+ 3. **Handle errors gracefully**
371
+ 4. **Provide clear recovery instructions**
372
+ 5. **Track resume attempts**
373
+ 6. **Clean up old saves** after success
374
+ 7. **Backup saves** before resume
375
+ 8. **Verify environment** before resume
376
+
377
+ ## Version
378
+
379
+ MDAN-AUTO Resume Protocol v1.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdan-cli",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Multi-Agent Development Agentic Network - A modern, adaptive, LLM-agnostic methodology for building software",
5
5
  "main": "cli/mdan.js",
6
6
  "bin": {
@@ -0,0 +1,165 @@
1
+ # Auto Phase 1: LOAD
2
+
3
+ > Load project context and requirements
4
+
5
+ ## Objective
6
+
7
+ Load and initialize the project context, including requirements, existing code, and configuration.
8
+
9
+ ## Tasks
10
+
11
+ ### 1.1 Load Project Configuration
12
+
13
+ - Read project configuration file
14
+ - Validate configuration
15
+ - Load environment variables
16
+ - Set up project structure
17
+
18
+ ### 1.2 Load Requirements
19
+
20
+ - Read requirements document
21
+ - Parse user stories
22
+ - Identify acceptance criteria
23
+ - Load constraints and assumptions
24
+
25
+ ### 1.3 Load Existing Code
26
+
27
+ - Check for existing codebase
28
+ - If exists, analyze structure
29
+ - Identify tech stack
30
+ - Load dependencies
31
+
32
+ ### 1.4 Initialize Context
33
+
34
+ - Create initial context state
35
+ - Set token tracking
36
+ - Initialize logging
37
+ - Create output directories
38
+
39
+ ### 1.5 Validate Environment
40
+
41
+ - Check required tools
42
+ - Verify dependencies
43
+ - Validate file permissions
44
+ - Check disk space
45
+
46
+ ## Output
47
+
48
+ Generate `docs/load.md`:
49
+
50
+ ```markdown
51
+ # Load Phase
52
+
53
+ ## Project Information
54
+
55
+ **Name**: [Project name]
56
+ **Description**: [Project description]
57
+ **Version**: [Version]
58
+
59
+ ## Requirements
60
+
61
+ ### User Stories
62
+
63
+ - [Story 1]
64
+ - [Story 2]
65
+ - [Story 3]
66
+
67
+ ### Acceptance Criteria
68
+
69
+ - [Criteria 1]
70
+ - [Criteria 2]
71
+ - [Criteria 3]
72
+
73
+ ### Constraints
74
+
75
+ - [Constraint 1]
76
+ - [Constraint 2]
77
+
78
+ ## Tech Stack
79
+
80
+ - **Language**: C#
81
+ - **Framework**: .NET 8.0
82
+ - **UI**: Blazor Server
83
+ - **Database**: SQL Server 2022
84
+ - **Cloud**: Azure
85
+
86
+ ## Existing Code
87
+
88
+ [Analysis of existing code if present]
89
+
90
+ ## Environment
91
+
92
+ - **Tools**: [List of tools]
93
+ - **Dependencies**: [List of dependencies]
94
+ - **Status**: Ready/Not Ready
95
+
96
+ ## Next Steps
97
+
98
+ Proceed to DISCOVER phase.
99
+ ```
100
+
101
+ ## Quality Gates
102
+
103
+ - [ ] Project configuration loaded
104
+ - [ ] Requirements identified
105
+ - [ ] Environment validated
106
+ - [ ] Context initialized
107
+
108
+ ## Success Criteria
109
+
110
+ - All project information loaded
111
+ - Requirements clearly defined
112
+ - Environment ready for development
113
+ - No critical errors
114
+
115
+ ## Error Handling
116
+
117
+ ### Configuration Not Found
118
+
119
+ - Log error
120
+ - Use default configuration
121
+ - Continue with warning
122
+
123
+ ### Requirements Not Found
124
+
125
+ - Log error
126
+ - Ask for requirements (if interactive)
127
+ - Or use placeholder requirements
128
+
129
+ ### Environment Not Ready
130
+
131
+ - Log error
132
+ - Provide setup instructions
133
+ - Abort if critical
134
+
135
+ ## Token Management
136
+
137
+ Track token usage:
138
+ - Initial load: ~1,000 tokens
139
+ - Context initialization: ~500 tokens
140
+ - Environment validation: ~500 tokens
141
+
142
+ Total: ~2,000 tokens
143
+
144
+ ## Logging
145
+
146
+ ```
147
+ [timestamp] Starting LOAD phase
148
+ [timestamp] Loading project configuration...
149
+ [timestamp] Loading requirements...
150
+ [timestamp] Loading existing code...
151
+ [timestamp] Initializing context...
152
+ [timestamp] Validating environment...
153
+ [timestamp] Token usage: X / 128,000 (X%)
154
+ [timestamp] LOAD phase complete
155
+ ```
156
+
157
+ ## Completion Signal
158
+
159
+ ```
160
+ PHASE 1 COMPLETE ✅
161
+ ```
162
+
163
+ ## Version
164
+
165
+ MDAN-AUTO Phase 1: LOAD v1.0