ec1f6c96e7
- Dockerfile: 改用 node:20-slim - entrypoint.sh: 執行 app/main.js - app/package.json: axios + js-yaml + openai - app/config.js: 環境變數與 LLM 自動偵測(10 種服務) - app/llm.js: OpenAI-compatible 統一介面 - app/gitea.js: PR diff 取得與 comment 發布 - app/roles.js: 從 prompts/roles/*.yaml 載入角色 - app/main.js: pipeline 骨架,log 每個主要階段
16 lines
701 B
JavaScript
16 lines
701 B
JavaScript
import axios from 'axios';
|
|
import { GITEA_TOKEN, GITEA_SERVER_URL, GITEA_REPOSITORY, PR_NUMBER } from './config.js';
|
|
|
|
const headers = () => ({ Authorization: `token ${GITEA_TOKEN}`, 'Content-Type': 'application/json' });
|
|
const api = (path) => `${GITEA_SERVER_URL.replace(/\/$/, '')}/api/v1${path}`;
|
|
|
|
export async function getPRDiff() {
|
|
const resp = await axios.get(api(`/repos/${GITEA_REPOSITORY}/pulls/${PR_NUMBER}.diff`), { headers: headers(), timeout: 60000 });
|
|
return resp.data;
|
|
}
|
|
|
|
export async function postComment(body) {
|
|
const resp = await axios.post(api(`/repos/${GITEA_REPOSITORY}/issues/${PR_NUMBER}/comments`), { body }, { headers: headers(), timeout: 30000 });
|
|
return resp.data;
|
|
}
|