Convert code to RAG for AI experts
npm install askexperts-coderConvert code to RAG (Retrieval-Augmented Generation) for AI experts. This tool analyzes TypeScript projects, generates documentation for symbols, and prepares them for import into the askexperts docstore system.
askexperts-coder is a powerful tool that:
- Analyzes TypeScript projects and extracts all symbols (functions, classes, interfaces, etc.)
- Generates comprehensive documentation for each symbol using AI
- Prepares documentation in the format required for askexperts docstore import
- Supports Lightning Network payments for AI processing via NWC (Nostr Wallet Connect)
``bash`
npm install -g askexperts-coder
Or install locally:
`bash`
npm install askexperts-coder
- Node.js (version 16 or higher)
- TypeScript project to analyze
- Lightning Network wallet with NWC support (for AI processing)
- Git repository (for tracking changes)
Here's the complete process to create an AI expert from your TypeScript codebase:
bash
npx askexperts-coder symbols ./my-project -d
`$3
Generate AI-powered documentation for all symbols:
`bash
npx askexperts-coder generate ./my-project -d --nwc "nostr+walletconnect://..."
`$3
Convert the generated docs to docstore format:
`bash
npx askexperts-coder prepare ./my-project --dir ./prepared-docs -d
`$3
`bash
npx askexperts user add -d
`$3
Create a new docstore to hold your project documentation:
`bash
npx askexperts docstore create my_project_store -d
`
Prints docstore_id - copy it and use below.$3
Import the prepared documentation into the docstore:
`bash
npx askexperts docstore import dir ./prepared-docs -s -d
`$3
`bash
npx askexperts wallet add main -n -d
`$3
Create a RAG-enabled expert using the imported documentation and wallet:
`bash
npx askexperts expert create rag my_project_expert -d -s --model gpt-4 --system_prompt "You are an expert on my TypeScript project. Use the provided documentation to answer questions accurately."
`
Prints expert pubkey - copy it and use below.$3
`bash
docker run -p 8000:8000 -v ./data:/data chromadb/chroma
`$3
`bash
npx askexperts expert run -d
`$3
`bash
npx askexperts expert chat
`Commands
$3
Generate documentation for all symbols in a TypeScript project.
Usage:
`bash
npx askexperts-coder generate ./my-project
`Options:
-
-d, --debug - Enable debug output
- --nwc - Lightning Node Connect (NWC) string for payment
- -n, --name - Symbol name to find if it is exported
- -c, --continue - Continue processing, skipping symbols that are already documented
- -t, --threads - Number of parallel processing threads (default: 1)
- -b, --branch - Expected git branch (default: main)Description:
This command analyzes your TypeScript project and generates AI-powered documentation for every symbol. It creates a
.askexperts directory in your project containing JSON files with detailed documentation for each symbol.Requirements:
- Clean git working tree
- Must be on the specified branch (default: main)
- Valid NWC string for Lightning payments
Example:
`bash
Generate docs with debug output and 4 parallel threads
npx askexperts-coder generate ./my-project --debug --threads 4 --nwc "nostr+walletconnect://..."Continue interrupted generation
npx askexperts-coder generate ./my-project --continue
`$3
Convert generated documentation from the
.askexperts directory to docstore format.Usage:
`bash
npx askexperts-coder prepare ./my-project --output docs.txt
`Options:
-
-d, --debug - Enable debug output
- -o, --output - Output file path to write combined doc content
- --dir - Directory to write individual doc files as JSONDescription:
This command processes the JSON files generated by the
generate command and converts them into a format suitable for RAG systems. You must specify either --output or --dir option.Example:
`bash
Create a single combined documentation file
npx askexperts-coder prepare ./my-project --output ./docs/combined-docs.txtCreate individual JSON files for each symbol
npx askexperts-coder prepare ./my-project --dir ./docs/symbols/
`$3
List all symbols found in a TypeScript project.
Usage:
`bash
npx askexperts-coder symbols ./my-project
`Options:
-
-d, --debug - Enable debug outputDescription:
This command analyzes a TypeScript project and prints all discovered symbols with their locations, types, and relationships. Useful for understanding the structure of your codebase before generating documentation.
Example:
`bash
List all symbols with debug information
npx askexperts-coder symbols ./my-project --debug
`Configuration
$3
The tool requires a Lightning Network wallet connection for AI processing payments. You can provide the NWC string in two ways:
1. Command line option: Use
--nwc with any command
2. Configuration file: Create ~/.askexperts-coder.nwc file containing your NWC stringThe NWC string format is typically:
`
nostr+walletconnect://relay-url?secret=your-secret&lud16=your-lightning-address
`$3
After running the
generate command, your project will contain:`
your-project/
├── .askexperts/
│ ├── commit.git # Git commit hash when docs were generated
│ ├── src/
│ │ ├── file1.ts.json # Documentation for file1.ts symbols
│ │ └── file2.ts.json # Documentation for file2.ts symbols
│ └── ...
├── src/
│ ├── file1.ts
│ └── file2.ts
└── package.json
`Examples
$3
`bash
1. Explore the project structure and evaluate indexer quality
npx askexperts-coder symbols ./my-typescript-project2. Generate documentation (requires NWC for payments)
npx askexperts-coder generate ./my-typescript-project --nwc "nostr+walletconnect://..."3. Prepare documentation for docstore import
npx askexperts-coder prepare ./my-typescript-project --dir ./prepared-docs4. Create a docstore
npx askexperts docstore create my_project_store5. Import to askexperts docstore
npx askexperts docstore import dir --docstore=my_project_store --path=./prepared-docs6. Create an expert
npx askexperts expert create rag my_project_expert -s my_project_store --model gpt-4 --system_prompt "Expert on my TypeScript project"7. Launch the expert
npx askexperts expert run
`$3
`bash
If generation was interrupted, continue from where it left off
npx askexperts-coder generate ./my-project --continue
`$3
`bash
Use multiple threads for faster processing
npx askexperts-coder generate ./my-project --threads 8 --debug
`$3
`bash
Create individual JSON files for each symbol
npx askexperts-coder prepare ./my-project --dir ./docs/symbols/Create a single combined documentation file
npx askexperts-coder prepare ./my-project --output ./docs/combined-docs.txt
`Development
$3
-
npm run build - Compile TypeScript to JavaScript
- npm run start - Run the compiled CLI
- npm run dev - Run in development mode with ts-node
- npm test - Run tests (not implemented yet)$3
`bash
git clone
cd askexperts-coder
npm install
npm run build
`License
MIT
Dependencies
- askexperts - Core AI expert functionality
- commander - CLI framework
- nostr-tools - Nostr protocol implementation
- openai - OpenAI API client
- @noble/hashes - Cryptographic hashing
- debug - Debug logging utility
Troubleshooting
$3
1. "No NWC string available" - Provide NWC string via
--nwc option or create ~/.askexperts-coder.nwc file
2. "Git tree is not clean" - Commit or stash your changes before running generate
3. "Expected to be on branch 'main'" - Switch to the correct branch or use --branch option
4. "Project directory not found" - Ensure the path to your TypeScript project is correct$3
Add
--debug flag to any command to see detailed logging:`bash
npx askexperts-coder generate ./my-project --debug
``This will show:
- File processing progress
- Symbol analysis details
- AI processing status
- Error details and stack traces