docworks 0.17.0-next.1 → 0.17.0-next.2

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 CHANGED
@@ -208,6 +208,10 @@ Contributions welcome! We're especially looking for:
208
208
  - Documentation platform integrations
209
209
  - Journey templates for common use cases
210
210
 
211
+ ### Development Setup
212
+
213
+ Pre-commit hooks are automatically installed when you run `pnpm install`. These hooks run linting and formatting checks before each commit to ensure code quality. If you need to bypass them (not recommended), use `git commit --no-verify`.
214
+
211
215
  ## Why DocWorks?
212
216
 
213
217
  - **Real-world testing** - AI navigates docs like developers do
@@ -1,4 +1,4 @@
1
- export declare function fetchDocumentation(url: string): Promise<{
1
+ export declare function fetchDocumentation(source: string): Promise<{
2
2
  content: string;
3
3
  name: string;
4
4
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/sources/source.ts"],"names":[],"mappings":"AAAA,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA0B5C"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/sources/source.ts"],"names":[],"mappings":"AA2DA,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAY5C"}
@@ -1,23 +1,58 @@
1
- export async function fetchDocumentation(url) {
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ function isUrl(source) {
2
4
  try {
3
- // Try to fetch llms.txt
4
- const llmsTxtUrl = new URL('/llms.txt', url).href;
5
- console.log(`Fetching ${llmsTxtUrl}...`);
6
- let response = await fetch(llmsTxtUrl);
5
+ // Check for protocol
6
+ if (!source.includes('://')) {
7
+ return false;
8
+ }
9
+ // Try to construct a URL object - will throw if invalid
10
+ new URL(source);
11
+ return true;
12
+ }
13
+ catch {
14
+ return false;
15
+ }
16
+ }
17
+ async function readFromFile(filePath) {
18
+ const resolvedPath = path.resolve(filePath);
19
+ if (!fs.existsSync(resolvedPath)) {
20
+ throw new Error(`File not found: ${resolvedPath}`);
21
+ }
22
+ console.log(`Reading ${resolvedPath}...`);
23
+ const content = fs.readFileSync(resolvedPath, 'utf-8');
24
+ const name = `${path.basename(resolvedPath)} from local file`;
25
+ console.log('✓ Loaded documentation\n');
26
+ return { content, name };
27
+ }
28
+ async function fetchFromUrl(url) {
29
+ // Try to fetch llms.txt
30
+ const llmsTxtUrl = new URL('/llms.txt', url).href;
31
+ console.log(`Fetching ${llmsTxtUrl}...`);
32
+ let response = await fetch(llmsTxtUrl);
33
+ if (!response.ok) {
34
+ // Maybe they provided the llms.txt URL directly
35
+ response = await fetch(url);
7
36
  if (!response.ok) {
8
- // Maybe they provided the llms.txt URL directly
9
- response = await fetch(url);
10
- if (!response.ok) {
11
- throw new Error(`No llms.txt found at ${url}`);
12
- }
37
+ throw new Error(`No llms.txt found at ${url}`);
38
+ }
39
+ }
40
+ const content = await response.text();
41
+ const name = `llms.txt from ${new URL(url).hostname}`;
42
+ console.log('✓ Fetched documentation\n');
43
+ return { content, name };
44
+ }
45
+ export async function fetchDocumentation(source) {
46
+ try {
47
+ if (isUrl(source)) {
48
+ return await fetchFromUrl(source);
49
+ }
50
+ else {
51
+ return await readFromFile(source);
13
52
  }
14
- const content = await response.text();
15
- const name = `llms.txt from ${new URL(url).hostname}`;
16
- console.log('✓ Fetched documentation\n');
17
- return { content, name };
18
53
  }
19
54
  catch (error) {
20
- throw new Error(`Failed to fetch documentation from ${url}: ${error.message}`);
55
+ throw new Error(`Failed to fetch documentation from ${source}: ${error.message}`);
21
56
  }
22
57
  }
23
58
  //# sourceMappingURL=source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/sources/source.ts"],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AG,EAAE,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IACrC,MAAM,IAAI,GAAG,iBAAiB,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAA;IAErD,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;IACxC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC1B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,MAAc;IAEd,IAAI,CAAC;QACH,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAClB,OAAO,MAAM,YAAY,CAAC,MAAM,CAAC,CAAA;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,YAAY,CAAC,MAAM,CAAC,CAAA;QACnC,CAAC;IACH,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,sCAAsC,MAAM,KAAK,KAAK,CAAC,OAAO,EAAE,CACjE,CAAA;IACH,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docworks",
3
- "version": "0.17.0-next.1",
3
+ "version": "0.17.0-next.2",
4
4
  "description": "Ensure your docs work for developers and AI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,8 +9,10 @@
9
9
  },
10
10
  "scripts": {
11
11
  "build": "tsc",
12
+ "build:standalone": "npm run build && npx @vercel/ncc build dist/index.js -o standalone -m",
12
13
  "test": "echo \"Error: no test specified\" && exit 1",
13
14
  "dev": "tsc --watch",
15
+ "prepare": "husky",
14
16
  "prepublishOnly": "npm run build",
15
17
  "format": "prettier --write .",
16
18
  "format:check": "prettier --check .",
@@ -29,6 +31,8 @@
29
31
  "yaml": "^2.0.0"
30
32
  },
31
33
  "devDependencies": {
34
+ "@commitlint/cli": "^20.1.0",
35
+ "@commitlint/config-conventional": "^20.0.0",
32
36
  "@eslint/js": "^9.35.0",
33
37
  "@semantic-release/changelog": "^6.0.3",
34
38
  "@semantic-release/exec": "^7.1.0",
@@ -41,7 +45,6 @@
41
45
  "eslint-config-prettier": "^10.1.8",
42
46
  "husky": "^9.1.7",
43
47
  "lint-staged": "^16.1.6",
44
- "node": "link:@@types/node",
45
48
  "prettier": "^3.6.2",
46
49
  "semantic-release": "^24.2.7",
47
50
  "typescript": "^5.0.0",