| layout | default |
|---|---|
| title | Chapter 4: Git Repository Source Imports |
| nav_order | 4 |
| parent | OpenSrc Tutorial |
Welcome to Chapter 4: Git Repository Source Imports. In this part of OpenSrc Tutorial: Deep Source Context for Coding Agents, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
OpenSrc can fetch direct git repositories when package metadata is not the right entry path.
github:owner/repoowner/repo(defaults to GitHub)owner/repo@tagorowner/repo#branchhttps://github.com/owner/repogitlab:owner/repoand other supported hosts
Repositories are organized under host/owner/repo path segments:
opensrc/
repos/
github.com/
vercel/
ai/
You now understand how OpenSrc imports repository source directly and normalizes storage paths.
Next: Chapter 5: AGENTS.md and sources.json Integration
The ResolvedPackage interface in src/types.ts handles a key part of this chapter's functionality:
}
export interface ResolvedPackage {
registry: Registry;
name: string;
version: string;
repoUrl: string;
repoDirectory?: string;
gitTag: string;
}
export interface FetchResult {
package: string;
version: string;
path: string;
success: boolean;
error?: string;
registry?: Registry;
}
export interface InstalledPackage {
name: string;
version: string;
}
/**
* Parsed repository specification
*/
export interface RepoSpec {
host: string; // e.g., "github.com", "gitlab.com"
owner: string;
repo: string;This interface is important because it defines how OpenSrc Tutorial: Deep Source Context for Coding Agents implements the patterns covered in this chapter.
The FetchResult interface in src/types.ts handles a key part of this chapter's functionality:
}
export interface FetchResult {
package: string;
version: string;
path: string;
success: boolean;
error?: string;
registry?: Registry;
}
export interface InstalledPackage {
name: string;
version: string;
}
/**
* Parsed repository specification
*/
export interface RepoSpec {
host: string; // e.g., "github.com", "gitlab.com"
owner: string;
repo: string;
ref?: string; // branch, tag, or commit
}
/**
* Type of input: package (with ecosystem) or git repo
*/
export type InputType = "package" | "repo";
/**This interface is important because it defines how OpenSrc Tutorial: Deep Source Context for Coding Agents implements the patterns covered in this chapter.
The InstalledPackage interface in src/types.ts handles a key part of this chapter's functionality:
}
export interface InstalledPackage {
name: string;
version: string;
}
/**
* Parsed repository specification
*/
export interface RepoSpec {
host: string; // e.g., "github.com", "gitlab.com"
owner: string;
repo: string;
ref?: string; // branch, tag, or commit
}
/**
* Type of input: package (with ecosystem) or git repo
*/
export type InputType = "package" | "repo";
/**
* Parsed package specification with registry
*/
export interface PackageSpec {
registry: Registry;
name: string;
version?: string;
}
/**This interface is important because it defines how OpenSrc Tutorial: Deep Source Context for Coding Agents implements the patterns covered in this chapter.
The RepoSpec interface in src/types.ts handles a key part of this chapter's functionality:
* Parsed repository specification
*/
export interface RepoSpec {
host: string; // e.g., "github.com", "gitlab.com"
owner: string;
repo: string;
ref?: string; // branch, tag, or commit
}
/**
* Type of input: package (with ecosystem) or git repo
*/
export type InputType = "package" | "repo";
/**
* Parsed package specification with registry
*/
export interface PackageSpec {
registry: Registry;
name: string;
version?: string;
}
/**
* Resolved repository information (for git repos)
*/
export interface ResolvedRepo {
host: string; // e.g., "github.com", "gitlab.com"
owner: string;
repo: string;
ref: string; // branch, tag, or commit (resolved)
repoUrl: string;This interface is important because it defines how OpenSrc Tutorial: Deep Source Context for Coding Agents implements the patterns covered in this chapter.
flowchart TD
A[ResolvedPackage]
B[FetchResult]
C[InstalledPackage]
D[RepoSpec]
E[PackageSpec]
A --> B
B --> C
C --> D
D --> E