gitee-ai-employee 1.2.6 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh/client.js +3 -7
- package/dsh/index.js +37 -6
- package/package.json +1 -1
package/dsh/client.js
CHANGED
|
@@ -359,16 +359,12 @@ window.__ModuleLoader__.load({
|
|
|
359
359
|
var accepted = 0
|
|
360
360
|
var skipped = 0
|
|
361
361
|
var tasks = repos.map(function (spec) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
var idx = rest.indexOf('/')
|
|
365
|
-
var owner = rest.slice(0, idx)
|
|
366
|
-
var repo = rest.slice(idx + 1)
|
|
367
|
-
if (!owner || !repo) return Promise.resolve({ accepted: false })
|
|
362
|
+
// 原始仓库行交给服务端统一解析(owner/repo、gitee:owner/repo、完整克隆地址均可)。
|
|
363
|
+
// 客户端不再自己 indexOf 切分——全路径 URL 会被切成 owner='https:' 导致克隆失败。
|
|
368
364
|
return fetch('/gitee-ai/scan', {
|
|
369
365
|
method: 'POST',
|
|
370
366
|
headers: { 'Content-Type': 'application/json' },
|
|
371
|
-
body: JSON.stringify({
|
|
367
|
+
body: JSON.stringify({ spec: spec, dryRun: false }),
|
|
372
368
|
}).then(function (r) { return r.json().catch(function () { return { accepted: false } }) })
|
|
373
369
|
.then(function (b) {
|
|
374
370
|
if (b && b.accepted) accepted++
|
package/dsh/index.js
CHANGED
|
@@ -25,6 +25,12 @@ import { join } from "node:path";
|
|
|
25
25
|
// 路径分隔符:Windows 用反斜杠,mac / linux 用正斜杠(保证跨平台路径正确)。
|
|
26
26
|
const PATH_SEP = (typeof process !== "undefined" && process.platform === "win32") ? "\\" : "/";
|
|
27
27
|
|
|
28
|
+
// 插件自身版本(读包内 package.json),用于启动日志 / 状态接口自报,
|
|
29
|
+
// 便于在运行日志里一眼确认当前加载的到底是不是最新版。
|
|
30
|
+
const PLUGIN_VERSION = (() => {
|
|
31
|
+
try { return JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version || "?"; } catch (e) { return "?"; }
|
|
32
|
+
})();
|
|
33
|
+
|
|
28
34
|
const DEFAULT_CONFIG = {
|
|
29
35
|
giteeToken: "",
|
|
30
36
|
githubToken: "",
|
|
@@ -171,7 +177,7 @@ export default {
|
|
|
171
177
|
let webServer = ctx.get("webServer");
|
|
172
178
|
const shell = ctx.shell;
|
|
173
179
|
const timer = ctx.timer;
|
|
174
|
-
console.log("[gitee-ai]
|
|
180
|
+
console.log("[gitee-ai] plugin v" + PLUGIN_VERSION + " loaded | " + ((typeof process !== "undefined" && process.platform) || "?") + " | node " + ((typeof process !== "undefined" && process.version) || "?"));
|
|
175
181
|
ensureWorkerPreset();
|
|
176
182
|
|
|
177
183
|
// ── 提示词归一化:兼容 {id:{name,prompt}} 与 [{id,name,prompt}] 两种形态 ──
|
|
@@ -522,6 +528,10 @@ export default {
|
|
|
522
528
|
const dir = repoDir(owner, repo);
|
|
523
529
|
// 跨平台检查是否已克隆:直接走文件系统,不依赖 PowerShell / shell 语法(mac / linux 亦可)
|
|
524
530
|
if (existsSync(dir + PATH_SEP + ".git")) {
|
|
531
|
+
// 复用旧克隆前,用「当前令牌」刷新 origin 地址。否则克隆时嵌入的旧令牌一旦失效,
|
|
532
|
+
// 后续 git push 会 401 失败(且曾被 sh() 静默吞掉 → PR 接口报“源分支不存在”)。
|
|
533
|
+
const fresh = await cloneUrlFor(platform, owner, repo);
|
|
534
|
+
await sh(`git -C ${shellQuote(dir)} remote set-url origin ${shellQuote(fresh)}`, { timeoutMs: 60000 }).catch(() => {});
|
|
525
535
|
await sh(`git -C ${shellQuote(dir)} fetch origin --prune --tags`, { timeoutMs: 300000 });
|
|
526
536
|
return dir;
|
|
527
537
|
}
|
|
@@ -1064,7 +1074,14 @@ export default {
|
|
|
1064
1074
|
}
|
|
1065
1075
|
|
|
1066
1076
|
update({ step: "push" });
|
|
1067
|
-
|
|
1077
|
+
// push 前再用当前令牌刷新 origin(克隆可能是旧令牌建的);并检查 push 退出码,
|
|
1078
|
+
// 失败立即抛明确错误,而不是静默继续导致 PR 接口报“源分支不存在”这类误导性 400。
|
|
1079
|
+
const freshPushUrl = await cloneUrlFor(p, owner, repo);
|
|
1080
|
+
await sh(`git -C ${shellQuote(dir)} remote set-url origin ${shellQuote(freshPushUrl)}`, { workdir: dir, timeoutMs: 60000 }).catch(() => {});
|
|
1081
|
+
const pushRes = await sh(`git -C ${shellQuote(dir)} push -u origin ${shellQuote(branchName)}`, { workdir: dir, timeoutMs: 300000 });
|
|
1082
|
+
if (pushRes && pushRes.exitCode !== 0) {
|
|
1083
|
+
throw new Error("git push failed (" + pushRes.exitCode + "): " + ((pushRes.stderr.text || pushRes.stdout.text || "").slice(0, 300)));
|
|
1084
|
+
}
|
|
1068
1085
|
|
|
1069
1086
|
update({ step: "pr" });
|
|
1070
1087
|
const prTitle = `[AI] ${(issue && issue.title) || ("Fix issue #" + number)} (#${number})`;
|
|
@@ -1662,7 +1679,7 @@ ${["critical", "high", "medium", "low", "none"].map((s) => `<option value="${s}"
|
|
|
1662
1679
|
}
|
|
1663
1680
|
|
|
1664
1681
|
// ── 扫描 API(固定路径,client 设置卡片调用)──
|
|
1665
|
-
// POST /gitee-ai/scan {platform?,owner,repo,dryRun?,force?,prompts?,customPrompt?}
|
|
1682
|
+
// POST /gitee-ai/scan {spec}(原始仓库行,统一解析)或 {platform?,owner,repo,dryRun?,force?,prompts?,customPrompt?}
|
|
1666
1683
|
// GET /gitee-ai/scan → 提示词清单 + 扫描任务 + 去重状态
|
|
1667
1684
|
let scanApiDisposer = null;
|
|
1668
1685
|
if (webServer) {
|
|
@@ -1680,9 +1697,22 @@ ${["critical", "high", "medium", "low", "none"].map((s) => `<option value="${s}"
|
|
|
1680
1697
|
if (ct.includes("application/json")) {
|
|
1681
1698
|
try { body = JSON.parse(raw || "{}"); } catch (e) { body = {}; }
|
|
1682
1699
|
} else if (raw) body = parseForm(raw);
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1700
|
+
let platform = normPlatform(body.platform || config.defaultPlatform);
|
|
1701
|
+
let owner = String(body.owner || "").trim();
|
|
1702
|
+
let repo = String(body.repo || "").trim();
|
|
1703
|
+
// 支持直接传原始仓库行(client「立即扫描全部仓库」就是传 spec 行):
|
|
1704
|
+
// 统一走 parseRepoSpec,兼容 owner/repo、gitee:/github: 前缀、完整克隆地址。
|
|
1705
|
+
// (不能在这里对 URL 用 indexOf('/') 切分——会把 https://… 切成 owner='https:')
|
|
1706
|
+
if (body.spec !== undefined && String(body.spec).trim()) {
|
|
1707
|
+
const parsed = parseRepoSpec(String(body.spec));
|
|
1708
|
+
if (!parsed) {
|
|
1709
|
+
send(res, 400, { ok: false, error: "无法解析仓库:" + String(body.spec) + "(支持 owner/repo、gitee:owner/repo、完整克隆地址)" });
|
|
1710
|
+
return;
|
|
1711
|
+
}
|
|
1712
|
+
platform = parsed.platform;
|
|
1713
|
+
owner = parsed.owner;
|
|
1714
|
+
repo = parsed.repo;
|
|
1715
|
+
}
|
|
1686
1716
|
if (!owner || !repo) { send(res, 400, { ok: false, error: "owner/repo required" }); return; }
|
|
1687
1717
|
const opts = {
|
|
1688
1718
|
dryRun: body.dryRun === true || body.dryRun === "true",
|
|
@@ -1856,6 +1886,7 @@ ${["critical", "high", "medium", "low", "none"].map((s) => `<option value="${s}"
|
|
|
1856
1886
|
workRoot: config.workRoot, autoMerge: config.autoMerge,
|
|
1857
1887
|
autoCloseIssue: !!config.autoCloseIssue, tokenConfigured: tokenOk(),
|
|
1858
1888
|
githubTokenConfigured: tokenOkFor("github"),
|
|
1889
|
+
version: PLUGIN_VERSION,
|
|
1859
1890
|
defaultPlatform: config.defaultPlatform || "gitee",
|
|
1860
1891
|
gitUser: config.gitUser || "", pollEnabled: !!config.pollEnabled,
|
|
1861
1892
|
pollIntervalMs: config.pollIntervalMs,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gitee-ai-employee",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Gitee/GitHub AI 员工:issue 里 @ 机器人自动开发并提 PR;v1.2 新增代码安全扫描——配置仓库地址后按内置/自定义提示词扫描漏洞,去重后提交 issue。An issue-driven AI developer for DeepSeek Harness (Gitee & GitHub) with optional static security scanning (dedup + issue reporting).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|