Compare commits

1 Commits

Author SHA1 Message Date
HIsheR 17a4fb171b iter: 新增 Gitea REST API 包装脚本 2026-10-23 15:27:02 +08:00
2 changed files with 19 additions and 2 deletions
-2
View File
@@ -16,8 +16,6 @@ qa/probe ──门禁通过──▶ qa/stable ──人工审阅──▶ main
## 每轮迭代流程(自动化 Agent 执行) ## 每轮迭代流程(自动化 Agent 执行)
> 所有远程推送一律使用认证包装脚本:`node scripts/gitea.mjs push <remote> <分支>`(令牌读自本地 `.gitea-token`,不入库;凭据管理器不可用)。
1. **同步**:`git fetch --all --prune`,切到 `qa/stable` 并 `git pull`;从其最新提交强制重建 `qa/probe` 并切换过去。 1. **同步**:`git fetch --all --prune`,切到 `qa/stable` 并 `git pull`;从其最新提交强制重建 `qa/probe` 并切换过去。
2. **选题**:读 `.ua/backlog.json`,取第一条 `status === "open"` 的条目;若全部关闭,按《选题规则》自行补充一条新点子后继续。 2. **选题**:读 `.ua/backlog.json`,取第一条 `status === "open"` 的条目;若全部关闭,按《选题规则》自行补充一条新点子后继续。
3. **实现**:按 `CODING.md` 编码规范实现,保持低侵入,单文件 < 200 行,涉及组件需同步 manifest/docs/llms-full.txt。 3. **实现**:按 `CODING.md` 编码规范实现,保持低侵入,单文件 < 200 行,涉及组件需同步 manifest/docs/llms-full.txt。
+19
View File
@@ -0,0 +1,19 @@
/*** 作用:Gitea REST API 调用包装器,用法 node scripts/gitea-api.mjs <METHOD> <path不带前导斜杠> [jsonBody],令牌读自 .gitea-token ***/
import { readFileSync } from 'node:fs';
// 仓库与令牌
const base = 'https://gitea.yinyuanjingling.icu/api/v1';
const token = readFileSync(new URL('../.gitea-token', import.meta.url), 'utf8').trim();
const [method = 'GET', path = '', body = ''] = process.argv.slice(2);
// 卫语句:缺参数退出
if (!method || !path) { console.error('用法: node scripts/gitea-api.mjs <METHOD> <path> [jsonBody]'); process.exit(2); }
// 发起请求并输出结果(path 不带前导斜杠,规避 Git Bash MSYS 路径转换篡改)
const res = await fetch(`${base}/${path.replace(/^\//, '')}`, {
method: method.toUpperCase(),
headers: { 'Authorization': `token ${token}`, 'Content-Type': 'application/json' },
body: body || undefined,
});
const text = await res.text();
console.log(`HTTP ${res.status}\n${text}`);
process.exit(res.ok ? 0 : 1);