Quick Start
The GitHub provider works without configuration. Pass the repository as the first argument:Configuration
Named instances are optional but useful for repositories you access frequently or that require authentication:colin.toml
| Field | Required | Description |
|---|---|---|
name | Yes | Provider instance name for template access |
repo | Yes | Repository in owner/repo format |
token | No | GitHub token for private repos and higher rate limits |
colin.github.{name} in templates.
Multiple Repositories
Configure multiple repositories as separate provider instances:colin.toml
Authentication
Without a token, requests are subject to GitHub’s anonymous rate limit (60 requests per hour). With a token, the limit increases to 5,000 requests per hour. For private repositories, a token with appropriate permissions is required.Template Functions
| Function | Purpose |
|---|---|
file() | Fetch a file’s content |
ls() | List directory contents |
issue() | Fetch a single issue |
pr() | Fetch a single pull request |
issues() | List issues with filters |
prs() | List pull requests with filters |
file()
Fetch a file from a repository. Without configuration, pass the repo as the first argument:| Argument | Required | Default | Description |
|---|---|---|---|
repo | Yes | — | Repository in owner/repo format |
path | Yes | — | File path in the repository |
ref | No | "HEAD" | Git ref (branch, tag, or commit SHA) |
watch | No | True | Track for staleness detection |
| Argument | Required | Default | Description |
|---|---|---|---|
path | Yes | — | File path in the repository |
ref | No | "HEAD" | Git ref (branch, tag, or commit SHA) |
watch | No | True | Track for staleness detection |
GitHubFileResource with the file content.
ls()
List directory contents. Without configuration, pass the repo as the first argument:| Argument | Required | Default | Description |
|---|---|---|---|
repo | Yes | — | Repository in owner/repo format |
path | No | "" | Directory path (empty for root) |
ref | No | "HEAD" | Git ref (branch, tag, or commit SHA) |
watch | No | True | Track for staleness detection |
| Argument | Required | Default | Description |
|---|---|---|---|
path | No | "" | Directory path (empty for root) |
ref | No | "HEAD" | Git ref (branch, tag, or commit SHA) |
watch | No | True | Track for staleness detection |
GitHubListingResource that can be iterated to get entries.
issue()
Fetch a single issue by number or URL:| Argument | Required | Default | Description |
|---|---|---|---|
number_or_url | Yes | — | Issue number or full GitHub URL |
repo | No | — | Repository in owner/repo format (required if using number without configured repo) |
watch | No | True | Track for staleness detection |
GitHubIssueResource with the issue content and metadata.
pr()
Fetch a single pull request by number or URL:| Argument | Required | Default | Description |
|---|---|---|---|
number_or_url | Yes | — | PR number or full GitHub URL |
repo | No | — | Repository in owner/repo format (required if using number without configured repo) |
watch | No | True | Track for staleness detection |
GitHubPRResource with the PR content and metadata.
issues()
List issues with optional filters:| Argument | Required | Default | Description |
|---|---|---|---|
repo | No | — | Repository in owner/repo format (uses configured repo if None) |
state | No | "open" | Filter by state: "open", "closed", or "all" |
labels | No | None | Filter by label names |
assignee | No | None | Filter by assignee username |
limit | No | 30 | Maximum number of issues |
watch | No | True | Track for staleness detection |
GitHubIssuesResource that can be iterated.
prs()
List pull requests with optional filters:| Argument | Required | Default | Description |
|---|---|---|---|
repo | No | — | Repository in owner/repo format (uses configured repo if None) |
state | No | "open" | Filter by state: "open", "closed", or "all" |
base | No | None | Filter by base branch |
head | No | None | Filter by head branch |
limit | No | 30 | Maximum number of PRs |
watch | No | True | Track for staleness detection |
GitHubPRsResource that can be iterated.
Objects
GitHubFileResource
Returned byfile():
| Property | Type | Description |
|---|---|---|
content | str | File content |
path | str | File path in the repository |
repo | str | Repository in owner/repo format |
git_ref | str | Original git ref |
resolved_sha | str | Resolved commit SHA |
GitHubListingResource
Returned byls():
| Property | Type | Description |
|---|---|---|
content | str | Newline-separated list of paths |
entries | list[GitHubEntry] | Directory entries |
path | str | Directory path |
tree_sha | str | Tree SHA for versioning |
GitHubEntry
Each entry in a directory listing:| Property | Type | Description |
|---|---|---|
path | str | Full path from repository root |
name | str | Filename only |
type | str | "file" or "dir" |
sha | str | Blob or tree SHA |
size | int | None | File size in bytes (None for directories) |
GitHubIssueResource
Returned byissue():
| Property | Type | Description |
|---|---|---|
content | str | Issue title and body as markdown |
repo | str | Repository in owner/repo format |
number | int | Issue number |
title | str | Issue title |
body | str | None | Issue body (markdown) |
state | str | "open" or "closed" |
labels | list[str] | Label names |
assignees | list[str] | Assignee usernames |
author | str | None | Username of creator |
url | str | HTML URL to issue |
updated_at | datetime | Last update time |
created_at | datetime | Creation time |
closed_at | datetime | None | When closed (None if open) |
comments_count | int | Number of comments |
GitHubPRResource
Returned bypr():
| Property | Type | Description |
|---|---|---|
content | str | PR title and body as markdown |
repo | str | Repository in owner/repo format |
number | int | PR number |
title | str | PR title |
body | str | None | PR body (markdown) |
state | str | "open", "closed", or "merged" |
labels | list[str] | Label names |
assignees | list[str] | Assignee usernames |
author | str | None | Username of creator |
url | str | HTML URL to PR |
head_ref | str | Source branch name |
base_ref | str | Target branch name |
head_sha | str | Current head commit SHA |
is_draft | bool | Whether PR is a draft |
updated_at | datetime | Last update time |
created_at | datetime | Creation time |
closed_at | datetime | None | When closed |
merged_at | datetime | None | When merged |
additions | int | Lines added |
deletions | int | Lines deleted |
changed_files | int | Files changed |
GitHubIssuesResource
Returned byissues():
| Property | Type | Description |
|---|---|---|
content | str | Newline-separated issue summaries |
issues | list[GitHubIssueResource] | List of issue resources |
len():
GitHubPRsResource
Returned byprs():
| Property | Type | Description |
|---|---|---|
content | str | Newline-separated PR summaries |
prs | list[GitHubPRResource] | List of PR resources |
len():
Dependency Tracking
By default, all methods automatically track dependencies (watch=True). Documents recompile when tracked resources change:
updated_at timestamp. Any edit to the issue (title, body, labels, comments, etc.) triggers recompilation.
Collections like issues() and prs() track all items collectively:
Staleness Detection
The GitHub provider uses different versioning strategies for different resource types: Files and directories resolve git refs to commit SHAs:| Ref Type | Behavior |
|---|---|
Branch (main) | Resolves to tip SHA; recompiles when branch advances |
Tag (v1.0) | Resolves to tagged commit SHA; stable unless tag is moved |
SHA (abc123) | Immutable; never triggers recompilation |
updated_at timestamp. Any modification (edits, comments, label changes, state changes) triggers recompilation.
Collections (issues(), prs()) compute a hash of all item numbers and their update times. Changes to any item in the list, or items entering/leaving the list, trigger recompilation.
Error Handling
| Status | Exception | Description |
|---|---|---|
| 404 | FileNotFoundError | Ref, path, or file not found |
| 401 | PermissionError | Authentication required (private repo) |
| 403 | PermissionError | Rate limited or access denied |
Examples
Include External Documentation
Pull documentation from another repository:models/external-docs.md
Generate Index from Directory
Create an index of example files:models/examples-index.md
Pin to a Specific Version
Reference files from a tagged release:models/v3-config.md
Track an Issue
Create a document that updates when an issue changes:models/tracked-issue.md
Bug Dashboard
Generate a dashboard of open bugs:models/bug-dashboard.md
PR Status Report
Track open PRs and their review status:models/pr-status.md