Skip to content

Commit 32e66a2

Browse files
committed
docs: update usage
1 parent 954178e commit 32e66a2

File tree

4 files changed

+72
-9
lines changed

4 files changed

+72
-9
lines changed

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
Application code lives in `src/`, with `app.ts` wiring Express routes, Zod validation, and agent orchestration. Domain-specific agents sit in `src/agents/` (classification, scoring, weakness matching), while parser utilities are under `src/common/`. Shared HTTP middleware lives in `src/middleware/`, and user-facing templates are stored in `src/templates/` (copied into `dist/templates/` during builds). Jest specs such as `src/app.test.ts` keep tests close to the code under test, and the `test/` directory holds sample LaTeX and JSON fixtures for manual runs and regression data.
5+
6+
## Build, Test, and Development Commands
7+
Use `make dev` for a hot-reloading Docker dev stack (`api-dev` service). Run the prod stack with `make build && make up`, and tear it down with `make down`. Local Node workflows use npm scripts: `npm run start` boots the TypeScript server via ts-node, `npm run build` compiles to `dist/` and copies templates, `npm run serve` runs the compiled output, and `npm test` executes Jest suites (pair with `npm run test:coverage` for coverage details). `make test` wraps the Docker dev stack around the Jest command for parity with CI containers.
8+
9+
## Coding Style & Naming Conventions
10+
TypeScript targets ESNext with CommonJS modules; keep async flows await-based and prefer typed helpers over `any`. Follow the existing two-space indentation and trailing comma style found in `src/app.ts`. Classes and agents use PascalCase (`PaperScoreAgent`), helpers use camelCase, and schema constants stay in SCREAMING_SNAKE cases only when truly constant. Validate inputs with Zod schemas and centralize repeated parsing logic in `src/common/`. Run `npm run build` before committing to catch TypeScript type drift.
11+
12+
## Testing Guidelines
13+
Jest with ts-jest powers unit and request tests; new suites should live alongside the modules as `*.test.ts`. Keep test names descriptive ("should parse sections with anchors") and arrange Arrange-Act-Assert blocks clearly. Call `npm test` locally before pushing, and gate high-risk changes with `npm run test:coverage` (aim for no coverage regressions on parser and agent modules). Use `supertest` when exercising Express routes.
14+
15+
## Commit & Pull Request Guidelines
16+
Recent history uses concise, prefixed commits (`feat:`, `fix:`, `chore:`, `add:`); continue that format with imperative subject lines under ~72 chars. Each pull request should describe the change, note affected endpoints or agents, and link tracking issues. Include repro or test instructions (e.g., `npm test`, `make dev`) and screenshots or JSON samples when responses change.
17+
18+
## Security & Configuration Tips
19+
Never commit `.env` files or keys; set `MCP_BASIC_KEY` and `MCP_PAPERSCORE_KEY` in your shell or Docker `.env`. Confirm `templatesPath` resolves inside the container before exposing routes, and rotate API keys if logs (via `make logs`/`dev-logs`) ever show accidental dumps.

Makefile

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
# Docker 操作快捷命令
2-
31
.PHONY: build up down dev dev-down logs clean test
42

5-
# 生产环境
3+
# Production environment
64
build:
75
docker-compose build
86

@@ -15,7 +13,7 @@ down:
1513
logs:
1614
docker-compose logs -f api
1715

18-
# 开发环境
16+
# Development environment
1917
dev:
2018
docker-compose -f docker-compose.dev.yaml up --build
2119

@@ -25,28 +23,28 @@ dev-down:
2523
dev-logs:
2624
docker-compose -f docker-compose.dev.yaml logs -f api-dev
2725

28-
# 测试
26+
# Testing
2927
test:
3028
docker-compose -f docker-compose.dev.yaml up -d
3129
docker-compose -f docker-compose.dev.yaml exec api-dev npm test
3230
docker-compose -f docker-compose.dev.yaml down
3331

34-
# 清理
32+
# Cleaning
3533
clean:
3634
docker-compose down -v --rmi all
3735
docker-compose -f docker-compose.dev.yaml down -v --rmi all
3836

39-
# 重建
37+
# Rebuilding
4038
rebuild:
4139
docker-compose down
4240
docker-compose build --no-cache
4341
docker-compose up -d
4442

