claude-autopm 1.30.0 → 1.30.1
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/autopm/.claude/scripts/pm/prd-new.js +33 -6
- package/autopm/.claude/scripts/pm/template-list.js +25 -3
- package/autopm/.claude/scripts/pm/template-new.js +25 -3
- package/autopm/lib/README-FILTER-SEARCH.md +285 -0
- package/autopm/lib/analytics-engine.js +689 -0
- package/autopm/lib/batch-processor-integration.js +366 -0
- package/autopm/lib/batch-processor.js +278 -0
- package/autopm/lib/burndown-chart.js +415 -0
- package/autopm/lib/conflict-history.js +316 -0
- package/autopm/lib/conflict-resolver.js +330 -0
- package/autopm/lib/dependency-analyzer.js +466 -0
- package/autopm/lib/filter-engine.js +414 -0
- package/autopm/lib/guide/interactive-guide.js +756 -0
- package/autopm/lib/guide/manager.js +663 -0
- package/autopm/lib/query-parser.js +322 -0
- package/autopm/lib/template-engine.js +347 -0
- package/autopm/lib/visual-diff.js +297 -0
- package/install/install.js +2 -1
- package/lib/ai-providers/base-provider.js +110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guide Manager
|
|
3
|
+
* Handles user guide and tutorial generation
|
|
4
|
+
* TDD Phase: REFACTOR - Extracted from command
|
|
5
|
+
* Task: 7.2
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs').promises;
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
class GuideManager {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.templates = {
|
|
14
|
+
quickstart: this.getQuickstartTemplate(),
|
|
15
|
+
installation: this.getInstallationTemplate(),
|
|
16
|
+
configuration: this.getConfigurationTemplate(),
|
|
17
|
+
faq: this.getFAQTemplate(),
|
|
18
|
+
troubleshooting: this.getTroubleshootingTemplate()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Generate quick start guide
|
|
24
|
+
*/
|
|
25
|
+
async generateQuickstart(options = {}) {
|
|
26
|
+
await fs.mkdir('docs', { recursive: true });
|
|
27
|
+
|
|
28
|
+
const content = this.templates.quickstart;
|
|
29
|
+
await fs.writeFile(path.join('docs', 'QUICKSTART.md'), content);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
path: 'docs/QUICKSTART.md',
|
|
33
|
+
sections: ['Prerequisites', 'Installation', 'First Steps', 'Basic Usage']
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Generate installation guide
|
|
39
|
+
*/
|
|
40
|
+
async generateInstallationGuide(platform = 'node', options = {}) {
|
|
41
|
+
await fs.mkdir('docs', { recursive: true });
|
|
42
|
+
|
|
43
|
+
const content = this.getInstallationContent(platform);
|
|
44
|
+
await fs.writeFile(path.join('docs', 'INSTALL.md'), content);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
path: 'docs/INSTALL.md',
|
|
48
|
+
platform,
|
|
49
|
+
sections: ['Requirements', 'Steps', 'Platform-Specific', 'Troubleshooting']
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Generate configuration guide
|
|
55
|
+
*/
|
|
56
|
+
async generateConfigGuide(options = {}) {
|
|
57
|
+
await fs.mkdir('docs', { recursive: true });
|
|
58
|
+
|
|
59
|
+
const content = this.templates.configuration;
|
|
60
|
+
await fs.writeFile(path.join('docs', 'CONFIG.md'), content);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
path: 'docs/CONFIG.md',
|
|
64
|
+
sections: ['Environment', 'Files', 'Advanced', 'Best Practices']
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create tutorial
|
|
70
|
+
*/
|
|
71
|
+
async createTutorial(topic = 'basics', options = {}) {
|
|
72
|
+
await fs.mkdir(path.join('docs', 'tutorials'), { recursive: true });
|
|
73
|
+
|
|
74
|
+
const content = this.getTutorialContent(topic);
|
|
75
|
+
const filePath = path.join('docs', 'tutorials', `${topic}.md`);
|
|
76
|
+
await fs.writeFile(filePath, content);
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
path: filePath,
|
|
80
|
+
topic,
|
|
81
|
+
parts: 3
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Generate examples
|
|
87
|
+
*/
|
|
88
|
+
async generateExamples(category = 'general', options = {}) {
|
|
89
|
+
await fs.mkdir(path.join('docs', 'examples'), { recursive: true });
|
|
90
|
+
|
|
91
|
+
const content = this.getExamplesContent(category);
|
|
92
|
+
const filePath = path.join('docs', 'examples', 'README.md');
|
|
93
|
+
await fs.writeFile(filePath, content);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
path: filePath,
|
|
97
|
+
category,
|
|
98
|
+
count: 3
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Generate FAQ document
|
|
104
|
+
*/
|
|
105
|
+
async generateFAQ(options = {}) {
|
|
106
|
+
await fs.mkdir('docs', { recursive: true });
|
|
107
|
+
|
|
108
|
+
const content = this.templates.faq;
|
|
109
|
+
await fs.writeFile(path.join('docs', 'FAQ.md'), content);
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
path: 'docs/FAQ.md',
|
|
113
|
+
sections: ['General', 'Technical', 'Troubleshooting', 'Community', 'License'],
|
|
114
|
+
questions: 10
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create troubleshooting guide
|
|
120
|
+
*/
|
|
121
|
+
async createTroubleshootingGuide(options = {}) {
|
|
122
|
+
await fs.mkdir('docs', { recursive: true });
|
|
123
|
+
|
|
124
|
+
const content = this.templates.troubleshooting;
|
|
125
|
+
await fs.writeFile(path.join('docs', 'TROUBLESHOOTING.md'), content);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
path: 'docs/TROUBLESHOOTING.md',
|
|
129
|
+
problems: ['Installation', 'Runtime', 'Performance'],
|
|
130
|
+
solutions: 8
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Generate interactive documentation site
|
|
136
|
+
*/
|
|
137
|
+
async generateInteractiveDocs(theme = 'default', options = {}) {
|
|
138
|
+
await fs.mkdir(path.join('docs', 'site'), { recursive: true });
|
|
139
|
+
|
|
140
|
+
const html = this.getInteractiveHTML(theme);
|
|
141
|
+
const filePath = path.join('docs', 'site', 'index.html');
|
|
142
|
+
await fs.writeFile(filePath, html);
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
path: filePath,
|
|
146
|
+
theme,
|
|
147
|
+
features: ['Interactive examples', 'Live API testing', 'Search', 'Theme support']
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Build search index
|
|
153
|
+
*/
|
|
154
|
+
async buildSearchIndex(options = {}) {
|
|
155
|
+
await fs.mkdir('docs', { recursive: true });
|
|
156
|
+
|
|
157
|
+
const documents = await this.indexDocuments();
|
|
158
|
+
const searchIndex = {
|
|
159
|
+
version: '1.0.0',
|
|
160
|
+
documents,
|
|
161
|
+
index: {
|
|
162
|
+
fields: ['title', 'content'],
|
|
163
|
+
ref: 'file'
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const filePath = path.join('docs', 'search-index.json');
|
|
168
|
+
await fs.writeFile(filePath, JSON.stringify(searchIndex, null, 2));
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
path: filePath,
|
|
172
|
+
documentsIndexed: documents.length,
|
|
173
|
+
ready: true
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Index existing documents
|
|
179
|
+
*/
|
|
180
|
+
async indexDocuments() {
|
|
181
|
+
const docs = [];
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
const files = await fs.readdir('docs');
|
|
185
|
+
for (const file of files) {
|
|
186
|
+
if (file.endsWith('.md')) {
|
|
187
|
+
const content = await fs.readFile(path.join('docs', file), 'utf8');
|
|
188
|
+
docs.push({
|
|
189
|
+
file,
|
|
190
|
+
title: file.replace('.md', ''),
|
|
191
|
+
content: content.substring(0, 200)
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} catch {
|
|
196
|
+
// Add default doc if none exist
|
|
197
|
+
docs.push({
|
|
198
|
+
file: 'guide.md',
|
|
199
|
+
title: 'Guide',
|
|
200
|
+
content: 'Documentation content'
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return docs;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Template methods
|
|
208
|
+
getQuickstartTemplate() {
|
|
209
|
+
return `# Quick Start Guide
|
|
210
|
+
|
|
211
|
+
## Getting Started
|
|
212
|
+
|
|
213
|
+
Welcome to the application! This guide will help you get up and running quickly.
|
|
214
|
+
|
|
215
|
+
### Prerequisites
|
|
216
|
+
- Node.js >= 14.0.0
|
|
217
|
+
- npm >= 6.0.0
|
|
218
|
+
|
|
219
|
+
### Installation
|
|
220
|
+
\`\`\`bash
|
|
221
|
+
npm install
|
|
222
|
+
\`\`\`
|
|
223
|
+
|
|
224
|
+
### First Steps
|
|
225
|
+
1. Install dependencies
|
|
226
|
+
2. Configure your environment
|
|
227
|
+
3. Run the application
|
|
228
|
+
|
|
229
|
+
### Basic Usage
|
|
230
|
+
\`\`\`bash
|
|
231
|
+
npm start
|
|
232
|
+
\`\`\`
|
|
233
|
+
|
|
234
|
+
## Next Steps
|
|
235
|
+
- Read the [full documentation](./README.md)
|
|
236
|
+
- Check out [examples](./examples/)
|
|
237
|
+
- Join our community`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
getInstallationTemplate() {
|
|
241
|
+
return `# Installation Guide
|
|
242
|
+
|
|
243
|
+
## System Requirements
|
|
244
|
+
- Operating System: Windows, macOS, Linux
|
|
245
|
+
- Node.js: >= 14.0.0
|
|
246
|
+
- Memory: 4GB RAM minimum
|
|
247
|
+
- Storage: 100MB available space
|
|
248
|
+
|
|
249
|
+
## Installation Steps
|
|
250
|
+
|
|
251
|
+
### 1. Install Node.js
|
|
252
|
+
Download and install Node.js from [nodejs.org](https://nodejs.org/)
|
|
253
|
+
|
|
254
|
+
### 2. Install Package
|
|
255
|
+
\`\`\`bash
|
|
256
|
+
npm install -g @yourorg/package
|
|
257
|
+
\`\`\`
|
|
258
|
+
|
|
259
|
+
### 3. Verify Installation
|
|
260
|
+
\`\`\`bash
|
|
261
|
+
package --version
|
|
262
|
+
\`\`\`
|
|
263
|
+
|
|
264
|
+
## Platform-Specific Instructions
|
|
265
|
+
|
|
266
|
+
### Node.js
|
|
267
|
+
- Use npm or yarn for package management
|
|
268
|
+
- Ensure proper Node version with nvm
|
|
269
|
+
|
|
270
|
+
### Docker
|
|
271
|
+
- Pull the Docker image
|
|
272
|
+
- Run container with proper volumes
|
|
273
|
+
|
|
274
|
+
## Troubleshooting
|
|
275
|
+
- Check Node.js version: \`node --version\`
|
|
276
|
+
- Clear npm cache: \`npm cache clean --force\`
|
|
277
|
+
- Reinstall dependencies: \`rm -rf node_modules && npm install\`
|
|
278
|
+
|
|
279
|
+
## Next Steps
|
|
280
|
+
- [Configuration Guide](./CONFIG.md)
|
|
281
|
+
- [Quick Start](./QUICKSTART.md)`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
getConfigurationTemplate() {
|
|
285
|
+
return `# Configuration Guide
|
|
286
|
+
|
|
287
|
+
## Environment Variables
|
|
288
|
+
\`\`\`bash
|
|
289
|
+
NODE_ENV=production
|
|
290
|
+
API_KEY=your-api-key
|
|
291
|
+
DATABASE_URL=postgresql://localhost/db
|
|
292
|
+
\`\`\`
|
|
293
|
+
|
|
294
|
+
## Configuration File
|
|
295
|
+
Create a \`config.json\` file:
|
|
296
|
+
|
|
297
|
+
\`\`\`json
|
|
298
|
+
{
|
|
299
|
+
"port": 3000,
|
|
300
|
+
"host": "localhost",
|
|
301
|
+
"database": {
|
|
302
|
+
"host": "localhost",
|
|
303
|
+
"port": 5432,
|
|
304
|
+
"name": "myapp"
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
\`\`\`
|
|
308
|
+
|
|
309
|
+
## Advanced Settings
|
|
310
|
+
- Logging levels
|
|
311
|
+
- Performance tuning
|
|
312
|
+
- Security settings
|
|
313
|
+
- API rate limits
|
|
314
|
+
|
|
315
|
+
## Best Practices
|
|
316
|
+
1. Use environment variables for secrets
|
|
317
|
+
2. Keep configuration files out of version control
|
|
318
|
+
3. Use different configs for each environment
|
|
319
|
+
4. Document all configuration options`;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
getFAQTemplate() {
|
|
323
|
+
return `# Frequently Asked Questions (FAQ)
|
|
324
|
+
|
|
325
|
+
## General Questions
|
|
326
|
+
|
|
327
|
+
### Q: What is this application?
|
|
328
|
+
**A:** This application is a comprehensive tool for managing your projects efficiently.
|
|
329
|
+
|
|
330
|
+
### Q: How do I get started?
|
|
331
|
+
**A:** Check out our [Quick Start Guide](./QUICKSTART.md) for step-by-step instructions.
|
|
332
|
+
|
|
333
|
+
### Q: What are the system requirements?
|
|
334
|
+
**A:** You need Node.js 14+ and at least 4GB of RAM. See [Installation Guide](./INSTALL.md) for details.
|
|
335
|
+
|
|
336
|
+
## Technical Questions
|
|
337
|
+
|
|
338
|
+
### Q: How do I configure the application?
|
|
339
|
+
**A:** See the [Configuration Guide](./CONFIG.md) for detailed configuration options.
|
|
340
|
+
|
|
341
|
+
### Q: Can I use this with Docker?
|
|
342
|
+
**A:** Yes! We provide Docker images and docker compose configurations.
|
|
343
|
+
|
|
344
|
+
### Q: Is there API documentation?
|
|
345
|
+
**A:** Yes, complete API documentation is available in [API.md](./API.md).
|
|
346
|
+
|
|
347
|
+
## Troubleshooting
|
|
348
|
+
|
|
349
|
+
### Q: The application won't start. What should I do?
|
|
350
|
+
**A:**
|
|
351
|
+
1. Check Node.js version: \`node --version\`
|
|
352
|
+
2. Reinstall dependencies: \`npm install\`
|
|
353
|
+
3. Check error logs in \`./logs\`
|
|
354
|
+
|
|
355
|
+
### Q: How do I report bugs?
|
|
356
|
+
**A:** Please create an issue on our GitHub repository with:
|
|
357
|
+
- Description of the problem
|
|
358
|
+
- Steps to reproduce
|
|
359
|
+
- Error messages
|
|
360
|
+
- System information
|
|
361
|
+
|
|
362
|
+
## Community
|
|
363
|
+
|
|
364
|
+
### Q: How can I contribute?
|
|
365
|
+
**A:** We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
366
|
+
|
|
367
|
+
### Q: Where can I get help?
|
|
368
|
+
**A:**
|
|
369
|
+
- GitHub Issues
|
|
370
|
+
- Community Forum
|
|
371
|
+
- Discord Server
|
|
372
|
+
- Stack Overflow tag
|
|
373
|
+
|
|
374
|
+
## License
|
|
375
|
+
|
|
376
|
+
### Q: What license is this under?
|
|
377
|
+
**A:** This project is licensed under the MIT License. See [LICENSE](./LICENSE) for details.`;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
getTroubleshootingTemplate() {
|
|
381
|
+
return `# Troubleshooting Guide
|
|
382
|
+
|
|
383
|
+
## Common Problems and Solutions
|
|
384
|
+
|
|
385
|
+
### Installation Issues
|
|
386
|
+
|
|
387
|
+
#### Problem: npm install fails
|
|
388
|
+
**Solution:**
|
|
389
|
+
\`\`\`bash
|
|
390
|
+
# Clear npm cache
|
|
391
|
+
npm cache clean --force
|
|
392
|
+
|
|
393
|
+
# Remove node_modules
|
|
394
|
+
rm -rf node_modules package-lock.json
|
|
395
|
+
|
|
396
|
+
# Reinstall
|
|
397
|
+
npm install
|
|
398
|
+
\`\`\`
|
|
399
|
+
|
|
400
|
+
#### Problem: Permission denied errors
|
|
401
|
+
**Solution:**
|
|
402
|
+
- On macOS/Linux: Use \`sudo\` or fix npm permissions
|
|
403
|
+
- On Windows: Run as Administrator
|
|
404
|
+
|
|
405
|
+
### Runtime Errors
|
|
406
|
+
|
|
407
|
+
#### Problem: Application crashes on startup
|
|
408
|
+
**Possible causes:**
|
|
409
|
+
1. Missing environment variables
|
|
410
|
+
2. Port already in use
|
|
411
|
+
3. Database connection failed
|
|
412
|
+
|
|
413
|
+
**Solutions:**
|
|
414
|
+
- Check .env file exists
|
|
415
|
+
- Change port in configuration
|
|
416
|
+
- Verify database is running
|
|
417
|
+
|
|
418
|
+
### Performance Issues
|
|
419
|
+
|
|
420
|
+
#### Problem: Application is slow
|
|
421
|
+
**Solutions:**
|
|
422
|
+
1. Increase Node.js memory: \`node --max-old-space-size=4096\`
|
|
423
|
+
2. Enable production mode: \`NODE_ENV=production\`
|
|
424
|
+
3. Check for memory leaks
|
|
425
|
+
4. Review database queries
|
|
426
|
+
|
|
427
|
+
## Debug Mode
|
|
428
|
+
|
|
429
|
+
Enable debug logging:
|
|
430
|
+
\`\`\`bash
|
|
431
|
+
DEBUG=* npm start
|
|
432
|
+
\`\`\`
|
|
433
|
+
|
|
434
|
+
## Getting Help
|
|
435
|
+
|
|
436
|
+
If you're still having issues:
|
|
437
|
+
1. Check the [FAQ](./FAQ.md)
|
|
438
|
+
2. Search existing GitHub issues
|
|
439
|
+
3. Create a new issue with:
|
|
440
|
+
- Error messages
|
|
441
|
+
- Steps to reproduce
|
|
442
|
+
- System information
|
|
443
|
+
- Logs`;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
getInstallationContent(platform) {
|
|
447
|
+
const base = this.getInstallationTemplate();
|
|
448
|
+
const platformSpecific = {
|
|
449
|
+
node: '\n\n### Node.js Specific\n- Use npm or yarn\n- Ensure Node version',
|
|
450
|
+
docker: '\n\n### Docker Specific\n- Pull image\n- Run container',
|
|
451
|
+
kubernetes: '\n\n### Kubernetes Specific\n- Deploy with kubectl\n- Configure namespace'
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
return base.replace(
|
|
455
|
+
'## Platform: node',
|
|
456
|
+
`## Platform: ${platform.toUpperCase()}`
|
|
457
|
+
).replace(
|
|
458
|
+
'### Node.js\n- Use npm or yarn for package management\n- Ensure proper Node version with nvm',
|
|
459
|
+
platformSpecific[platform] || platformSpecific.node
|
|
460
|
+
);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
getTutorialContent(topic) {
|
|
464
|
+
return `# ${topic.charAt(0).toUpperCase() + topic.slice(1)} Tutorial
|
|
465
|
+
|
|
466
|
+
## Introduction
|
|
467
|
+
This tutorial covers the ${topic} of our application.
|
|
468
|
+
|
|
469
|
+
## Prerequisites
|
|
470
|
+
- Basic knowledge of JavaScript
|
|
471
|
+
- Familiarity with command line
|
|
472
|
+
|
|
473
|
+
## Part 1: Getting Started
|
|
474
|
+
Let's begin with the fundamentals...
|
|
475
|
+
|
|
476
|
+
### Exercise 1
|
|
477
|
+
\`\`\`javascript
|
|
478
|
+
// Your first ${topic} example
|
|
479
|
+
const example = require('./example');
|
|
480
|
+
example.run();
|
|
481
|
+
\`\`\`
|
|
482
|
+
|
|
483
|
+
## Part 2: Core Concepts
|
|
484
|
+
Understanding the key concepts...
|
|
485
|
+
|
|
486
|
+
## Part 3: Practical Examples
|
|
487
|
+
Real-world applications...
|
|
488
|
+
|
|
489
|
+
## Summary
|
|
490
|
+
You've learned the ${topic}!
|
|
491
|
+
|
|
492
|
+
## Next Steps
|
|
493
|
+
- Try the advanced tutorial
|
|
494
|
+
- Build your own project
|
|
495
|
+
- Share your experience`;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
getExamplesContent(category) {
|
|
499
|
+
return `# Code Examples
|
|
500
|
+
|
|
501
|
+
## Category: ${category.toUpperCase()}
|
|
502
|
+
|
|
503
|
+
### Example 1: Basic Usage
|
|
504
|
+
\`\`\`javascript
|
|
505
|
+
const api = require('api');
|
|
506
|
+
|
|
507
|
+
// Initialize
|
|
508
|
+
api.init({
|
|
509
|
+
key: 'your-key'
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// Make request
|
|
513
|
+
const result = await api.request('GET', '/users');
|
|
514
|
+
console.log(result);
|
|
515
|
+
\`\`\`
|
|
516
|
+
|
|
517
|
+
### Example 2: Advanced Features
|
|
518
|
+
\`\`\`javascript
|
|
519
|
+
// Error handling
|
|
520
|
+
try {
|
|
521
|
+
const data = await api.getData();
|
|
522
|
+
} catch (error) {
|
|
523
|
+
console.error('Error:', error.message);
|
|
524
|
+
}
|
|
525
|
+
\`\`\`
|
|
526
|
+
|
|
527
|
+
### Example 3: Best Practices
|
|
528
|
+
\`\`\`javascript
|
|
529
|
+
// Async/await pattern
|
|
530
|
+
async function fetchData() {
|
|
531
|
+
const response = await api.fetch();
|
|
532
|
+
return response.data;
|
|
533
|
+
}
|
|
534
|
+
\`\`\`
|
|
535
|
+
|
|
536
|
+
## Running the Examples
|
|
537
|
+
1. Clone the repository
|
|
538
|
+
2. Install dependencies
|
|
539
|
+
3. Run: \`npm run examples\`
|
|
540
|
+
|
|
541
|
+
## More Examples
|
|
542
|
+
- [Authentication](./auth.js)
|
|
543
|
+
- [Database Operations](./database.js)
|
|
544
|
+
- [File Handling](./files.js)`;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
getInteractiveHTML(theme) {
|
|
548
|
+
const themes = {
|
|
549
|
+
default: {
|
|
550
|
+
bg: '#ffffff',
|
|
551
|
+
text: '#333333',
|
|
552
|
+
navBg: '#f5f5f5',
|
|
553
|
+
contentBg: '#f9f9f9',
|
|
554
|
+
link: '#3b82f6'
|
|
555
|
+
},
|
|
556
|
+
dark: {
|
|
557
|
+
bg: '#1a1a1a',
|
|
558
|
+
text: '#e0e0e0',
|
|
559
|
+
navBg: '#2d2d2d',
|
|
560
|
+
contentBg: '#2d2d2d',
|
|
561
|
+
link: '#60a5fa'
|
|
562
|
+
},
|
|
563
|
+
light: {
|
|
564
|
+
bg: '#ffffff',
|
|
565
|
+
text: '#000000',
|
|
566
|
+
navBg: '#eeeeee',
|
|
567
|
+
contentBg: '#fafafa',
|
|
568
|
+
link: '#2563eb'
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
const colors = themes[theme] || themes.default;
|
|
573
|
+
|
|
574
|
+
return `<!DOCTYPE html>
|
|
575
|
+
<html lang="en">
|
|
576
|
+
<head>
|
|
577
|
+
<meta charset="UTF-8">
|
|
578
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
579
|
+
<title>Interactive Documentation</title>
|
|
580
|
+
<style>
|
|
581
|
+
body {
|
|
582
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
583
|
+
margin: 0;
|
|
584
|
+
padding: 0;
|
|
585
|
+
background: ${colors.bg};
|
|
586
|
+
color: ${colors.text};
|
|
587
|
+
}
|
|
588
|
+
.container {
|
|
589
|
+
max-width: 1200px;
|
|
590
|
+
margin: 0 auto;
|
|
591
|
+
padding: 20px;
|
|
592
|
+
}
|
|
593
|
+
nav {
|
|
594
|
+
background: ${colors.navBg};
|
|
595
|
+
padding: 15px;
|
|
596
|
+
border-radius: 8px;
|
|
597
|
+
margin-bottom: 20px;
|
|
598
|
+
}
|
|
599
|
+
nav a {
|
|
600
|
+
margin-right: 20px;
|
|
601
|
+
color: ${colors.link};
|
|
602
|
+
text-decoration: none;
|
|
603
|
+
}
|
|
604
|
+
nav a:hover {
|
|
605
|
+
text-decoration: underline;
|
|
606
|
+
}
|
|
607
|
+
.content {
|
|
608
|
+
background: ${colors.contentBg};
|
|
609
|
+
padding: 30px;
|
|
610
|
+
border-radius: 8px;
|
|
611
|
+
}
|
|
612
|
+
h1 {
|
|
613
|
+
color: ${colors.link};
|
|
614
|
+
}
|
|
615
|
+
code {
|
|
616
|
+
background: ${theme === 'dark' ? '#1a1a1a' : '#f0f0f0'};
|
|
617
|
+
padding: 2px 6px;
|
|
618
|
+
border-radius: 4px;
|
|
619
|
+
font-family: 'Fira Code', monospace;
|
|
620
|
+
}
|
|
621
|
+
</style>
|
|
622
|
+
</head>
|
|
623
|
+
<body>
|
|
624
|
+
<div class="container">
|
|
625
|
+
<nav>
|
|
626
|
+
<a href="#quickstart">Quick Start</a>
|
|
627
|
+
<a href="#installation">Installation</a>
|
|
628
|
+
<a href="#tutorials">Tutorials</a>
|
|
629
|
+
<a href="#api">API Reference</a>
|
|
630
|
+
<a href="#faq">FAQ</a>
|
|
631
|
+
</nav>
|
|
632
|
+
|
|
633
|
+
<div class="content">
|
|
634
|
+
<h1>Welcome to Interactive Documentation</h1>
|
|
635
|
+
<p>Explore our comprehensive documentation with interactive examples and live demos.</p>
|
|
636
|
+
|
|
637
|
+
<section id="quickstart">
|
|
638
|
+
<h2>Quick Start</h2>
|
|
639
|
+
<p>Get up and running in minutes with our step-by-step guide.</p>
|
|
640
|
+
<code>npm install && npm start</code>
|
|
641
|
+
</section>
|
|
642
|
+
|
|
643
|
+
<section id="features">
|
|
644
|
+
<h2>Features</h2>
|
|
645
|
+
<ul>
|
|
646
|
+
<li>Interactive code examples</li>
|
|
647
|
+
<li>Live API testing</li>
|
|
648
|
+
<li>Searchable documentation</li>
|
|
649
|
+
<li>Dark/Light theme support</li>
|
|
650
|
+
</ul>
|
|
651
|
+
</section>
|
|
652
|
+
</div>
|
|
653
|
+
</div>
|
|
654
|
+
|
|
655
|
+
<script>
|
|
656
|
+
console.log('Interactive documentation loaded');
|
|
657
|
+
</script>
|
|
658
|
+
</body>
|
|
659
|
+
</html>`;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
module.exports = GuideManager;
|