Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ pnpm-debug.log*

# OS
.DS_Store
Thumbs.db
Thumbs.db

# Dev-agent local data
.dev-agent.json
.dev-agent/
69 changes: 47 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,40 +156,65 @@ pnpm build

### Quick Start

**For Local Development:**

```bash
# Index your repository
dev-agent index
# Link the CLI globally for local testing
cd packages/cli
npm link

# Now you can use 'dev' anywhere
cd ~/your-project
dev init
dev index .
```

# Search with beautiful output
dev-agent search "authentication logic"
**Basic Commands:**

# Get AI help planning work
dev-agent plan --issue 42
```bash
# Index your repository
dev index .

# Discover patterns in your codebase
dev-agent explore "error handling patterns"
# Semantic search (natural language queries work!)
dev search "how do agents communicate"
dev search "vector embeddings"
dev search "error handling" --threshold 0.3

# Create PR with AI-generated description
dev-agent pr create
# Explore code patterns
dev explore pattern "test coverage utilities" --limit 5
dev explore similar path/to/file.ts

# JSON output for scripting
dev-agent search "auth" --json | jq '.results[].file'
# View statistics
dev stats
```

**Example output:**
```
πŸ” Searching for "authentication"...
**Real Example Output:**

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
πŸ“„ auth/oauth.ts:45-67 (score: 0.92)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
export class OAuth2Service {
authenticate(code: string) { ... }
}
```bash
$ dev search "vector embeddings" --threshold 0.3 --limit 3

1. EmbeddingProvider (58.5% match)
File: packages/core/src/vector/types.ts:36-54
Signature: interface EmbeddingProvider
Doc: Generates vector embeddings from text

2. EmbeddingDocument (51.0% match)
File: packages/core/src/vector/types.ts:8-12
Signature: interface EmbeddingDocument

✨ Found 5 results in 42ms
3. VectorStore (47.9% match)
File: packages/core/src/vector/types.ts:60-97
Signature: interface VectorStore
Doc: Stores and retrieves vector embeddings

βœ” Found 3 result(s)
```

**Tips for Better Results:**
- **Use natural language**: "how do agents communicate" works better than "agent message"
- **Adjust thresholds**: Default is 0.7 (precise), use 0.25-0.4 for exploration
- **Exact matches score 70-90%**: Semantic matches score 25-60%

### Current Status

**In Progress:** Building core intelligence layer (scanner, vectors, indexer)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"@commitlint/cli": "^20.1.0",
"@commitlint/config-conventional": "^20.0.0",
"@tsconfig/node-lts": "^22.0.0",
"@vitest/coverage-v8": "^4.0.3",
"husky": "^9.0.11",
"turbo": "^2.5.8",
"typescript": "^5.3.3",
"vitest": "^4.0.3",
"@vitest/coverage-v8": "^4.0.3"
"vitest": "^4.0.3"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
91 changes: 84 additions & 7 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ Options:
- `-t, --threshold <number>` - Minimum similarity score 0-1 (default: 0.7)
- `--json` - Output as JSON

**Understanding Thresholds:**
- `0.7` (default): Precise matches only
- `0.4-0.6`: Balanced - good for most searches
- `0.25-0.3`: Exploratory - finds related concepts
- `0.0`: Return everything (useful for debugging)

### Explore

Explore code patterns and relationships:

```bash
# Find patterns using semantic search
dev explore pattern "error handling" --limit 5

# Find code similar to a file
dev explore similar path/to/file.ts --limit 5
```

Options:
- `-l, --limit <number>` - Maximum results (default: 10)
- `-t, --threshold <number>` - Minimum similarity score (default: 0.7)

### Update

Incrementally update the index with changed files:
Expand Down Expand Up @@ -107,22 +129,77 @@ The `.dev-agent.json` file configures the indexer:

## Examples

### Basic Workflow

```bash
# Initialize and index
dev init
dev index .

# Search for code
dev search "user authentication flow"
dev search "database connection pool" --limit 5
# View statistics
dev stats
# πŸ“Š Files Indexed: 54, Vectors Stored: 566
```

### Semantic Search Examples

```bash
# Natural language queries work great!
dev search "how do agents communicate" --threshold 0.3

# Results:
# 1. Message-Based Architecture (51.9% match)
# 2. AgentContext (43.1% match)
# 3. SubagentCoordinator.broadcastMessage (41.8% match)

# Technical concept search
dev search "vector embeddings" --threshold 0.3 --limit 3

# Results:
# 1. EmbeddingProvider (58.5% match)
# 2. EmbeddingDocument (51.0% match)
# 3. VectorStore (47.9% match)

# Exact term matching (high scores!)
dev search "RepositoryIndexer" --threshold 0.4

# Results:
# 1. RepositoryIndexer.index (85.7% match)
# 2. RepositoryIndexer (75.4% match)
```

### Pattern Exploration

```bash
# Find patterns in your codebase
dev explore pattern "test coverage utilities" --threshold 0.25

# Results:
# 1. Coverage Targets (56.0% match)
# 2. 100% Coverage on Utilities (50.8% match)
# 3. Testing (42.3% match)

# Discover error handling patterns
dev explore pattern "error handling" --threshold 0.3

# Results:
# 1. Handle Errors Gracefully (39.3% match)
# 2. createErrorResponse (35.9% match)
```

### Pro Tips

```bash
# JSON output for scripting
dev search "coordinator" --json | jq '.[].metadata.path' | sort -u

# Lower threshold for exploration
dev search "architectural patterns" --threshold 0.25 --limit 10

# Keep index up to date
dev update

# View statistics
dev stats

# Clean and re-index
# Clean and re-index if needed
dev clean --force
dev index . --force
```
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/commands/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ export const searchCommand = new Command('search')
const metadata = result.metadata;
const score = (result.score * 100).toFixed(1);

// Extract file info
const file = metadata.file as string;
const relativePath = path.relative(config.repositoryPath, file);
// Extract file info (metadata uses 'path', not 'file')
const filePath = (metadata.path || metadata.file) as string;
const relativePath = filePath ? path.relative(config.repositoryPath, filePath) : 'unknown';
const startLine = metadata.startLine as number;
const endLine = metadata.endLine as number;
const name = metadata.name as string;
Expand Down
Loading