45-
# 查看状态
43+
# Checking status
4644
status:
4745
docker-compose ps
4846

49-
# 进入容器 shell
47+
# Enter container shell
5048
shell:
5149
docker-compose exec api sh
5250

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ make logs
2020
make clean
2121
```
2222

23+
## Usage Documentation
24+
25+
For a full walkthrough covering local setup, publishing to GitHub Container Registry, pulling the latest images, and the GitHub Actions pipeline, see [USAGE.md](./USAGE.md).
26+
2327
### Required environment variables for image
2428

2529
```bash

USAGE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Repository Usage Guide
2+
3+
## Getting Started
4+
1. Install dependencies: `npm install`.
5+
2. Copy `.env.example` to `.env` and set `MCP_BASIC_KEY`, `MCP_PAPERSCORE_KEY`, and any other secrets required by the agents.
6+
3. Run `npm run start` to boot the API via ts-node, or use `make dev` for the auto-rebuilding Docker dev stack (`api-dev` service). `make build && make up` builds and starts the production docker-compose stack locally.
7+
8+
## Local Testing and Builds
9+
- `npm test`: runs the Jest suites in `src/*.test.ts` and any request tests.
10+
- `npm run test:coverage`: produces a coverage report under `coverage/`.
11+
- `npm run build`: compiles TypeScript into `dist/` and copies `src/templates/`.
12+
- `npm run serve`: executes the compiled `dist/app.js` using Node.
13+
Use these commands locally before pushing to keep CI green.
14+
15+
## Publishing to GitHub Container Registry (GHCR)
16+
The repository publishes multi-architecture images to `ghcr.io/<owner>/paperdebugger-mcp-server` via the `Build and Push Docker Image` workflow (`.github/workflows/build.yaml`). When you push to `main` or open/update a pull request targeting `main`, GitHub Actions:
17+
1. Checks out the repo (with submodules) using `actions/checkout`.
18+
2. Sets up Buildx and authenticates to GHCR with `${{ secrets.GITHUB_TOKEN }}`.
19+
3. Generates tags for the branch, PR, and short SHA through `docker/metadata-action`.
20+
4. Builds `docker/Dockerfile` for `linux/amd64` and `linux/arm64` and pushes all tags to GHCR.
21+
Manual publishing is rarely needed, but you can mimic the pipeline locally: `docker build -t ghcr.io/<owner>/paperdebugger-mcp-server:dev -f docker/Dockerfile .` and then `docker push ghcr.io/<owner>/paperdebugger-mcp-server:dev` after `docker login ghcr.io` with a PAT scoped to packages.
22+
23+
## Pulling the Latest Image from GitHub
24+
To consume the newest container, pull the tag emitted by the workflow:
25+
```bash
26+
docker pull ghcr.io/<owner>/paperdebugger-mcp-server:main
27+
docker pull ghcr.io/<owner>/paperdebugger-mcp-server:main-<short_sha>
28+
```
29+
Tags `main`, `pr-<id>`, and `<branch>-<short_sha>` are updated during each run; production deployments typically use the `main` tag or a specific SHA tag for reproducibility.
30+
31+
## GitHub Actions Overview
32+
### Build and Push Docker Image
33+
- **Trigger:** push to `main` or PR targeting `main`.
34+
- **Inputs:** repository source, `${{ secrets.PERSONAL_ACCESS_TOKEN }}` for checkout, `${{ secrets.GITHUB_TOKEN }}` for GHCR login.
35+
- **Process:** checkout → Buildx setup → tag calculation → multi-arch build → push to GHCR (with caching via `type=gha`).
36+
- **Output:** versioned Docker images stored in GHCR plus workflow metadata (tags, labels).
37+
38+
### Test Coverage Workflow
39+
- **Trigger:** push or PR against `main` or `develop`.
40+
- **Inputs:** codebase, Node 20 runtime, secrets like `MCP_AUTO_TEST_KEY` for OpenAI calls.
41+
- **Process:** checkout → `npm ci``npm run test:coverage` → upload `coverage/` artifact → append summary → comment on PR (when applicable).
42+
- **Output:** stored coverage artifact, GitHub step summary, and a PR comment showing line/function/branch/statement coverage.

0 commit comments

Comments
 (0)