Docsgene
raw JSON → 1.0.0 verified Sat Apr 25 auth: no javascript
Docsgene (v1.0.0) is an AI-focused tool that bundles codebase context into a single file optimized for LLM ingestion. It scans project files, intelligently selects relevant code, and outputs a compact representation that preserves dependencies and structure, reducing token overhead. Released as initial stable version; no established release cadence yet. Key differentiator: purpose-built for LLM context windows, unlike generic bundlers.
Common errors
error TypeError: docsgene_1.bundleCodebase is not a function ↓
cause Using CommonJS require() on an ESM-only package, getting the module's default export object instead of named export.
fix
Use import { bundleCodebase } from 'docsgene' or const { bundleCodebase } = await import('docsgene').
error SyntaxError: Cannot use import statement outside a module ↓
cause Running in a non-module context (e.g., plain .js file without type: module).
fix
Add "type": "module" to package.json, rename file to .mjs, or use dynamic import().
error Module not found: Can't resolve 'docsgene' in 'C:\project' ↓
cause Package not installed or typo in package name.
fix
Run 'npm install docsgene' and ensure correct import path.
Warnings
breaking ESM-only: package does not support CommonJS require(). ↓
fix Use import syntax. If using Node.js, set "type": "module" in package.json or use .mjs extension.
gotcha Default ignore patterns may not exclude large directories like .git or build outputs; can cause token overflow. ↓
fix Explicitly pass ignorePatterns for all non-essential directories.
gotcha maxTokens setting does not strictly enforce token limit; it's a guideline for chunking. ↓
fix Monitor tokenCount in result and adjust maxTokens or ignorePatterns accordingly.
Install
npm install docsgene yarn add docsgene pnpm add docsgene Imports
- bundleCodebase wrong
const bundleCodebase = require('docsgene')correctimport { bundleCodebase } from 'docsgene' - DocsgeneConfig wrong
import { DocsgeneConfig } from 'docsgene' (will cause runtime error if used as value)correctimport type { DocsgeneConfig } from 'docsgene' - default wrong
import { default } from 'docsgene'correctimport docsgene from 'docsgene'
Quickstart
import { bundleCodebase } from 'docsgene';
const result = await bundleCodebase({
sourceDir: './src',
outputFile: './context.txt',
ignorePatterns: ['node_modules', 'dist'],
maxTokens: 8000,
includeComments: false,
});
console.log('Bundled context written to', result.outputPath);
console.log('Token count:', result.tokenCount);