@iservu-inc/adf-cli 0.1.6 → 0.2.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.
- package/.project/chats/current/2025-10-03_ADF-CLI-QUALITY-BASED-PROGRESS-AND-RESUME.md +399 -0
- package/.project/docs/architecture/SYSTEM-DESIGN.md +369 -0
- package/.project/docs/frameworks/FRAMEWORK-METHODOLOGIES.md +449 -0
- package/.project/docs/goals/PROJECT-VISION.md +112 -0
- package/.project/docs/tool-integrations/IDE-CUSTOMIZATIONS.md +578 -0
- package/CHANGELOG.md +115 -0
- package/jest.config.js +20 -0
- package/lib/commands/init.js +41 -113
- package/lib/frameworks/answer-quality-analyzer.js +216 -0
- package/lib/frameworks/interviewer.js +447 -0
- package/lib/frameworks/output-generators.js +345 -0
- package/lib/frameworks/progress-tracker.js +239 -0
- package/lib/frameworks/questions.js +664 -0
- package/lib/frameworks/session-manager.js +100 -0
- package/package.json +10 -5
- package/tests/answer-quality-analyzer.test.js +173 -0
- package/tests/progress-tracker.test.js +205 -0
- package/tests/session-manager.test.js +162 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
# ADF CLI - System Architecture
|
|
2
|
+
|
|
3
|
+
## High-Level Architecture
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
7
|
+
│ CLI Entry │
|
|
8
|
+
│ (adf init) │
|
|
9
|
+
└──────────────────────┬──────────────────────────────────────┘
|
|
10
|
+
│
|
|
11
|
+
▼
|
|
12
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
13
|
+
│ Session Manager │
|
|
14
|
+
│ (Check for resumable sessions) │
|
|
15
|
+
└──────────────────────┬──────────────────────────────────────┘
|
|
16
|
+
│
|
|
17
|
+
┌──────────────┴──────────────┐
|
|
18
|
+
│ │
|
|
19
|
+
▼ ▼
|
|
20
|
+
┌───────────────┐ ┌──────────────────┐
|
|
21
|
+
│ Resume │ │ New Session │
|
|
22
|
+
│ Existing │ │ Workflow │
|
|
23
|
+
└───────┬───────┘ └────────┬─────────┘
|
|
24
|
+
│ │
|
|
25
|
+
└─────────┬──────────────────┘
|
|
26
|
+
│
|
|
27
|
+
▼
|
|
28
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
29
|
+
│ Interviewer │
|
|
30
|
+
│ (AI-driven conversational engine) │
|
|
31
|
+
└──────────────────────┬──────────────────────────────────────┘
|
|
32
|
+
│
|
|
33
|
+
┌──────────────┼──────────────┐
|
|
34
|
+
│ │ │
|
|
35
|
+
▼ ▼ ▼
|
|
36
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
37
|
+
│ Questions │ │ Quality │ │ Progress │
|
|
38
|
+
│ Database │ │ Analyzer │ │ Tracker │
|
|
39
|
+
└─────────────┘ └─────────────┘ └──────┬──────┘
|
|
40
|
+
│
|
|
41
|
+
┌─────────────────┼─────────────────┐
|
|
42
|
+
│ │ │
|
|
43
|
+
▼ ▼ ▼
|
|
44
|
+
┌────────────┐ ┌───────────┐ ┌──────────────┐
|
|
45
|
+
│ Main Save │ │ Backup │ │ Emergency │
|
|
46
|
+
│ JSON │ │ JSON │ │ Timestamped │
|
|
47
|
+
└────────────┘ └───────────┘ └──────────────┘
|
|
48
|
+
│
|
|
49
|
+
▼
|
|
50
|
+
┌─────────────────┐
|
|
51
|
+
│ Output │
|
|
52
|
+
│ Generator │
|
|
53
|
+
└────────┬────────┘
|
|
54
|
+
│
|
|
55
|
+
┌─────────────────┼─────────────────┐
|
|
56
|
+
│ │ │
|
|
57
|
+
▼ ▼ ▼
|
|
58
|
+
┌────────────┐ ┌───────────┐ ┌──────────────┐
|
|
59
|
+
│ PRP │ │ Balanced │ │ BMAD │
|
|
60
|
+
│ Output │ │ Output │ │ Output │
|
|
61
|
+
└────────────┘ └───────────┘ └──────────────┘
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Component Details
|
|
65
|
+
|
|
66
|
+
### 1. CLI Entry (init.js)
|
|
67
|
+
|
|
68
|
+
**Responsibilities:**
|
|
69
|
+
- Parse command-line arguments
|
|
70
|
+
- Check for existing sessions
|
|
71
|
+
- Initialize workflow selection
|
|
72
|
+
- Orchestrate interviewer
|
|
73
|
+
|
|
74
|
+
**Key Functions:**
|
|
75
|
+
- `init(options)`: Main entry point
|
|
76
|
+
- Calls SessionManager to check for resume
|
|
77
|
+
- Creates new Interviewer instance
|
|
78
|
+
|
|
79
|
+
### 2. Session Manager (session-manager.js)
|
|
80
|
+
|
|
81
|
+
**Responsibilities:**
|
|
82
|
+
- List all sessions
|
|
83
|
+
- Find resumable sessions
|
|
84
|
+
- Prompt user to resume or start new
|
|
85
|
+
- Delete sessions
|
|
86
|
+
|
|
87
|
+
**Key Functions:**
|
|
88
|
+
- `listSessions()`: Get all sessions
|
|
89
|
+
- `getResumableSessions()`: Filter for in-progress
|
|
90
|
+
- `promptToResume()`: Interactive prompt
|
|
91
|
+
- `deleteSession(id)`: Remove session
|
|
92
|
+
|
|
93
|
+
**Data:**
|
|
94
|
+
- Reads from `.adf/sessions/{sessionId}/_progress.json`
|
|
95
|
+
|
|
96
|
+
### 3. Interviewer (interviewer.js)
|
|
97
|
+
|
|
98
|
+
**Responsibilities:**
|
|
99
|
+
- Conduct conversational interview
|
|
100
|
+
- Group questions into blocks
|
|
101
|
+
- Show block previews
|
|
102
|
+
- Ask questions with follow-ups
|
|
103
|
+
- Track answers
|
|
104
|
+
- Generate outputs
|
|
105
|
+
|
|
106
|
+
**Key Functions:**
|
|
107
|
+
- `start()`: Main interview loop
|
|
108
|
+
- `askBlockQuestions()`: Ask all questions in block
|
|
109
|
+
- `askQuestion()`: Ask single question with quality analysis
|
|
110
|
+
- `determineFollowUp()`: Decide if follow-up needed
|
|
111
|
+
- `generateOutputs()`: Create framework documents
|
|
112
|
+
|
|
113
|
+
**State:**
|
|
114
|
+
- `sessionId`: Unique session identifier
|
|
115
|
+
- `answers`: All user answers
|
|
116
|
+
- `transcript`: Full conversation log
|
|
117
|
+
- `progressTracker`: Real-time progress
|
|
118
|
+
|
|
119
|
+
### 4. Questions Database (questions.js)
|
|
120
|
+
|
|
121
|
+
**Responsibilities:**
|
|
122
|
+
- Store all framework questions
|
|
123
|
+
- Provide questions by framework
|
|
124
|
+
- Define question metadata
|
|
125
|
+
|
|
126
|
+
**Structure:**
|
|
127
|
+
```javascript
|
|
128
|
+
{
|
|
129
|
+
id: 'prp-1',
|
|
130
|
+
phase: 'goal-definition',
|
|
131
|
+
text: 'Question text',
|
|
132
|
+
guidance: 'How to answer well',
|
|
133
|
+
goodExample: 'Example good answer',
|
|
134
|
+
badExample: 'Example bad answer',
|
|
135
|
+
keywords: ['web', 'mobile', ...],
|
|
136
|
+
requiredElements: ['platform', 'technology'],
|
|
137
|
+
followUpTriggers: {
|
|
138
|
+
vague: ['website', 'app'],
|
|
139
|
+
missingTech: (answer) => !hastech(answer),
|
|
140
|
+
missingPlatform: (answer) => !hasPlatform(answer)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 5. Answer Quality Analyzer (answer-quality-analyzer.js)
|
|
146
|
+
|
|
147
|
+
**Responsibilities:**
|
|
148
|
+
- Analyze answer richness
|
|
149
|
+
- Calculate quality score (0-100)
|
|
150
|
+
- Detect required elements
|
|
151
|
+
- Determine if follow-ups needed
|
|
152
|
+
|
|
153
|
+
**Scoring System:**
|
|
154
|
+
```
|
|
155
|
+
Word Count: 0-30 points
|
|
156
|
+
Keywords: 0-20 points
|
|
157
|
+
Required Elements: 0-25 points
|
|
158
|
+
Detail Level: 0-15 points
|
|
159
|
+
Technical Depth: 0-10 points
|
|
160
|
+
─────────────────────────────────
|
|
161
|
+
Total: 0-100 points
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Thresholds:**
|
|
165
|
+
- Score >= 70: Comprehensive
|
|
166
|
+
- Score >= 85: Skip follow-ups
|
|
167
|
+
|
|
168
|
+
**Key Functions:**
|
|
169
|
+
- `analyze(answer, question)`: Main analysis
|
|
170
|
+
- `checkKeywords()`: Match expected terms
|
|
171
|
+
- `checkRequiredElements()`: Detect critical info
|
|
172
|
+
- `checkDetailLevel()`: Assess depth
|
|
173
|
+
- `checkTechnicalDepth()`: Technical completeness
|
|
174
|
+
|
|
175
|
+
### 6. Progress Tracker (progress-tracker.js)
|
|
176
|
+
|
|
177
|
+
**Responsibilities:**
|
|
178
|
+
- Track real-time progress
|
|
179
|
+
- Calculate information richness
|
|
180
|
+
- Save with triple redundancy
|
|
181
|
+
- Enable resume capability
|
|
182
|
+
|
|
183
|
+
**Progress Data:**
|
|
184
|
+
```javascript
|
|
185
|
+
{
|
|
186
|
+
sessionId: string,
|
|
187
|
+
framework: string,
|
|
188
|
+
status: 'in-progress' | 'completed',
|
|
189
|
+
startedAt: ISO timestamp,
|
|
190
|
+
lastUpdated: ISO timestamp,
|
|
191
|
+
completedAt: ISO timestamp | null,
|
|
192
|
+
totalBlocks: number,
|
|
193
|
+
currentBlock: number,
|
|
194
|
+
completedBlocks: array,
|
|
195
|
+
skippedBlocks: array,
|
|
196
|
+
totalQuestionsAnswered: number,
|
|
197
|
+
informationRichness: 0-100,
|
|
198
|
+
averageAnswerQuality: 0-100,
|
|
199
|
+
totalWordCount: number,
|
|
200
|
+
comprehensiveAnswers: number,
|
|
201
|
+
canResume: boolean,
|
|
202
|
+
answers: object,
|
|
203
|
+
transcript: array
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Key Functions:**
|
|
208
|
+
- `initialize()`: Load or create progress
|
|
209
|
+
- `startBlock()`: Mark block as started
|
|
210
|
+
- `completeBlock()`: Mark block as done
|
|
211
|
+
- `skipBlock()`: Mark block as skipped
|
|
212
|
+
- `answerQuestion()`: Save answer with quality
|
|
213
|
+
- `saveWithBackup()`: Triple-redundant save
|
|
214
|
+
- `complete()`: Mark session as done
|
|
215
|
+
|
|
216
|
+
**Save Strategy:**
|
|
217
|
+
1. Main: `_progress.json`
|
|
218
|
+
2. Backup: `_progress.backup.json`
|
|
219
|
+
3. Log: `_progress-log.md` (append-only)
|
|
220
|
+
4. Emergency: `_emergency-{timestamp}.json` (if errors)
|
|
221
|
+
|
|
222
|
+
### 7. Output Generator (output-generators.js)
|
|
223
|
+
|
|
224
|
+
**Responsibilities:**
|
|
225
|
+
- Transform Q&A into framework documents
|
|
226
|
+
- Generate PRP, Balanced, or BMAD outputs
|
|
227
|
+
- Create AI agent instructions
|
|
228
|
+
|
|
229
|
+
**Outputs by Framework:**
|
|
230
|
+
|
|
231
|
+
**PRP:**
|
|
232
|
+
- `prp.md`: Product Requirement Prompt
|
|
233
|
+
|
|
234
|
+
**Balanced:**
|
|
235
|
+
- `constitution.md`: Project principles
|
|
236
|
+
- `specification.md`: Detailed spec
|
|
237
|
+
- `plan.md`: Technical plan
|
|
238
|
+
- `tasks.md`: Task breakdown
|
|
239
|
+
|
|
240
|
+
**BMAD:**
|
|
241
|
+
- `prd.md`: Product Requirements Document
|
|
242
|
+
- `architecture.md`: System architecture
|
|
243
|
+
- `stories.md`: User stories
|
|
244
|
+
|
|
245
|
+
## Data Flow
|
|
246
|
+
|
|
247
|
+
### New Session Flow
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
1. User runs `adf init`
|
|
251
|
+
2. SessionManager checks for resumable sessions
|
|
252
|
+
3. User selects "New Session"
|
|
253
|
+
4. Workflow detection or selection
|
|
254
|
+
5. Interviewer creates session directory
|
|
255
|
+
6. ProgressTracker initializes
|
|
256
|
+
7. For each block:
|
|
257
|
+
a. Show block preview
|
|
258
|
+
b. User chooses answer/skip/quit
|
|
259
|
+
c. For each question in block:
|
|
260
|
+
i. Show question with guidance
|
|
261
|
+
ii. User provides answer
|
|
262
|
+
iii. Quality analyzer evaluates
|
|
263
|
+
iv. Progress tracker saves (triple-redundant)
|
|
264
|
+
v. Determine if follow-up needed
|
|
265
|
+
vi. If follow-up, ask and re-analyze
|
|
266
|
+
d. Complete block
|
|
267
|
+
e. Display progress
|
|
268
|
+
8. Generate outputs
|
|
269
|
+
9. Save transcript
|
|
270
|
+
10. Mark session complete
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Resume Session Flow
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
1. User runs `adf init`
|
|
277
|
+
2. SessionManager finds resumable sessions
|
|
278
|
+
3. User selects session to resume
|
|
279
|
+
4. Interviewer loads session data
|
|
280
|
+
5. ProgressTracker loads from file
|
|
281
|
+
6. Display resume info (last updated, progress)
|
|
282
|
+
7. Continue from currentBlock
|
|
283
|
+
8. [Same as steps 7-10 above]
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## File Structure
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
project/
|
|
290
|
+
├── .adf/
|
|
291
|
+
│ └── sessions/
|
|
292
|
+
│ └── {sessionId}/
|
|
293
|
+
│ ├── _progress.json # Main progress file
|
|
294
|
+
│ ├── _progress.backup.json # Backup
|
|
295
|
+
│ ├── _progress-log.md # Append-only log
|
|
296
|
+
│ ├── _transcript.md # Full conversation
|
|
297
|
+
│ ├── _metadata.json # Session metadata
|
|
298
|
+
│ ├── qa-responses/
|
|
299
|
+
│ │ ├── goal-definition.md
|
|
300
|
+
│ │ ├── business-justification.md
|
|
301
|
+
│ │ └── ...
|
|
302
|
+
│ └── outputs/
|
|
303
|
+
│ ├── prp.md # (if PRP)
|
|
304
|
+
│ ├── constitution.md # (if Balanced)
|
|
305
|
+
│ ├── specification.md # (if Balanced)
|
|
306
|
+
│ └── ...
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Error Handling
|
|
310
|
+
|
|
311
|
+
### Save Failures
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
try {
|
|
315
|
+
await fs.writeJson(mainFile, data)
|
|
316
|
+
await fs.writeJson(backupFile, data)
|
|
317
|
+
await fs.appendFile(logFile, entry)
|
|
318
|
+
} catch (error) {
|
|
319
|
+
// Emergency save
|
|
320
|
+
await fs.writeJson(emergencyFile, data)
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### Corrupted Progress File
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
if (await exists(mainFile)) {
|
|
328
|
+
try {
|
|
329
|
+
progress = await readJson(mainFile)
|
|
330
|
+
} catch {
|
|
331
|
+
// Try backup
|
|
332
|
+
progress = await readJson(backupFile)
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### Application Crash
|
|
338
|
+
|
|
339
|
+
- On next run, SessionManager detects incomplete session
|
|
340
|
+
- User prompted to resume
|
|
341
|
+
- All data recovered from last successful save
|
|
342
|
+
|
|
343
|
+
## Performance Considerations
|
|
344
|
+
|
|
345
|
+
### Save Optimization
|
|
346
|
+
|
|
347
|
+
- Asynchronous saves (non-blocking)
|
|
348
|
+
- Debounce rapid saves (combine within 100ms)
|
|
349
|
+
- Gzip compression for large transcripts
|
|
350
|
+
|
|
351
|
+
### Memory Management
|
|
352
|
+
|
|
353
|
+
- Stream large files instead of loading entirely
|
|
354
|
+
- Clear transcript from memory after save
|
|
355
|
+
- Lazy load question blocks
|
|
356
|
+
|
|
357
|
+
## Security
|
|
358
|
+
|
|
359
|
+
### Data Privacy
|
|
360
|
+
|
|
361
|
+
- All data stored locally
|
|
362
|
+
- No external API calls (except future analytics opt-in)
|
|
363
|
+
- User owns all session data
|
|
364
|
+
|
|
365
|
+
### Input Validation
|
|
366
|
+
|
|
367
|
+
- Sanitize file paths
|
|
368
|
+
- Validate JSON structure
|
|
369
|
+
- Prevent path traversal attacks
|