agdex 0.1.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.
Files changed (46) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +190 -0
  3. package/dist/cli/index.d.ts +3 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +7289 -0
  6. package/dist/index-6dj5che8.js +859 -0
  7. package/dist/index-6e18afd7.js +1229 -0
  8. package/dist/index-7adbtddf.js +1123 -0
  9. package/dist/index-db6kreh4.js +1188 -0
  10. package/dist/index-exr11by8.js +708 -0
  11. package/dist/index-fxmpwsct.js +779 -0
  12. package/dist/index-gtzz9131.js +708 -0
  13. package/dist/index-hr5jh9yq.js +712 -0
  14. package/dist/index-k299aha0.js +1229 -0
  15. package/dist/index-ntpyfcve.js +1154 -0
  16. package/dist/index-pry8ssn1.js +636 -0
  17. package/dist/index-wgnqr8g3.js +882 -0
  18. package/dist/index-y6zqcrbh.js +788 -0
  19. package/dist/index.d.ts +43 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +70 -0
  22. package/dist/lib/agents-md.d.ts +55 -0
  23. package/dist/lib/agents-md.d.ts.map +1 -0
  24. package/dist/lib/providers/bun.d.ts +3 -0
  25. package/dist/lib/providers/bun.d.ts.map +1 -0
  26. package/dist/lib/providers/conda-forge.d.ts +3 -0
  27. package/dist/lib/providers/conda-forge.d.ts.map +1 -0
  28. package/dist/lib/providers/generic.d.ts +37 -0
  29. package/dist/lib/providers/generic.d.ts.map +1 -0
  30. package/dist/lib/providers/index.d.ts +26 -0
  31. package/dist/lib/providers/index.d.ts.map +1 -0
  32. package/dist/lib/providers/nextjs.d.ts +3 -0
  33. package/dist/lib/providers/nextjs.d.ts.map +1 -0
  34. package/dist/lib/providers/pixi.d.ts +3 -0
  35. package/dist/lib/providers/pixi.d.ts.map +1 -0
  36. package/dist/lib/providers/rattler-build.d.ts +3 -0
  37. package/dist/lib/providers/rattler-build.d.ts.map +1 -0
  38. package/dist/lib/providers/react.d.ts +3 -0
  39. package/dist/lib/providers/react.d.ts.map +1 -0
  40. package/dist/lib/providers/tauri.d.ts +3 -0
  41. package/dist/lib/providers/tauri.d.ts.map +1 -0
  42. package/dist/lib/skills.d.ts +53 -0
  43. package/dist/lib/skills.d.ts.map +1 -0
  44. package/dist/lib/types.d.ts +126 -0
  45. package/dist/lib/types.d.ts.map +1 -0
  46. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 Logan Lang
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # agdex
2
+
3
+ Embed compressed documentation indexes into `AGENTS.md` or `CLAUDE.md` for AI coding agents.
4
+
5
+ This package helps AI coding agents (Claude, Cursor, etc.) work with version-matched framework documentation by embedding a compressed docs index directly into your project's markdown file. Based on [Vercel's research](https://vercel.com/blog/teaching-ai-agents-how-to-use-nextjs) showing that embedded docs achieve 100% pass rates compared to 79% for skills.
6
+
7
+ ## Why?
8
+
9
+ AI coding agents rely on training data that becomes outdated. When agents don't know current APIs, they generate incorrect code. This tool:
10
+
11
+ 1. Downloads version-matched documentation from GitHub
12
+ 2. Creates a compressed index (~8KB for Next.js)
13
+ 3. Embeds it in your `AGENTS.md` or `CLAUDE.md`
14
+ 4. Agents can then retrieve specific docs on demand
15
+
16
+ The key instruction embedded tells agents to **prefer retrieval-led reasoning over pre-training-led reasoning**.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ # Using bun
22
+ bun add -D agdex
23
+
24
+ # Using npm
25
+ npm install -D agdex
26
+
27
+ # Or run directly with npx
28
+ npx agdex
29
+ ```
30
+
31
+ ## CLI Usage
32
+
33
+ ### Interactive Mode
34
+
35
+ ```bash
36
+ npx agdex
37
+ ```
38
+
39
+ Prompts you to select a provider, version, and output file.
40
+
41
+ ### Built-in Providers
42
+
43
+ ```bash
44
+ # Next.js (auto-detects version from package.json)
45
+ npx agdex --provider nextjs --output AGENTS.md
46
+
47
+ # With explicit version
48
+ npx agdex --provider nextjs --fw-version 15.1.0 --output CLAUDE.md
49
+
50
+ # React
51
+ npx agdex --provider react --fw-version 18.2.0 --output AGENTS.md
52
+
53
+ # Pixi (auto-detects from pixi.toml or installed version)
54
+ npx agdex --provider pixi --output AGENTS.md
55
+
56
+ # Pixi with explicit version
57
+ npx agdex --provider pixi --fw-version 0.63.2 --output AGENTS.md
58
+
59
+ # Bun (auto-detects from bun.lockb or bunfig.toml)
60
+ npx agdex --provider bun --output AGENTS.md
61
+ ```
62
+
63
+ ### Custom GitHub Repository
64
+
65
+ ```bash
66
+ npx agdex --repo owner/repo --docs-path docs --fw-version v1.0.0 --output AGENTS.md
67
+ ```
68
+
69
+ ### Local Documentation
70
+
71
+ Build an index from an existing local docs directory:
72
+
73
+ ```bash
74
+ npx agdex local ./docs --name "My Framework" --output AGENTS.md
75
+ ```
76
+
77
+ ### List Available Providers
78
+
79
+ ```bash
80
+ npx agdex list
81
+ ```
82
+
83
+ ## Programmatic API
84
+
85
+ ```typescript
86
+ import { embed, nextjsProvider, createProvider } from 'agdex'
87
+
88
+ // Use built-in provider
89
+ const result = await embed({
90
+ cwd: process.cwd(),
91
+ provider: nextjsProvider,
92
+ output: 'AGENTS.md'
93
+ })
94
+
95
+ // Create custom provider
96
+ const myProvider = createProvider({
97
+ name: 'my-framework',
98
+ displayName: 'My Framework',
99
+ repo: 'myorg/myframework',
100
+ docsPath: 'docs',
101
+ packageName: 'my-framework', // for auto-detection
102
+ })
103
+
104
+ await embed({
105
+ cwd: process.cwd(),
106
+ provider: myProvider,
107
+ version: '1.0.0',
108
+ output: 'CLAUDE.md'
109
+ })
110
+ ```
111
+
112
+ ### Building Index Manually
113
+
114
+ ```typescript
115
+ import {
116
+ collectDocFiles,
117
+ buildDocTree,
118
+ generateIndex,
119
+ injectIndex
120
+ } from 'agdex'
121
+
122
+ // Collect doc files
123
+ const files = collectDocFiles('./docs', {
124
+ extensions: ['.md', '.mdx']
125
+ })
126
+
127
+ // Build tree structure
128
+ const sections = buildDocTree(files)
129
+
130
+ // Generate compressed index
131
+ const index = generateIndex({
132
+ docsPath: './docs',
133
+ sections,
134
+ providerName: 'My Docs',
135
+ instruction: 'Use retrieval-led reasoning.'
136
+ })
137
+
138
+ // Inject into existing content
139
+ const newContent = injectIndex(existingContent, index)
140
+ ```
141
+
142
+ ## Output Format
143
+
144
+ The generated index uses a compressed pipe-delimited format:
145
+
146
+ ```
147
+ [Next.js Docs Index]|root: ./.nextjs-docs|IMPORTANT: Prefer retrieval-led reasoning...|01-app/01-getting-started:{01-installation.mdx,02-project-structure.mdx}|...
148
+ ```
149
+
150
+ This format:
151
+ - Minimizes context window usage (~8KB for Next.js)
152
+ - Provides enough structure for agents to find relevant docs
153
+ - Includes instructions for retrieval-led reasoning
154
+ - Wraps in HTML comments for clean updates
155
+
156
+ ## Available Providers
157
+
158
+ | Provider | Status | Repository |
159
+ |----------------|--------|------------|
160
+ | Next.js | ✓ | vercel/next.js |
161
+ | React | ✓ | reactjs/react.dev |
162
+ | Pixi | ✓ | prefix-dev/pixi |
163
+ | rattler-build | ✓ | prefix-dev/rattler-build |
164
+ | Tauri | ✓ | tauri-apps/tauri-docs |
165
+ | conda-forge | ✓ | conda-forge/conda-forge.github.io |
166
+ | Bun | ✓ | oven-sh/bun |
167
+ | Vue | ○ | Coming soon |
168
+ | Svelte | ○ | Coming soon |
169
+ | Astro | ○ | Coming soon |
170
+
171
+ ## How It Works
172
+
173
+ 1. **Detection**: Reads `package.json` to detect framework version
174
+ 2. **Download**: Uses git sparse-checkout to fetch only docs folder
175
+ 3. **Index**: Builds a tree of all doc files
176
+ 4. **Compress**: Generates pipe-delimited format
177
+ 5. **Inject**: Adds to AGENTS.md with markers for updates
178
+ 6. **Gitignore**: Adds docs directory to .gitignore
179
+
180
+ ## Contributing
181
+
182
+ Contributions welcome! To add a new provider:
183
+
184
+ 1. Create `src/lib/providers/[name].ts`
185
+ 2. Export provider from `src/lib/providers/index.ts`
186
+ 3. Add to provider list in CLI
187
+
188
+ ## License
189
+
190
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}