Skip to content

Commit 6c55af8

Browse files
committed
chore: add github action
1 parent 1d93143 commit 6c55af8

File tree

9 files changed

+281
-48
lines changed

9 files changed

+281
-48
lines changed

.github/FUNDING.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# These are supported funding model platforms
2+
3+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: ericc_ch
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12+
polar: # Replace with a single Polar username
13+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
14+
thanks_dev: # Replace with a single thanks.dev username
15+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: oven-sh/setup-bun@v2
16+
with:
17+
bun-version: latest
18+
19+
- name: Install dependencies
20+
run: bun install
21+
22+
- name: Run linter
23+
run: bun run lint:all
24+
25+
- name: Run type check
26+
run: bun run typecheck
27+
28+
- name: Run tests
29+
run: bun test
30+
31+
- name: Build
32+
run: bun run build

.github/workflows/deploy-pages.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch:
7+
8+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
9+
permissions:
10+
contents: read
11+
pages: write
12+
id-token: write
13+
14+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
15+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: false
19+
20+
jobs:
21+
deploy:
22+
runs-on: ubuntu-latest
23+
environment:
24+
name: github-pages
25+
url: ${{ steps.deployment.outputs.page_url }}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Pages
31+
uses: actions/configure-pages@v4
32+
33+
- name: Upload artifact
34+
uses: actions/upload-pages-artifact@v3
35+
with:
36+
path: ./pages
37+
38+
- name: Deploy to GitHub Pages
39+
id: deployment
40+
uses: actions/deploy-pages@v4
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Docker Build and Push
2+
3+
# This workflow uses actions that are not certified by GitHub.
4+
# They are provided by a third-party and are governed by
5+
# separate terms of service, privacy policy, and support
6+
# documentation.
7+
8+
on:
9+
push:
10+
# branches: [ "main" ]
11+
# Publish semver tags as releases.
12+
tags: [ 'v*.*.*' ]
13+
paths-ignore:
14+
- 'docs/**'
15+
16+
env:
17+
# Use docker.io for Docker Hub if empty
18+
REGISTRY: ghcr.io
19+
# github.repository as <account>/<repo>
20+
#IMAGE_NAME: ${{ github.repository }}
21+
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: write
29+
# This is used to complete the identity challenge
30+
# with sigstore/fulcio when running outside of PRs.
31+
id-token: write
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
37+
- name: Set version
38+
id: version
39+
run: |
40+
mkdir -p handlers
41+
echo ${GITHUB_REF#refs/tags/v} > handlers/VERSION
42+
43+
# Install the cosign tool except on PR
44+
# https://github.com/sigstore/cosign-installer
45+
- name: Install cosign
46+
if: github.event_name != 'pull_request'
47+
uses: sigstore/cosign-installer@main
48+
- name: Set up QEMU
49+
uses: docker/setup-qemu-action@v2
50+
with:
51+
platforms: 'arm64,amd64'
52+
53+
# Workaround: https://github.com/docker/build-push-action/issues/461
54+
- name: Setup Docker buildx
55+
uses: docker/setup-buildx-action@v2
56+
57+
# Login against a Docker registry except on PR
58+
# https://github.com/docker/login-action
59+
- name: Log into registry ${{ env.REGISTRY }}
60+
if: github.event_name != 'pull_request'
61+
uses: docker/login-action@v2
62+
with:
63+
registry: ${{ env.REGISTRY }}
64+
username: ${{ github.actor }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
67+
# Extract metadata (tags, labels) for Docker
68+
# https://github.com/docker/metadata-action
69+
- name: Extract Docker metadata
70+
id: meta
71+
uses: docker/metadata-action@v4
72+
with:
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
images: ${{ env.REGISTRY }}/${{ github.repository }}
75+
tags: |
76+
type=semver,pattern=v{{version}}
77+
type=semver,pattern=v{{major}}.{{minor}}
78+
type=semver,pattern=v{{major}}
79+
80+
# Build and push Docker image with Buildx (don't push on PR)
81+
# https://github.com/docker/build-push-action
82+
- name: Build and push Docker image
83+
id: build-and-push
84+
uses: docker/build-push-action@v3
85+
with:
86+
context: .
87+
push: ${{ github.event_name != 'pull_request' }}
88+
tags: ${{ steps.meta.outputs.tags }}
89+
platforms: linux/amd64,linux/arm64
90+
labels: ${{ steps.meta.outputs.labels }}
91+

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
permissions:
4+
id-token: write
5+
contents: write
6+
7+
on:
8+
push:
9+
tags:
10+
- "v*"
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: oven-sh/setup-bun@v2
21+
with:
22+
bun-version: latest
23+
24+
- run: bunx changelogithub
25+
env:
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
27+
28+
- name: Publish to npm
29+
run: bun publish --access public
30+
env:
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 66 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,79 @@
11
# Copilot API Pro
22

3-
> [!NOTE]
4-
> This is a fork of [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api). The package/CLI name is **copilot-api-pro** (`npx copilot-api-pro@latest start`).
5-
> Highlights of this fork:
6-
> - Native OpenAI `/v1/responses` support (latest GPT models such as gpt-5.1-codex).
7-
> - Persisted Claude Code model selection, daemon start/stop commands, non-interactive startup.
8-
> - Improved error handling for Copilot responses and daemon management.
9-
> - bug fixes
10-
11-
> [!WARNING]
12-
> This is a reverse-engineered proxy of GitHub Copilot API. It is not supported by GitHub, and may break unexpectedly. Use at your own risk.
13-
14-
> [!WARNING]
15-
> **GitHub Security Notice:**
16-
> Excessive automated or scripted use of Copilot (including rapid or bulk requests, such as via automated tools) may trigger GitHub's abuse-detection systems.
17-
> You may receive a warning from GitHub Security, and further anomalous activity could result in temporary suspension of your Copilot access.
18-
>
19-
> GitHub prohibits use of their servers for excessive automated bulk activity or any activity that places undue burden on their infrastructure.
20-
>
21-
> Please review:
22-
>
23-
> - [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github)
24-
> - [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
25-
>
26-
> Use this proxy responsibly to avoid account restrictions.
27-
28-
CLI: `npx copilot-api-pro@latest start`
29-
30-
Quick start
31-
```sh
32-
npx copilot-api-pro@latest start # 前台
33-
npx copilot-api-pro@latest start --daemon # 后台
34-
npx copilot-api-pro@latest stop # 停止后台
35-
npx copilot-api-pro@latest start --claude-code # 生成 Claude Code 命令并保存模型
36-
npx copilot-api-pro@latest start --codex # 生成 Codex 命令 (responses)
37-
npx copilot-api-pro@latest check-usage # 查看用量
38-
```
3+
Fork of [ericc-ch/copilot-api](https://github.com/ericc-ch/copilot-api) that adds OpenAI `/v1/responses`, persistent Claude Code model selection, daemon-friendly start/stop, and tighter error handling. CLI name: `copilot-api-pro`.
4+
5+
> This is a reverse-engineered proxy of GitHub Copilot. It is unofficial and may break at any time.
6+
7+
## Highlights
8+
- OpenAI-compatible endpoints (including `/v1/responses` for GPT-4.1 / gpt-5.1-codex) and Anthropic-compatible `/v1/messages`.
9+
- One-shot Claude Code setup: select models once, persist them, and reuse with `--daemon`.
10+
- Codex CLI helper: generates `wire_api=responses` command for Codex.
11+
- Manual approval and rate-limit guard rails to reduce Copilot abuse flags.
12+
- Background daemon with `start --daemon` and `stop`.
13+
14+
## Requirements
15+
- Bun 1.0+ recommended.
16+
- A GitHub Copilot account (individual, business, or enterprise).
17+
- Files are stored under `~/.local/share/copilot-api` (tokens, Claude Code config, daemon pid).
3918

40-
Quick start
19+
## Quick start
4120
```sh
42-
# 前台 / 后台
21+
# Foreground / background
4322
npx copilot-api-pro@latest start
4423
npx copilot-api-pro@latest start --daemon
4524
npx copilot-api-pro@latest stop
4625

47-
# Claude Code(选择并保存模型,复制命令)
26+
# Claude Code (select & persist models, copy command)
4827
npx copilot-api-pro@latest start --claude-code
4928

50-
# Codex(生成 wire_api=responses 命令)
29+
# Reset Claude Code selection
30+
npx copilot-api-pro@latest start --claude-code --reset
31+
32+
# Codex (generate wire_api=responses command)
5133
npx copilot-api-pro@latest start --codex
5234

53-
# 查看用量
35+
# Show usage
5436
npx copilot-api-pro@latest check-usage
55-
```
37+
```
38+
39+
## Help
40+
`npx copilot-api-pro@latest --help` shows the command list (command name is `copilot-api-pro`):
41+
```
42+
USAGE copilot-api-pro auth|start|stop|check-usage|debug
43+
44+
COMMANDS
45+
auth Run GitHub auth flow without running the server
46+
start Start the Copilot API server
47+
stop Stop the background Copilot API server started with --daemon
48+
check-usage Show current GitHub Copilot usage/quota information
49+
debug Print debug information about the application
50+
```
51+
52+
## CLI
53+
- `start` – start the server. Common flags: `-p/--port` (default 4141), `-a/--account-type` (`individual|business|enterprise`), `--manual`, `-r/--rate-limit <sec>`, `--wait`, `-g/--github-token <token>`, `--proxy-env`, `--claude-code`, `--reset`, `--codex`, `--daemon`, `--show-token`, `-v/--verbose`.
54+
- `auth` – run GitHub auth flow only (writes token).
55+
- `stop` – stop the `--daemon` background process.
56+
- `check-usage` – print Copilot usage/quotas.
57+
- `debug` – print version/runtime/path info (`--json` available).
58+
59+
## API surface
60+
- OpenAI: `/v1/chat/completions`, `/v1/embeddings`, `/v1/models`, `/v1/responses`.
61+
- Anthropic: `/v1/messages`, `/v1/messages/count_tokens`.
62+
- Usage: `/usage`, token debug: `/token`.
63+
- Usage Viewer: `https://ericc-ch.github.io/copilot-api?endpoint=http://localhost:4141/usage`.
64+
65+
## Tips
66+
- Rate-limit safety: `--manual` or `--rate-limit 30 --wait` helps avoid abuse flags.
67+
- Proxy: `--proxy-env` reads `HTTP_PROXY` / `HTTPS_PROXY` env vars.
68+
- Reset Claude Code selection: `start --claude-code --reset`.
69+
70+
## Caveats & safety
71+
- This tool depends on unofficial Copilot endpoints; GitHub can change or block them at any time.
72+
- Heavy or automated use may trigger GitHub security/abuse protections; use at your own risk.
73+
- Please comply with:
74+
- [GitHub Acceptable Use Policies](https://docs.github.com/site-policy/acceptable-use-policies/github-acceptable-use-policies#4-spam-and-inauthentic-activity-on-github)
75+
- [GitHub Copilot Terms](https://docs.github.com/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot)
76+
77+
---
78+
79+
README structure inspired by [smart-suggestion](https://github.com/yetone/smart-suggestion).

dist/main.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { stop } from "./stop"
1010

1111
const main = defineCommand({
1212
meta: {
13-
name: "copilot-api",
13+
name: "copilot-api-pro",
1414
description:
1515
"A wrapper around GitHub Copilot API to make it OpenAI compatible, making it usable for other tools.",
1616
},

src/start.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export const start = defineCommand({
245245
description:
246246
"Generate a command to launch Claude Code with Copilot API config",
247247
},
248-
"claude-code-reset": {
248+
reset: {
249249
type: "boolean",
250250
default: false,
251251
description:
@@ -288,7 +288,7 @@ export const start = defineCommand({
288288
rateLimitWait: args.wait,
289289
githubToken: args["github-token"],
290290
claudeCode: args["claude-code"],
291-
claudeCodeReset: args["claude-code-reset"],
291+
claudeCodeReset: args.reset,
292292
codex: args.codex,
293293
showToken: args["show-token"],
294294
proxyEnv: args["proxy-env"],

0 commit comments

Comments
 (0)