docworks 0.11.0 → 0.12.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/README.md +86 -148
- package/dist/commands/check.d.ts +3 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +31 -12
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +32 -132
- package/dist/commands/init.js.map +1 -1
- package/dist/core/validator.d.ts +3 -3
- package/dist/core/validator.d.ts.map +1 -1
- package/dist/core/validator.js +10 -29
- package/dist/core/validator.js.map +1 -1
- package/dist/index.js +5 -12
- package/dist/index.js.map +1 -1
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +94 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/sources/source.d.ts +5 -0
- package/dist/sources/source.d.ts.map +1 -0
- package/dist/sources/source.js +23 -0
- package/dist/sources/source.js.map +1 -0
- package/dist/types/config.d.ts +7 -13
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +8 -3
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/reporter.d.ts +1 -1
- package/dist/utils/reporter.d.ts.map +1 -1
- package/dist/utils/reporter.js +18 -51
- package/dist/utils/reporter.js.map +1 -1
- package/package.json +1 -1
- package/dist/commands/test.d.ts +0 -5
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -45
- package/dist/commands/test.js.map +0 -1
- package/dist/core/ai.d.ts +0 -2
- package/dist/core/ai.d.ts.map +0 -1
- package/dist/core/ai.js +0 -29
- package/dist/core/ai.js.map +0 -1
- package/dist/core/cache.d.ts +0 -3
- package/dist/core/cache.d.ts.map +0 -1
- package/dist/core/cache.js +0 -31
- package/dist/core/cache.js.map +0 -1
- package/dist/providers/anthropic.d.ts +0 -10
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js +0 -51
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/base.d.ts +0 -12
- package/dist/providers/base.d.ts.map +0 -1
- package/dist/providers/base.js +0 -14
- package/dist/providers/base.js.map +0 -1
- package/dist/providers/openai.d.ts +0 -10
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js +0 -42
- package/dist/providers/openai.js.map +0 -1
- package/dist/sources/base.d.ts +0 -3
- package/dist/sources/base.d.ts.map +0 -1
- package/dist/sources/base.js +0 -17
- package/dist/sources/base.js.map +0 -1
- package/dist/sources/llms-txt.d.ts +0 -7
- package/dist/sources/llms-txt.d.ts.map +0 -1
- package/dist/sources/llms-txt.js +0 -43
- package/dist/sources/llms-txt.js.map +0 -1
- package/dist/sources/mcp.d.ts +0 -9
- package/dist/sources/mcp.d.ts.map +0 -1
- package/dist/sources/mcp.js +0 -33
- package/dist/sources/mcp.js.map +0 -1
- package/templates/api.yml +0 -21
- package/templates/default.yml +0 -19
- package/templates/gitbook.yml +0 -13
- package/templates/library.yml +0 -21
- package/templates/mintlify.yml +0 -18
- package/templates/readme.yml +0 -13
package/README.md
CHANGED
|
@@ -1,200 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
<br/><br/>
|
|
1
|
+
# DocWorks
|
|
3
2
|
|
|
4
|
-
Ensure your docs
|
|
3
|
+
Ensure your docs work for developers and AI. Tests if humans and AI agents can actually accomplish tasks using your documentation.
|
|
5
4
|
|
|
6
|
-
##
|
|
7
|
-
|
|
8
|
-
Your docs mention "authentication" 50 times, but developers still can't figure out HOW to authenticate. Keywords exist, but answers are fragmented across pages. Support tickets spike.
|
|
9
|
-
|
|
10
|
-
## How It Works
|
|
11
|
-
|
|
12
|
-
Define what questions your docs must answer. DocWorks uses AI to verify they remain answerable after every change.
|
|
13
|
-
|
|
14
|
-
```yaml
|
|
15
|
-
# docworks.yml
|
|
16
|
-
questions:
|
|
17
|
-
critical:
|
|
18
|
-
- How do I authenticate?
|
|
19
|
-
- What are the rate limits?
|
|
20
|
-
- How do I handle errors?
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Install
|
|
5
|
+
## Quick Start
|
|
24
6
|
|
|
25
7
|
```bash
|
|
8
|
+
# Install
|
|
26
9
|
npm install -g docworks
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Quick Start
|
|
30
10
|
|
|
31
|
-
|
|
32
|
-
# 1. Initialize with smart defaults
|
|
11
|
+
# Initialize
|
|
33
12
|
docworks init
|
|
34
13
|
|
|
35
|
-
#
|
|
14
|
+
# Run validation
|
|
36
15
|
OPENAI_API_KEY=sk-... docworks check
|
|
37
16
|
```
|
|
38
17
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
42
|
-
✅ How do I authenticate?
|
|
43
|
-
✅ What are the rate limits?
|
|
44
|
-
❌ How do I handle errors?
|
|
45
|
-
|
|
46
|
-
Documentation check failed:
|
|
47
|
-
Critical questions cannot be answered from current docs
|
|
48
|
-
```
|
|
18
|
+
## How It Works
|
|
49
19
|
|
|
50
|
-
|
|
20
|
+
DocWorks tests documentation the way developers actually use it - by having AI search and navigate your docs to answer questions:
|
|
51
21
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
jobs:
|
|
58
|
-
check:
|
|
59
|
-
runs-on: ubuntu-latest
|
|
60
|
-
steps:
|
|
61
|
-
- uses: actions/checkout@v3
|
|
62
|
-
- run: npx docworks check
|
|
63
|
-
env:
|
|
64
|
-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
65
|
-
```
|
|
22
|
+
1. **AI explores your docs** - Uses web search to navigate pages
|
|
23
|
+
2. **Tracks the journey** - Records which pages were visited
|
|
24
|
+
3. **Reports confidence** - Shows how easily answers were found
|
|
25
|
+
4. **Identifies gaps** - Lists exactly what's missing
|
|
66
26
|
|
|
67
27
|
## Configuration
|
|
68
28
|
|
|
29
|
+
### Simple Questions
|
|
30
|
+
|
|
69
31
|
```yaml
|
|
70
32
|
# docworks.yml
|
|
71
|
-
|
|
72
|
-
critical: # These block PRs if unanswerable
|
|
73
|
-
- How do I install this?
|
|
74
|
-
- How do I authenticate?
|
|
33
|
+
source: https://docs.yourcompany.com
|
|
75
34
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
nice_to_have: # Informational only
|
|
81
|
-
- Are there TypeScript types?
|
|
35
|
+
questions:
|
|
36
|
+
- How do I authenticate?
|
|
37
|
+
- What are the rate limits?
|
|
38
|
+
- Where are code examples?
|
|
82
39
|
|
|
83
|
-
|
|
84
|
-
provider: openai # or anthropic, azure
|
|
40
|
+
provider: openai
|
|
85
41
|
model: gpt-4o-mini
|
|
86
42
|
```
|
|
87
43
|
|
|
88
|
-
|
|
44
|
+
### Journey Validation
|
|
89
45
|
|
|
90
|
-
|
|
46
|
+
```yaml
|
|
47
|
+
source: https://docs.yourcompany.com
|
|
91
48
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
49
|
+
journeys:
|
|
50
|
+
authentication:
|
|
51
|
+
- How do I get API keys?
|
|
52
|
+
- How do I authenticate requests?
|
|
53
|
+
- How do I handle token refresh?
|
|
95
54
|
|
|
96
|
-
|
|
97
|
-
|
|
55
|
+
error_handling:
|
|
56
|
+
- What are the error codes?
|
|
57
|
+
- How do I retry failed requests?
|
|
98
58
|
|
|
99
|
-
|
|
100
|
-
|
|
59
|
+
provider: openai
|
|
60
|
+
model: gpt-4o-mini
|
|
101
61
|
```
|
|
102
62
|
|
|
103
|
-
##
|
|
104
|
-
|
|
105
|
-
- **Explicit control** - You define what matters, not magic patterns
|
|
106
|
-
- **AI-powered** - Understands context, not just keywords
|
|
107
|
-
- **Progressive adoption** - Start advisory, enable blocking when ready
|
|
108
|
-
- **Provider flexible** - OpenAI, Anthropic, Azure (BYO keys)
|
|
109
|
-
- **Fast** - Cached responses, parallel validation
|
|
110
|
-
|
|
111
|
-
## Examples
|
|
112
|
-
|
|
113
|
-
### API Documentation
|
|
114
|
-
|
|
115
|
-
```yaml
|
|
116
|
-
questions:
|
|
117
|
-
critical:
|
|
118
|
-
- How do I authenticate with the API?
|
|
119
|
-
- What are the API endpoints?
|
|
120
|
-
- How do I handle errors?
|
|
121
|
-
```
|
|
63
|
+
## Rich Feedback
|
|
122
64
|
|
|
123
|
-
|
|
65
|
+
Instead of simple YES/NO, get actionable insights:
|
|
124
66
|
|
|
125
|
-
```yaml
|
|
126
|
-
questions:
|
|
127
|
-
critical:
|
|
128
|
-
- How do I install this package?
|
|
129
|
-
- How do I import and use it?
|
|
130
|
-
- What's a basic example?
|
|
131
67
|
```
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
- How do I get access?
|
|
139
|
-
- Who do I contact for help?
|
|
140
|
-
- Where are the runbooks?
|
|
68
|
+
⚠️ How do I authenticate?
|
|
69
|
+
Confidence: 60%
|
|
70
|
+
Searched: 3 pages
|
|
71
|
+
Missing:
|
|
72
|
+
- API key generation steps
|
|
73
|
+
- Token refresh documentation
|
|
141
74
|
```
|
|
142
75
|
|
|
143
|
-
##
|
|
76
|
+
## Multi-Model Testing
|
|
144
77
|
|
|
145
|
-
|
|
146
|
-
2. **DocWorks reads** all your documentation
|
|
147
|
-
3. **AI validates** each question is answerable
|
|
148
|
-
4. **CI/CD enforces** on every PR
|
|
78
|
+
Test against multiple AI models using CI/CD:
|
|
149
79
|
|
|
150
|
-
|
|
80
|
+
```yaml
|
|
81
|
+
# .github/workflows/docs.yml
|
|
82
|
+
name: Documentation Validation
|
|
83
|
+
on: [pull_request]
|
|
151
84
|
|
|
152
|
-
|
|
85
|
+
jobs:
|
|
86
|
+
validate:
|
|
87
|
+
strategy:
|
|
88
|
+
matrix:
|
|
89
|
+
include:
|
|
90
|
+
- provider: openai
|
|
91
|
+
model: gpt-4o
|
|
92
|
+
- provider: openai
|
|
93
|
+
model: gpt-4o-mini
|
|
94
|
+
- provider: anthropic
|
|
95
|
+
model: claude-3-opus
|
|
153
96
|
|
|
154
|
-
-
|
|
155
|
-
|
|
156
|
-
-
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v3
|
|
100
|
+
- run: npx docworks check
|
|
101
|
+
env:
|
|
102
|
+
PROVIDER: ${{ matrix.provider }}
|
|
103
|
+
MODEL: ${{ matrix.model }}
|
|
104
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
105
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
106
|
+
```
|
|
157
107
|
|
|
158
|
-
##
|
|
108
|
+
## Supported Documentation
|
|
159
109
|
|
|
160
|
-
- **
|
|
161
|
-
- **
|
|
110
|
+
- **Public docs** - Any site with [llms.txt](https://llmstxt.org)
|
|
111
|
+
- **Platforms** - Mintlify, ReadMe, GitBook
|
|
162
112
|
|
|
163
|
-
##
|
|
113
|
+
## Commands
|
|
164
114
|
|
|
165
115
|
```bash
|
|
166
|
-
#
|
|
167
|
-
|
|
168
|
-
cd docworks
|
|
169
|
-
npm install
|
|
170
|
-
|
|
171
|
-
# Run locally
|
|
172
|
-
npm run dev
|
|
173
|
-
|
|
174
|
-
# Run tests
|
|
175
|
-
npm test
|
|
176
|
-
```
|
|
116
|
+
# Initialize config
|
|
117
|
+
docworks init
|
|
177
118
|
|
|
178
|
-
|
|
119
|
+
# Validate all journeys
|
|
120
|
+
docworks check
|
|
179
121
|
|
|
180
|
-
|
|
181
|
-
|
|
122
|
+
# Test specific journey
|
|
123
|
+
docworks check --journey authentication
|
|
182
124
|
|
|
183
|
-
|
|
184
|
-
|
|
125
|
+
# Output as JSON
|
|
126
|
+
docworks check --format json
|
|
127
|
+
```
|
|
185
128
|
|
|
186
|
-
|
|
187
|
-
A: Yes. Runs in your CI with your API keys. Docs never leave your infrastructure.
|
|
129
|
+
## Why DocWorks?
|
|
188
130
|
|
|
189
|
-
**
|
|
190
|
-
|
|
131
|
+
- **Real-world testing** - AI navigates docs like developers do
|
|
132
|
+
- **Actionable feedback** - Know exactly what to fix
|
|
133
|
+
- **CI/CD ready** - Catch doc regressions before merge
|
|
134
|
+
- **Progressive** - Start simple, add complexity as needed
|
|
191
135
|
|
|
192
136
|
## License
|
|
193
137
|
|
|
194
138
|
MIT
|
|
195
|
-
|
|
196
|
-
## Links
|
|
197
|
-
|
|
198
|
-
- [Documentation](https://docworks.dev)
|
|
199
|
-
- [GitHub](https://github.com/caiopizzol/docworks)
|
|
200
|
-
- [NPM](https://npmjs.com/package/docworks)
|
package/dist/commands/check.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare function check(options: {
|
|
2
2
|
config: string;
|
|
3
3
|
journey?: string;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
format?: 'terminal' | 'json';
|
|
5
|
+
provider?: string;
|
|
6
|
+
model?: string;
|
|
6
7
|
}): Promise<void>;
|
|
7
8
|
//# sourceMappingURL=check.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAMA,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAMA,wBAAsB,KAAK,CAAC,OAAO,EAAE;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAA;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CA6FhB"}
|
package/dist/commands/check.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { loadConfig } from '../utils/config.js';
|
|
2
|
-
import {
|
|
2
|
+
import { fetchDocumentation } from '../sources/source.js';
|
|
3
3
|
import { validateJourneys, validateQuestions } from '../core/validator.js';
|
|
4
4
|
import { formatReport, formatJSON } from '../utils/reporter.js';
|
|
5
5
|
export async function check(options) {
|
|
6
6
|
try {
|
|
7
7
|
// Load config
|
|
8
8
|
const config = await loadConfig(options.config || 'docworks.yml');
|
|
9
|
+
// Apply overrides
|
|
10
|
+
if (options.provider)
|
|
11
|
+
config.provider = options.provider;
|
|
12
|
+
if (options.model)
|
|
13
|
+
config.model = options.model;
|
|
9
14
|
// Validate API key
|
|
10
15
|
const apiKey = process.env.OPENAI_API_KEY ||
|
|
11
16
|
process.env.ANTHROPIC_API_KEY ||
|
|
@@ -19,15 +24,29 @@ export async function check(options) {
|
|
|
19
24
|
}
|
|
20
25
|
// Load documentation
|
|
21
26
|
console.log('📚 Loading documentation...');
|
|
22
|
-
const
|
|
23
|
-
console.log(`Source: ${
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
const { content: docs, name: sourceName } = await fetchDocumentation(config.source);
|
|
28
|
+
console.log(`Source: ${sourceName}\n`);
|
|
29
|
+
// Prepare all validations
|
|
30
|
+
const allValidations = {};
|
|
31
|
+
// Add standalone questions as implicit "general" journey
|
|
32
|
+
if (config.questions) {
|
|
33
|
+
allValidations.general = config.questions;
|
|
34
|
+
}
|
|
35
|
+
// Add explicit journeys
|
|
36
|
+
if (config.journeys) {
|
|
37
|
+
Object.assign(allValidations, config.journeys);
|
|
38
|
+
}
|
|
39
|
+
// Check if we have anything to validate
|
|
40
|
+
if (Object.keys(allValidations).length === 0) {
|
|
41
|
+
console.error('❌ No questions or journeys found in config');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
// Validate
|
|
45
|
+
console.log('🔍 Validating documentation...\n');
|
|
27
46
|
let results;
|
|
28
47
|
if (options.journey) {
|
|
29
48
|
// Validate single journey
|
|
30
|
-
const questions =
|
|
49
|
+
const questions = allValidations[options.journey];
|
|
31
50
|
if (!questions) {
|
|
32
51
|
console.error(`Journey "${options.journey}" not found`);
|
|
33
52
|
process.exit(1);
|
|
@@ -35,21 +54,21 @@ export async function check(options) {
|
|
|
35
54
|
console.log(`Journey: ${options.journey}`);
|
|
36
55
|
console.log('─'.repeat(40));
|
|
37
56
|
results = {
|
|
38
|
-
[options.journey]: await validateQuestions(questions, docs, apiKey,
|
|
57
|
+
[options.journey]: await validateQuestions(questions, docs, apiKey, config),
|
|
39
58
|
};
|
|
40
59
|
}
|
|
41
60
|
else {
|
|
42
|
-
// Validate all
|
|
43
|
-
results = await validateJourneys(
|
|
61
|
+
// Validate all
|
|
62
|
+
results = await validateJourneys(allValidations, docs, apiKey, config);
|
|
44
63
|
}
|
|
45
64
|
// Format output
|
|
46
65
|
if (options.format === 'json') {
|
|
47
|
-
console.log(formatJSON(results,
|
|
66
|
+
console.log(formatJSON(results, sourceName));
|
|
48
67
|
const hasFailures = Object.values(results).some((questions) => questions.some((q) => q.answerable === 'NO'));
|
|
49
68
|
process.exit(hasFailures ? 1 : 0);
|
|
50
69
|
}
|
|
51
70
|
else {
|
|
52
|
-
const exitCode = formatReport(results
|
|
71
|
+
const exitCode = formatReport(results);
|
|
53
72
|
process.exit(exitCode);
|
|
54
73
|
}
|
|
55
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,k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CAAC,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QACxE,CAAC;QAED,gBAAgB;QAChB,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;YAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAC5D,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,IAAI,CAAC,CAC7C,CAAA;YACD,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,CAAC;aAAM,CAAC;YACN,MAAM,QAAQ,GAAG,YAAY,CAAC,OAAO,CAAC,CAAA;YACtC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAU,EAAG,KAAe,CAAC,OAAO,CAAC,CAAA;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC"}
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAsCA,wBAAsB,IAAI,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCxE"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,108 +1,37 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import { glob } from 'glob';
|
|
3
2
|
const TEMPLATES = {
|
|
4
|
-
|
|
5
|
-
source:
|
|
3
|
+
simple: `# DocWorks Configuration
|
|
4
|
+
source: https://docs.example.com
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- How do I run tests?
|
|
15
|
-
- How do I debug issues?
|
|
16
|
-
- Where can I get help?
|
|
6
|
+
# Simple list of questions to validate
|
|
7
|
+
questions:
|
|
8
|
+
- How do I authenticate?
|
|
9
|
+
- What are the rate limits?
|
|
10
|
+
- How do I get started?
|
|
11
|
+
- Where can I find examples?
|
|
12
|
+
- How do I handle errors?
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
# Provider configuration (supports environment variables)
|
|
15
|
+
provider: \${PROVIDER:-openai}
|
|
16
|
+
model: \${MODEL:-gpt-4o-mini}`,
|
|
17
|
+
journeys: `# DocWorks Configuration
|
|
18
|
+
source: https://docs.example.com
|
|
22
19
|
|
|
20
|
+
# Group questions by user journey
|
|
23
21
|
journeys:
|
|
24
22
|
authentication:
|
|
25
|
-
- How do I
|
|
26
|
-
-
|
|
23
|
+
- How do I get API keys?
|
|
24
|
+
- How do I authenticate requests?
|
|
27
25
|
- What auth methods are supported?
|
|
28
26
|
|
|
29
|
-
|
|
30
|
-
- What
|
|
31
|
-
- How
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
production:
|
|
35
|
-
- How do I monitor usage?
|
|
36
|
-
- Where are status pages?
|
|
37
|
-
- How do I get support?
|
|
38
|
-
|
|
39
|
-
provider: openai
|
|
40
|
-
model: gpt-4o-mini`,
|
|
41
|
-
library: `# DocWorks Configuration - Library/Package
|
|
42
|
-
source: ./llms.txt
|
|
43
|
-
|
|
44
|
-
journeys:
|
|
45
|
-
setup:
|
|
46
|
-
- How do I install this package?
|
|
47
|
-
- How do I import it?
|
|
48
|
-
- What are the requirements?
|
|
49
|
-
|
|
50
|
-
basic_usage:
|
|
51
|
-
- What's a hello world example?
|
|
52
|
-
- What are the main functions?
|
|
53
|
-
- How do I configure options?
|
|
54
|
-
|
|
55
|
-
typescript:
|
|
56
|
-
- Does it have TypeScript support?
|
|
57
|
-
- Where are the type definitions?
|
|
58
|
-
- How do I use with TypeScript?
|
|
59
|
-
|
|
60
|
-
provider: openai
|
|
61
|
-
model: gpt-4o-mini`,
|
|
62
|
-
mintlify: `# DocWorks Configuration - Mintlify
|
|
63
|
-
source:
|
|
64
|
-
type: mcp
|
|
65
|
-
server: "@mintlify/mcp-server"
|
|
66
|
-
|
|
67
|
-
journeys:
|
|
68
|
-
api_reference:
|
|
69
|
-
- Where is the API reference?
|
|
70
|
-
- Are all endpoints documented?
|
|
71
|
-
- Do examples work?
|
|
72
|
-
|
|
73
|
-
getting_started:
|
|
74
|
-
- Is there a quickstart guide?
|
|
75
|
-
- How do I authenticate?
|
|
76
|
-
- What SDKs are available?
|
|
77
|
-
|
|
78
|
-
provider: openai
|
|
79
|
-
model: gpt-4o-mini`,
|
|
80
|
-
readme: `# DocWorks Configuration - ReadMe
|
|
81
|
-
source:
|
|
82
|
-
type: mcp
|
|
83
|
-
server: "@readme/mcp-server"
|
|
84
|
-
|
|
85
|
-
journeys:
|
|
86
|
-
developer_experience:
|
|
87
|
-
- Can I try the API interactively?
|
|
88
|
-
- Are there code examples?
|
|
89
|
-
- Is versioning documented?
|
|
90
|
-
|
|
91
|
-
provider: openai
|
|
92
|
-
model: gpt-4o-mini`,
|
|
93
|
-
gitbook: `# DocWorks Configuration - GitBook
|
|
94
|
-
source:
|
|
95
|
-
type: mcp
|
|
96
|
-
server: "@gitbook/mcp-server"
|
|
27
|
+
error_handling:
|
|
28
|
+
- What error codes exist?
|
|
29
|
+
- How should I handle rate limits?
|
|
30
|
+
- Where are error examples?
|
|
97
31
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
- Can I search effectively?
|
|
102
|
-
- Are guides comprehensive?
|
|
103
|
-
|
|
104
|
-
provider: openai
|
|
105
|
-
model: gpt-4o-mini`,
|
|
32
|
+
# Provider configuration (supports environment variables)
|
|
33
|
+
provider: \${PROVIDER:-openai}
|
|
34
|
+
model: \${MODEL:-gpt-4o-mini}`,
|
|
106
35
|
};
|
|
107
36
|
export async function init(options) {
|
|
108
37
|
console.log('🚀 Initializing DocWorks...\n');
|
|
@@ -112,54 +41,25 @@ export async function init(options) {
|
|
|
112
41
|
process.exit(1);
|
|
113
42
|
}
|
|
114
43
|
// Select template
|
|
115
|
-
const templateName = options.
|
|
44
|
+
const templateName = options.template || 'simple';
|
|
116
45
|
const template = TEMPLATES[templateName];
|
|
117
46
|
if (!template) {
|
|
118
47
|
console.error(`Unknown template: ${templateName}`);
|
|
119
|
-
console.log('Available:
|
|
48
|
+
console.log('Available: simple, journeys');
|
|
120
49
|
process.exit(1);
|
|
121
50
|
}
|
|
122
|
-
// Create llms.txt if needed (not for MCP platforms)
|
|
123
|
-
if (!options.platform && !fs.existsSync('llms.txt')) {
|
|
124
|
-
await createLLMSTxt();
|
|
125
|
-
}
|
|
126
51
|
// Write config
|
|
127
52
|
fs.writeFileSync('docworks.yml', template);
|
|
128
53
|
console.log('✅ Created docworks.yml\n');
|
|
129
54
|
// Next steps
|
|
130
55
|
console.log('Next steps:');
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log('2. Set your API key:');
|
|
56
|
+
console.log('1. Update the source URL to your documentation');
|
|
57
|
+
console.log('2. Customize the questions for your needs');
|
|
58
|
+
console.log('3. Set your API key:');
|
|
135
59
|
console.log(' export OPENAI_API_KEY=sk-...');
|
|
136
|
-
console.log('
|
|
60
|
+
console.log(' # or for Anthropic:');
|
|
61
|
+
console.log(' export ANTHROPIC_API_KEY=sk-ant-...');
|
|
62
|
+
console.log('4. Run validation:');
|
|
137
63
|
console.log(' docworks check');
|
|
138
64
|
}
|
|
139
|
-
async function createLLMSTxt() {
|
|
140
|
-
console.log('📝 Creating llms.txt...');
|
|
141
|
-
// Find common documentation files
|
|
142
|
-
const patterns = ['README.md', 'readme.md', 'docs/**/*.md', '*.md'];
|
|
143
|
-
const files = new Set();
|
|
144
|
-
for (const pattern of patterns) {
|
|
145
|
-
const matches = await glob(pattern, {
|
|
146
|
-
ignore: ['node_modules/**', '.git/**', 'CHANGELOG.md'],
|
|
147
|
-
});
|
|
148
|
-
matches.forEach((file) => files.add(file));
|
|
149
|
-
}
|
|
150
|
-
const content = [
|
|
151
|
-
'# Documentation sources for DocWorks',
|
|
152
|
-
'# Add your documentation files below, one per line',
|
|
153
|
-
'# Lines starting with # are comments',
|
|
154
|
-
'',
|
|
155
|
-
...Array.from(files).slice(0, 20), // Limit initial list
|
|
156
|
-
'',
|
|
157
|
-
'# Add more files as needed:',
|
|
158
|
-
'# docs/api/authentication.md',
|
|
159
|
-
'# examples/quickstart.js',
|
|
160
|
-
'# https://api.example.com/openapi.json',
|
|
161
|
-
].join('\n');
|
|
162
|
-
fs.writeFileSync('llms.txt', content);
|
|
163
|
-
console.log(`✅ Created llms.txt with ${files.size} documentation files\n`);
|
|
164
|
-
}
|
|
165
65
|
//# sourceMappingURL=init.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AAEnB,MAAM,SAAS,GAAG;IAChB,MAAM,EAAE;;;;;;;;;;;;;8BAaoB;IAE5B,QAAQ,EAAE;;;;;;;;;;;;;;;;;8BAiBkB;CAC7B,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAA8B;IACvD,OAA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
1
|
-
import { ValidationResult, JourneyResults } from '../types/config.js';
|
|
2
|
-
export declare function validateJourneys(journeys: Record<string, string[]>, docs: string, apiKey: string,
|
|
3
|
-
export declare function validateQuestions(questions: string[], docs: string, apiKey: string,
|
|
1
|
+
import { ValidationResult, JourneyResults, DocWorksConfig } from '../types/config.js';
|
|
2
|
+
export declare function validateJourneys(journeys: Record<string, string[]>, docs: string, apiKey: string, config?: DocWorksConfig): Promise<JourneyResults>;
|
|
3
|
+
export declare function validateQuestions(questions: string[], docs: string, apiKey: string, config?: DocWorksConfig): Promise<ValidationResult[]>;
|
|
4
4
|
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/core/validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/core/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,oBAAoB,CAAA;AAG3B,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,cAAc,CAAC,CAQzB;AAED,wBAAsB,iBAAiB,CACrC,SAAS,EAAE,MAAM,EAAE,EACnB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA+B7B"}
|