|
1 | 1 | # repofetch |
2 | 2 |
|
3 | | -repofetch is a CLI tool that bridges GitHub source code with AI context. It enables AI assistants to better understand and work with repository code by providing structured, context-aware access to GitHub repositories. |
| 3 | +**CLI tool that bridges GitHub source code with AI context.** |
| 4 | + |
| 5 | +A TypeScript monorepo providing a SDK and CLI for AI agents to analyze GitHub repositories without cloning them locally. |
| 6 | + |
| 7 | +## Packages |
| 8 | + |
| 9 | +| Package | Version | Description | |
| 10 | +|---------|---------|-------------| |
| 11 | +| `@nesalia/repofetch-sdk` | `0.1.0` | TypeScript SDK for GitHub API | |
| 12 | +| `@nesalia/repofetch` | `0.1.4` | CLI tool | |
4 | 13 |
|
5 | 14 | ## Installation |
6 | 15 |
|
7 | 16 | ```bash |
8 | | -npm install -g repofetch |
| 17 | +npm install -g @nesalia/repofetch |
9 | 18 | ``` |
10 | 19 |
|
11 | 20 | ## Quick Start |
12 | 21 |
|
13 | | -### Authentication |
| 22 | +```bash |
| 23 | +# Authenticate with GitHub |
| 24 | +repofetch auth set YOUR_GITHUB_TOKEN |
| 25 | + |
| 26 | +# List repository contents |
| 27 | +repofetch ls owner/repo |
| 28 | + |
| 29 | +# Read files |
| 30 | +repofetch read owner/repo path/to/file.ts |
14 | 31 |
|
15 | | -Before using repofetch, authenticate with your GitHub account: |
| 32 | +# Search code |
| 33 | +repofetch search "function name" -r owner/repo |
16 | 34 |
|
17 | | -```bash |
18 | | -repofetch auth login |
| 35 | +# View tree structure |
| 36 | +repofetch tree owner/repo --depth 3 |
| 37 | + |
| 38 | +# Create aliases for quick access |
| 39 | +repofetch alias set myrepo owner/repo |
| 40 | +repofetch tree myrepo --depth 2 |
19 | 41 | ``` |
20 | 42 |
|
21 | | -### Browse Repositories |
| 43 | +## CLI Commands |
22 | 44 |
|
23 | | -List and explore repositories: |
| 45 | +### `repofetch ls <repo> [path]` |
| 46 | +List directory contents. |
24 | 47 |
|
25 | | -```bash |
26 | | -repofetch ls owner/repo |
| 48 | +### `repofetch read <repo> <path1> [path2] ...` |
| 49 | +Read file contents (supports multiple files). |
| 50 | + |
| 51 | +### `repofetch search "<query>" -r <owner/repo> [options]` |
| 52 | +Search code in repository. |
| 53 | +- `-e, --ext <ext>` - Filter by file extension |
| 54 | +- `--limit <n>` - Limit results (default: 30) |
| 55 | + |
| 56 | +### `repofetch tree <repo> [options]` |
| 57 | +Show repository tree structure. |
| 58 | +- `--depth <n>` - Maximum depth (default: 3) |
| 59 | +- `--branch <name>` - Target branch (default: main) |
| 60 | + |
| 61 | +### `repofetch alias <command>` |
| 62 | +Manage repository aliases. |
| 63 | +- `alias set <name> <repo>` - Create alias |
| 64 | +- `alias rm <name>` - Remove alias |
| 65 | +- `alias list` - List all aliases |
| 66 | + |
| 67 | +### `repofetch auth <command>` |
| 68 | +Manage authentication. |
| 69 | +- `auth status` - Check authentication status |
| 70 | +- `auth set <token>` - Store token securely (OS keychain) |
| 71 | +- `auth logout` - Remove stored token |
| 72 | + |
| 73 | +## SDK Usage |
| 74 | + |
| 75 | +```typescript |
| 76 | +import { createClient } from '@nesalia/repofetch-sdk'; |
| 77 | + |
| 78 | +const client = await createClient({ token: process.env.GITHUB_TOKEN }); |
| 79 | + |
| 80 | +// List repository |
| 81 | +const result = await client.repos.ls('owner/repo', 'src'); |
| 82 | +if (result.ok) { |
| 83 | + console.log(result.value.items); |
| 84 | +} |
| 85 | + |
| 86 | +// Search code |
| 87 | +const search = await client.search.search('function', { repo: 'owner/repo' }); |
| 88 | + |
| 89 | +// Get tree structure |
| 90 | +const tree = await client.tree.getTree('owner/repo', { depth: 3 }); |
27 | 91 | ``` |
28 | 92 |
|
29 | | -Replace `owner/repo` with the GitHub repository path (e.g., `facebook/react`). |
| 93 | +## Development |
| 94 | + |
| 95 | +```bash |
| 96 | +# Install dependencies |
| 97 | +pnpm install |
30 | 98 |
|
31 | | -## Documentation |
| 99 | +# Build all packages |
| 100 | +pnpm build |
32 | 101 |
|
33 | | -For full documentation, including advanced usage, configuration options, and API reference, see [docs/PROJECT.md](./docs/PROJECT.md). |
| 102 | +# Run tests (41 tests, 82%+ coverage) |
| 103 | +pnpm test |
| 104 | + |
| 105 | +# Lint |
| 106 | +pnpm lint |
| 107 | + |
| 108 | +# Type check |
| 109 | +pnpm typecheck |
| 110 | +``` |
| 111 | + |
| 112 | +## Architecture |
| 113 | + |
| 114 | +``` |
| 115 | +packages/ |
| 116 | +├── sdk/ # @nesalia/repofetch-sdk |
| 117 | +│ ├── src/ |
| 118 | +│ │ ├── context.ts # SDK configuration |
| 119 | +│ │ ├── errors.ts # Result type & error classes |
| 120 | +│ │ ├── modules/ |
| 121 | +│ │ │ ├── repos.ts # ls, read, getMetadata |
| 122 | +│ │ │ ├── search.ts # search |
| 123 | +│ │ │ ├── tree.ts # getTree |
| 124 | +│ │ │ └── auth.ts # getStatus |
| 125 | +│ │ └── internal/ |
| 126 | +│ │ ├── fetch-transport.ts # HTTP layer |
| 127 | +│ │ ├── keychain.ts # OS keychain integration |
| 128 | +│ │ └── response-mapper.ts # API response mapping |
| 129 | +│ └── tests/ # 41 tests |
| 130 | +└── repofetch/ # @nesalia/repofetch (CLI) |
| 131 | + └── src/ |
| 132 | + └── cli.ts # CLI commands |
| 133 | +``` |
34 | 134 |
|
35 | 135 | ## License |
36 | 136 |
|
37 | | -This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details. |
| 137 | +MIT |
0 commit comments