236 lines
4.4 KiB
Markdown
236 lines
4.4 KiB
Markdown
# CLI Command Reference
|
|
|
|
## Quick Reference
|
|
|
|
```bash
|
|
ai-context [options]
|
|
```
|
|
|
|
## Global Options
|
|
|
|
| Option | Type | Default | Description |
|
|
|--------|------|---------|-------------|
|
|
| `--dir` | string | `process.cwd()` | Project directory to analyze |
|
|
| `--output` | string | `ai-context` | Output file path (without extension) |
|
|
| `--format` | string | `json` | Output format: `json` or `yaml` |
|
|
| `--template` | string | `default` | Template: `default`, `cursor`, `copilot`, `generic` |
|
|
| `--config` | string | auto-detected | Config file path |
|
|
| `--verbose` | boolean | `false` | Enable verbose output |
|
|
| `--no-conventions` | boolean | `false` | Skip convention analysis |
|
|
| `--include-dev` | boolean | `false` | Include dev dependencies |
|
|
| `--no-gitignore` | boolean | `false` | Do not respect .gitignore |
|
|
|
|
## Detailed Options
|
|
|
|
### `--dir`, `-d`
|
|
|
|
Specifies the project directory to analyze.
|
|
|
|
```bash
|
|
ai-context --dir /path/to/project
|
|
ai-context -d ./my-project
|
|
```
|
|
|
|
If not specified, uses the current working directory.
|
|
|
|
### `--output`, `-o`
|
|
|
|
Specifies the output file path. The file extension is automatically added based on the format.
|
|
|
|
```bash
|
|
ai-context --output my-context
|
|
# Creates my-context.json or my-context.yaml
|
|
|
|
ai-context --output /absolute/path/output
|
|
# Creates /absolute/path/output.json
|
|
```
|
|
|
|
### `--format`, `-f`
|
|
|
|
Specifies the output format.
|
|
|
|
```bash
|
|
# JSON output (default)
|
|
ai-context --format json
|
|
|
|
# YAML output
|
|
ai-context --format yaml
|
|
```
|
|
|
|
### `--template`, `-t`
|
|
|
|
Specifies the template for context output.
|
|
|
|
```bash
|
|
# Default template
|
|
ai-context --template default
|
|
|
|
# Cursor-optimized template
|
|
ai-context --template cursor
|
|
|
|
# Copilot-optimized template
|
|
ai-context --template copilot
|
|
|
|
# Generic template
|
|
ai-context --template generic
|
|
```
|
|
|
|
### `--config`, `-c`
|
|
|
|
Specifies a custom config file path.
|
|
|
|
```bash
|
|
ai-context --config /path/to/config.json
|
|
ai-context -c ./custom-config.json
|
|
```
|
|
|
|
If not specified, automatically looks for `.ai-context-config.json` in the project directory.
|
|
|
|
### `--verbose`, `-v`
|
|
|
|
Enables verbose output for debugging.
|
|
|
|
```bash
|
|
ai-context --verbose
|
|
ai-context -v
|
|
```
|
|
|
|
Output includes:
|
|
- Analyzed directory
|
|
- Output file path
|
|
- Format and template selection
|
|
- Analysis progress
|
|
|
|
### `--no-conventions`
|
|
|
|
Skips convention analysis for faster processing.
|
|
|
|
```bash
|
|
ai-context --no-conventions
|
|
```
|
|
|
|
### `--include-dev`
|
|
|
|
Includes development dependencies in the analysis.
|
|
|
|
```bash
|
|
ai-context --include-dev
|
|
```
|
|
|
|
### `--no-gitignore`
|
|
|
|
Disables `.gitignore` pattern matching.
|
|
|
|
```bash
|
|
ai-context --no-gitignore
|
|
```
|
|
|
|
## Exit Codes
|
|
|
|
| Code | Description |
|
|
|------|-------------|
|
|
| `0` | Success |
|
|
| `1` | Error (see error message for details) |
|
|
|
|
## Examples
|
|
|
|
### Basic Analysis
|
|
|
|
```bash
|
|
# Analyze current directory
|
|
ai-context
|
|
|
|
# Analyze specific directory with verbose output
|
|
ai-context --dir ./my-project --verbose
|
|
|
|
# Generate YAML output
|
|
ai-context --format yaml --output project-context
|
|
```
|
|
|
|
### Custom Output
|
|
|
|
```bash
|
|
# Custom output file name
|
|
ai-context --output my-ai-context
|
|
|
|
# Different format
|
|
ai-context --format yaml --output context
|
|
|
|
# Use specific template
|
|
ai-context --template cursor --output cursor-context
|
|
```
|
|
|
|
### Advanced Options
|
|
|
|
```bash
|
|
# Full analysis with all options
|
|
ai-context --dir ./project --verbose --include-dev
|
|
|
|
# Skip conventions for speed
|
|
ai-context --no-conventions --output quick-context
|
|
|
|
# Ignore gitignore
|
|
ai-context --no-gitignore --output all-files-context
|
|
```
|
|
|
|
### Combined Options
|
|
|
|
```bash
|
|
# Analyze Python project with conventions
|
|
ai-context --dir ./python-app --format yaml --no-conventions
|
|
|
|
# Analyze with dev dependencies
|
|
ai-context --dir ./node-app --include-dev --template copilot
|
|
|
|
# Full verbose analysis
|
|
ai-context --dir ./full-stack-app --verbose --format json --include-dev --template cursor
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Command Not Found
|
|
|
|
If `ai-context` is not found after installation:
|
|
|
|
```bash
|
|
# Re-link the CLI
|
|
npm unlink
|
|
npm link
|
|
|
|
# Or use npx
|
|
npx ai-context-generator-cli --dir ./project
|
|
```
|
|
|
|
### Permission Denied
|
|
|
|
On Unix systems, you may need to make the script executable:
|
|
|
|
```bash
|
|
chmod +x dist/index.js
|
|
```
|
|
|
|
Or run with node directly:
|
|
|
|
```bash
|
|
node dist/index.js --dir ./project
|
|
```
|
|
|
|
### Slow Analysis
|
|
|
|
For large projects, use:
|
|
|
|
```bash
|
|
# Skip conventions
|
|
ai-context --no-conventions
|
|
|
|
# Skip dev dependencies
|
|
ai-context --no-include-dev
|
|
|
|
# Limit file patterns
|
|
ai-context --dir ./project --format json
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
Currently, the CLI does not use environment variables. All configuration is done via CLI options or config files.
|