askexperts-coder
v1.0.29
Published
Convert code to RAG for AI experts
Readme
askexperts-coder
Convert 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.
Overview
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
askexpertsdocstore import - Supports Lightning Network payments for AI processing via NWC (Nostr Wallet Connect)
Installation
npm install -g askexperts-coderOr install locally:
npm install askexperts-coderPrerequisites
- Node.js (version 16 or higher)
- TypeScript project to analyze
- Lightning Network wallet with NWC support (for AI processing)
- Git repository (for tracking changes)
Complete Workflow
Here's the complete process to create an AI expert from your TypeScript codebase:
1. Analyze Symbols
First, explore your project structure and evaluate the indexer quality:
npx askexperts-coder symbols ./my-project -d2. Generate Documentation
Generate AI-powered documentation for all symbols:
npx askexperts-coder generate ./my-project -d --nwc "nostr+walletconnect://..."3. Prepare for Import
Convert the generated docs to docstore format:
npx askexperts-coder prepare ./my-project --dir ./prepared-docs -d4. Create 'askexperts' user
npx askexperts user add -d5. Create Docstore
Create a new docstore to hold your project documentation:
npx askexperts docstore create my_project_store -dPrints docstore_id - copy it and use below.
6. Import to Docstore
Import the prepared documentation into the docstore:
npx askexperts docstore import dir ./prepared-docs -s <docstore_id> -d7. Add wallet
npx askexperts wallet add main -n <nwc-wallet> -d8. Create Expert
Create a RAG-enabled expert using the imported documentation and wallet:
npx askexperts expert create rag my_project_expert -d -s <docstore_id> --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.
9. Launch RAG db
docker run -p 8000:8000 -v ./data:/data chromadb/chroma9. Launch Expert
npx askexperts expert run <expert_pubkey> -d10. Chat with Expert
npx askexperts expert chat <expert_pubkey> Commands
askexperts-coder generate <path_to_project>
Generate documentation for all symbols in a TypeScript project.
Usage:
npx askexperts-coder generate ./my-projectOptions:
-d, --debug- Enable debug output--nwc <string>- 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>- Number of parallel processing threads (default: 1)-b, --branch <string>- 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:
# 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 --continueaskexperts-coder prepare <package_path>
Convert generated documentation from the .askexperts directory to docstore format.
Usage:
npx askexperts-coder prepare ./my-project --output docs.txtOptions:
-d, --debug- Enable debug output-o, --output <file>- Output file path to write combined doc content--dir <directory>- Directory to write individual doc files as JSON
Description:
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:
# Create a single combined documentation file
npx askexperts-coder prepare ./my-project --output ./docs/combined-docs.txt
# Create individual JSON files for each symbol
npx askexperts-coder prepare ./my-project --dir ./docs/symbols/askexperts-coder symbols <package_path>
List all symbols found in a TypeScript project.
Usage:
npx askexperts-coder symbols ./my-projectOptions:
-d, --debug- Enable debug output
Description: 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:
# List all symbols with debug information
npx askexperts-coder symbols ./my-project --debugConfiguration
NWC (Nostr Wallet Connect) Setup
The tool requires a Lightning Network wallet connection for AI processing payments. You can provide the NWC string in two ways:
- Command line option: Use
--nwcwith any command - Configuration file: Create
~/.askexperts-coder.nwcfile containing your NWC string
The NWC string format is typically:
nostr+walletconnect://relay-url?secret=your-secret&lud16=your-lightning-addressProject Structure
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.jsonExamples
Complete workflow for a TypeScript project:
# 1. Explore the project structure and evaluate indexer quality
npx askexperts-coder symbols ./my-typescript-project
# 2. 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-docs
# 4. Create a docstore
npx askexperts docstore create my_project_store
# 5. Import to askexperts docstore
npx askexperts docstore import dir --docstore=my_project_store --path=./prepared-docs
# 6. 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 <expert_pubkey>Resuming interrupted documentation generation:
# If generation was interrupted, continue from where it left off
npx askexperts-coder generate ./my-project --continueHigh-performance documentation generation:
# Use multiple threads for faster processing
npx askexperts-coder generate ./my-project --threads 8 --debugCreating different output formats:
# 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.txtDevelopment
Scripts
npm run build- Compile TypeScript to JavaScriptnpm run start- Run the compiled CLInpm run dev- Run in development mode with ts-nodenpm test- Run tests (not implemented yet)
Building from source
git clone <repository-url>
cd askexperts-coder
npm install
npm run buildLicense
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
Common Issues
- "No NWC string available" - Provide NWC string via
--nwcoption or create~/.askexperts-coder.nwcfile - "Git tree is not clean" - Commit or stash your changes before running
generate - "Expected to be on branch 'main'" - Switch to the correct branch or use
--branchoption - "Project directory not found" - Ensure the path to your TypeScript project is correct
Debug Mode
Add --debug flag to any command to see detailed logging:
npx askexperts-coder generate ./my-project --debugThis will show:
- File processing progress
- Symbol analysis details
- AI processing status
- Error details and stack traces
