Skip to content

nesalia-inc/repofetch

repofetch

CLI tool that bridges GitHub source code with AI context.

A TypeScript monorepo providing a SDK and CLI for AI agents to analyze GitHub repositories without cloning them locally.

Packages

Package Version Description
@nesalia/repofetch-sdk 0.1.0 TypeScript SDK for GitHub API
@nesalia/repofetch 0.1.4 CLI tool

Installation

npm install -g @nesalia/repofetch

Quick Start

# Authenticate with GitHub
repofetch auth set YOUR_GITHUB_TOKEN

# List repository contents
repofetch ls owner/repo

# Read files
repofetch read owner/repo path/to/file.ts

# Search code
repofetch search "function name" -r owner/repo

# View tree structure
repofetch tree owner/repo --depth 3

# Create aliases for quick access
repofetch alias set myrepo owner/repo
repofetch tree myrepo --depth 2

CLI Commands

repofetch ls <repo> [path]

List directory contents.

repofetch read <repo> <path1> [path2] ...

Read file contents (supports multiple files).

repofetch search "<query>" -r <owner/repo> [options]

Search code in repository.

  • -e, --ext <ext> - Filter by file extension
  • --limit <n> - Limit results (default: 30)

repofetch tree <repo> [options]

Show repository tree structure.

  • --depth <n> - Maximum depth (default: 3)
  • --branch <name> - Target branch (default: main)

repofetch alias <command>

Manage repository aliases.

  • alias set <name> <repo> - Create alias
  • alias rm <name> - Remove alias
  • alias list - List all aliases

repofetch auth <command>

Manage authentication.

  • auth status - Check authentication status
  • auth set <token> - Store token securely (OS keychain)
  • auth logout - Remove stored token

SDK Usage

import { createClient } from '@nesalia/repofetch-sdk';

const client = await createClient({ token: process.env.GITHUB_TOKEN });

// List repository
const result = await client.repos.ls('owner/repo', 'src');
if (result.ok) {
  console.log(result.value.items);
}

// Search code
const search = await client.search.search('function', { repo: 'owner/repo' });

// Get tree structure
const tree = await client.tree.getTree('owner/repo', { depth: 3 });

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests (41 tests, 82%+ coverage)
pnpm test

# Lint
pnpm lint

# Type check
pnpm typecheck

Architecture

packages/
├── sdk/              # @nesalia/repofetch-sdk
│   ├── src/
│   │   ├── context.ts       # SDK configuration
│   │   ├── errors.ts        # Result type & error classes
│   │   ├── modules/
│   │   │   ├── repos.ts     # ls, read, getMetadata
│   │   │   ├── search.ts    # search
│   │   │   ├── tree.ts      # getTree
│   │   │   └── auth.ts      # getStatus
│   │   └── internal/
│   │       ├── fetch-transport.ts  # HTTP layer
│   │       ├── keychain.ts         # OS keychain integration
│   │       └── response-mapper.ts  # API response mapping
│   └── tests/             # 41 tests
└── repofetch/       # @nesalia/repofetch (CLI)
    └── src/
        └── cli.ts          # CLI commands

License

MIT

About

CLI tool that bridges GitHub source code with AI context

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors