mdan-cli 2.5.1 → 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,328 @@
1
+ # Context Save Format Specification
2
+
3
+ > MDAN-AUTO v1.0 Context Persistence Format
4
+
5
+ ## Overview
6
+
7
+ Context saves are JSON files that capture the complete state of an MDAN-AUTO execution, enabling resumption after token limits or interruptions.
8
+
9
+ ## File Location
10
+
11
+ ```
12
+ /tmp/mdan-save-[timestamp].json
13
+ ```
14
+
15
+ Example: `/tmp/mdan-save-1705310400.json`
16
+
17
+ ## JSON Structure
18
+
19
+ ```json
20
+ {
21
+ "version": "1.0",
22
+ "mode": "auto",
23
+ "timestamp": "2024-01-15T10:23:45Z",
24
+ "project": {
25
+ "name": "MyProject",
26
+ "description": "Project description",
27
+ "tech_stack": {
28
+ "language": "csharp",
29
+ "framework": "dotnet",
30
+ "ui": "blazor",
31
+ "database": "sqlserver",
32
+ "cloud": "azure"
33
+ }
34
+ },
35
+ "phases": {
36
+ "current": "IMPLEMENT",
37
+ "completed": ["LOAD", "DISCOVER", "PLAN", "ARCHITECT"],
38
+ "status": {
39
+ "LOAD": "complete",
40
+ "DISCOVER": "complete",
41
+ "PLAN": "complete",
42
+ "ARCHITECT": "complete",
43
+ "IMPLEMENT": "in_progress",
44
+ "TEST": "pending",
45
+ "DEPLOY": "pending",
46
+ "DOC": "pending"
47
+ }
48
+ },
49
+ "context": {
50
+ "token_usage": {
51
+ "total": 102400,
52
+ "limit": 128000,
53
+ "percentage": 0.8
54
+ },
55
+ "conversation_history": [
56
+ {
57
+ "role": "system",
58
+ "content": "System message",
59
+ "timestamp": "2024-01-15T10:00:00Z"
60
+ },
61
+ {
62
+ "role": "user",
63
+ "content": "User message",
64
+ "timestamp": "2024-01-15T10:00:01Z"
65
+ },
66
+ {
67
+ "role": "assistant",
68
+ "content": "Assistant response",
69
+ "timestamp": "2024-01-15T10:00:05Z"
70
+ }
71
+ ],
72
+ "artifacts": {
73
+ "discover": {
74
+ "file": "docs/discover.md",
75
+ "content": "# Discover Phase\n\n..."
76
+ },
77
+ "plan": {
78
+ "file": "docs/plan.md",
79
+ "content": "# Plan\n\n#PHASE1\n..."
80
+ },
81
+ "architecture": {
82
+ "file": "docs/architecture.md",
83
+ "content": "# Architecture\n\n..."
84
+ }
85
+ },
86
+ "decisions": [
87
+ {
88
+ "id": "decision-001",
89
+ "topic": "Database Choice",
90
+ "winner": "SQL Server",
91
+ "rationale": "Azure integration and enterprise features",
92
+ "timestamp": "2024-01-15T10:05:00Z"
93
+ }
94
+ ]
95
+ },
96
+ "debates": [
97
+ {
98
+ "id": "debate-001",
99
+ "topic": "Architecture Pattern",
100
+ "question": "Should we use monolith or microservices?",
101
+ "participants": ["architect", "dev", "devops"],
102
+ "arguments": {
103
+ "architect": "Microservices for scalability",
104
+ "dev": "Monolith for simplicity",
105
+ "devops": "Microservices for deployment flexibility"
106
+ },
107
+ "winner": "architect",
108
+ "rationale": "Project requires scalability",
109
+ "timestamp": "2024-01-15T10:10:00Z"
110
+ }
111
+ ],
112
+ "errors": [],
113
+ "quality_gates": {
114
+ "LOAD": true,
115
+ "DISCOVER": true,
116
+ "PLAN": true,
117
+ "ARCHITECT": true,
118
+ "IMPLEMENT": false,
119
+ "TEST": false,
120
+ "DEPLOY": false,
121
+ "DOC": false
122
+ },
123
+ "configuration": {
124
+ "token_limit": 128000,
125
+ "save_threshold": 0.8,
126
+ "output_dir": "./mdan-auto-output",
127
+ "log_level": "INFO",
128
+ "fail_fast": true,
129
+ "debate_enabled": true
130
+ },
131
+ "metadata": {
132
+ "created_at": "2024-01-15T10:00:00Z",
133
+ "updated_at": "2024-01-15T10:23:45Z",
134
+ "save_count": 1,
135
+ "resume_count": 0
136
+ }
137
+ }
138
+ ```
139
+
140
+ ## Field Descriptions
141
+
142
+ ### Top-Level Fields
143
+
144
+ | Field | Type | Description |
145
+ |-------|------|-------------|
146
+ | `version` | string | Format version (always "1.0") |
147
+ | `mode` | string | Execution mode (always "auto") |
148
+ | `timestamp` | string | ISO 8601 timestamp of save |
149
+ | `project` | object | Project information |
150
+ | `phases` | object | Phase execution state |
151
+ | `context` | object | Execution context |
152
+ | `debates` | array | Debate history |
153
+ | `errors` | array | Error log |
154
+ | `quality_gates` | object | Quality gate status |
155
+ | `configuration` | object | Runtime configuration |
156
+ | `metadata` | object | Save metadata |
157
+
158
+ ### Project Object
159
+
160
+ | Field | Type | Description |
161
+ |-------|------|-------------|
162
+ | `name` | string | Project name |
163
+ | `description` | string | Project description |
164
+ | `tech_stack` | object | Technology stack |
165
+
166
+ ### Phases Object
167
+
168
+ | Field | Type | Description |
169
+ |-------|------|-------------|
170
+ | `current` | string | Currently executing phase |
171
+ | `completed` | array | List of completed phases |
172
+ | `status` | object | Status of each phase (pending/in_progress/complete/failed) |
173
+
174
+ ### Context Object
175
+
176
+ | Field | Type | Description |
177
+ |-------|------|-------------|
178
+ | `token_usage` | object | Token usage statistics |
179
+ | `conversation_history` | array | LLM conversation history |
180
+ | `artifacts` | object | Generated artifacts |
181
+ | `decisions` | array | Decision history |
182
+
183
+ ### Token Usage Object
184
+
185
+ | Field | Type | Description |
186
+ |-------|------|-------------|
187
+ | `total` | number | Total tokens used |
188
+ | `limit` | number | Token limit |
189
+ | `percentage` | number | Usage as decimal (0.0-1.0) |
190
+
191
+ ### Conversation History Item
192
+
193
+ | Field | Type | Description |
194
+ |-------|------|-------------|
195
+ | `role` | string | Message role (system/user/assistant) |
196
+ | `content` | string | Message content |
197
+ | `timestamp` | string | ISO 8601 timestamp |
198
+
199
+ ### Artifacts Object
200
+
201
+ | Field | Type | Description |
202
+ |-------|------|-------------|
203
+ | `[phase]` | object | Phase-specific artifacts |
204
+ | `file` | string | Artifact file path |
205
+ | `content` | string | Artifact content |
206
+
207
+ ### Debate Object
208
+
209
+ | Field | Type | Description |
210
+ |-------|------|-------------|
211
+ | `id` | string | Unique debate ID |
212
+ | `topic` | string | Debate topic |
213
+ | `question` | string | Debate question |
214
+ | `participants` | array | Participating agents |
215
+ | `arguments` | object | Agent arguments |
216
+ | `winner` | string | Winning agent |
217
+ | `rationale` | string | Decision rationale |
218
+ | `timestamp` | string | ISO 8601 timestamp |
219
+
220
+ ### Error Object
221
+
222
+ | Field | Type | Description |
223
+ |-------|------|-------------|
224
+ | `id` | string | Unique error ID |
225
+ | `phase` | string | Phase where error occurred |
226
+ | `message` | string | Error message |
227
+ | `stack_trace` | string | Stack trace (if available) |
228
+ | `timestamp` | string | ISO 8601 timestamp |
229
+ | `critical` | boolean | Whether error is critical |
230
+
231
+ ### Quality Gates Object
232
+
233
+ | Field | Type | Description |
234
+ |-------|------|-------------|
235
+ | `[phase]` | boolean | Whether quality gate passed |
236
+
237
+ ### Configuration Object
238
+
239
+ | Field | Type | Description |
240
+ |-------|------|-------------|
241
+ | `token_limit` | number | Token limit |
242
+ | `save_threshold` | number | Save threshold (0.0-1.0) |
243
+ | `output_dir` | string | Output directory |
244
+ | `log_level` | string | Log level |
245
+ | `fail_fast` | boolean | Fail-fast enabled |
246
+ | `debate_enabled` | boolean | Debate enabled |
247
+
248
+ ### Metadata Object
249
+
250
+ | Field | Type | Description |
251
+ |-------|------|-------------|
252
+ | `created_at` | string | Creation timestamp |
253
+ | `updated_at` | string | Last update timestamp |
254
+ | `save_count` | number | Number of saves |
255
+ | `resume_count` | number | Number of resumes |
256
+
257
+ ## Save Triggers
258
+
259
+ Context is saved when:
260
+
261
+ 1. Token usage ≥ 80% of limit
262
+ 2. Before critical operations
263
+ 3. On phase completion
264
+ 4. On error (before abort)
265
+ 5. Manual save command
266
+
267
+ ## Resume Process
268
+
269
+ When resuming from save:
270
+
271
+ 1. Load save file
272
+ 2. Validate version compatibility
273
+ 3. Restore conversation history
274
+ 4. Restore artifacts
275
+ 5. Resume from `phases.current`
276
+ 6. Increment `metadata.resume_count`
277
+
278
+ ## Validation
279
+
280
+ Save files must be valid JSON with all required fields. Missing or invalid fields should trigger a warning and use defaults.
281
+
282
+ ## Compression
283
+
284
+ For large saves (>1MB), consider using gzip compression:
285
+
286
+ ```
287
+ /tmp/mdan-save-[timestamp].json.gz
288
+ ```
289
+
290
+ ## Security
291
+
292
+ - Never save sensitive data (API keys, passwords, tokens)
293
+ - Sanitize conversation history before saving
294
+ - Use secure file permissions (0600)
295
+ - Delete old saves after successful completion
296
+
297
+ ## Version Compatibility
298
+
299
+ | Version | Changes |
300
+ |---------|---------|
301
+ | 1.0 | Initial version |
302
+
303
+ ## Example Usage
304
+
305
+ ```python
306
+ import json
307
+ from datetime import datetime
308
+
309
+ def save_context(state):
310
+ timestamp = int(datetime.now().timestamp())
311
+ filename = f"/tmp/mdan-save-{timestamp}.json"
312
+
313
+ with open(filename, 'w') as f:
314
+ json.dump(state, f, indent=2)
315
+
316
+ print(f"CONTEXT SAVE {filename}")
317
+
318
+ def load_context(filename):
319
+ with open(filename, 'r') as f:
320
+ state = json.load(f)
321
+
322
+ state['metadata']['resume_count'] += 1
323
+ return state
324
+ ```
325
+
326
+ ## Version
327
+
328
+ MDAN-AUTO Context Save Format v1.0
@@ -0,0 +1,66 @@
1
+ {
2
+ "version": "1.0",
3
+ "mode": "auto",
4
+ "timestamp": "",
5
+ "project": {
6
+ "name": "",
7
+ "description": "",
8
+ "tech_stack": {
9
+ "language": "csharp",
10
+ "framework": "dotnet",
11
+ "ui": "blazor",
12
+ "database": "sqlserver",
13
+ "cloud": "azure"
14
+ }
15
+ },
16
+ "phases": {
17
+ "current": "LOAD",
18
+ "completed": [],
19
+ "status": {
20
+ "LOAD": "pending",
21
+ "DISCOVER": "pending",
22
+ "PLAN": "pending",
23
+ "ARCHITECT": "pending",
24
+ "IMPLEMENT": "pending",
25
+ "TEST": "pending",
26
+ "DEPLOY": "pending",
27
+ "DOC": "pending"
28
+ }
29
+ },
30
+ "context": {
31
+ "token_usage": {
32
+ "total": 0,
33
+ "limit": 128000,
34
+ "percentage": 0.0
35
+ },
36
+ "conversation_history": [],
37
+ "artifacts": {},
38
+ "decisions": []
39
+ },
40
+ "debates": [],
41
+ "errors": [],
42
+ "quality_gates": {
43
+ "LOAD": false,
44
+ "DISCOVER": false,
45
+ "PLAN": false,
46
+ "ARCHITECT": false,
47
+ "IMPLEMENT": false,
48
+ "TEST": false,
49
+ "DEPLOY": false,
50
+ "DOC": false
51
+ },
52
+ "configuration": {
53
+ "token_limit": 128000,
54
+ "save_threshold": 0.8,
55
+ "output_dir": "./mdan-auto-output",
56
+ "log_level": "INFO",
57
+ "fail_fast": true,
58
+ "debate_enabled": true
59
+ },
60
+ "metadata": {
61
+ "created_at": "",
62
+ "updated_at": "",
63
+ "save_count": 0,
64
+ "resume_count": 0
65
+ }
66
+ }