@unifan/pi-unifan-zh 1.0.29 → 1.0.31

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/AGENTS.md CHANGED
@@ -18,8 +18,8 @@ pi-unifan-zh/
18
18
  │ │ ├── index.ts # 双栏实时预览 TUI 交互逻辑
19
19
  │ │ ├── sessions.ts # 会话解析、时间格式化与搜索过滤
20
20
  │ │ └── package.json
21
- │ ├── review/ # ② 代码审查全能扩展 (/review, /review-lite, /review-perf, /review-full)
22
- │ │ ├── index.ts # 斜杠命令注册与自动补全
21
+ │ ├── review/ # ② 代码审查全能扩展 (/review, /review-lite, /review-full, /review-reset, /review-sync)
22
+ │ │ ├── index.ts # 单文件轻量会话分支隔离与审查编排引擎
23
23
  │ │ ├── agents/ # 独立子代理提示词 (UTF-8 无 BOM)
24
24
  │ │ │ ├── bugbot.md # 逻辑缺陷专家
25
25
  │ │ │ ├── security-review.md # 安全隐患专家
@@ -29,11 +29,6 @@ pi-unifan-zh/
29
29
  │ │ │ ├── claude-md-compliance.md # 规范合规专家
30
30
  │ │ │ ├── history-context.md # 历史上下文专家
31
31
  │ │ │ └── code-comments.md # 注释检查专家
32
- │ │ ├── src/
33
- │ │ │ ├── directive.ts # 工作流脚本生成 (带自动重试与容错)
34
- │ │ │ ├── review-run.ts # 运行编排与路由分发
35
- │ │ │ ├── report.ts # 报告拼装与 Markdown 渲染
36
- │ │ │ └── config.ts # 默认配置 (门禁模型继承 inherit)
37
32
  │ │ └── package.json # 独立子包: @unifan/pi-review-zh
38
33
  │ └── commit/ # ③ 智能 Git 提交助手 (/commit, /commit-push)
39
34
  │ ├── index.ts # 一键提交与推流命令
@@ -87,9 +82,8 @@ pi-unifan-zh/
87
82
  * **网络抖动重试**:`runs.all` 并发调用必须包裹 `try-catch` 并在发生网络断连时自动延迟 800ms 重试一次。
88
83
  * **门禁熔断保护**:门禁裁判长(Gate)发生异常时必须兜底捕获,**绝对不能抛出未捕获异常导致已完成的 Reviewer 成果丢失**。
89
84
 
90
- ### 6. Git 冲突解决铁律(严禁直接使用 ours/theirs)
91
- * 拉取更新或变基(`git pull --rebase`)发生代码冲突时,**绝对严禁直接使用 `--ours` 或 `--theirs` 无脑覆盖**(严禁粗暴丢失任何一方代码)。
92
- * **必须仔细对比两方的 diff 修改与完整代码上下文**,逐行融合双方意图与逻辑,确保既不丢失远端的最新改动,又完整保留本地提交的修复与功能。
85
+ ### 6. 冲突解决原则
86
+ 拉取或变基冲突时,严禁直接使用 ours/theirs 覆盖,必须根据双方修改对比与上下文解决冲突。
93
87
 
94
88
  ---
95
89
 
package/README.md CHANGED
@@ -128,7 +128,7 @@ pi install npm:@unifan/pi-commit-zh
128
128
  - **Strict ASCII Punctuation**: Parentheses `()` and colon `: ` strictly use ASCII half-width characters for CI / Commitlint compliance.
129
129
  - **No Emoji**: Clean, professional plain text commit style.
130
130
  - **Smart Auto-Rebase on Push**: In `/commit-push`, if remote contains unpulled commits, it automatically runs `git pull --rebase` and retries push, keeping a clean linear git history.
131
- - **Smart Conflict Resolution Guidance**: If rebase encounters conflicts, lists conflicting files and explicitly enforces: **never blindly use `--ours` or `--theirs`; always resolve line-by-line based on diff and context**.
131
+ - **Smart Conflict Guidance**: If rebase conflicts occur, lists conflict files and enforces resolving by diff and context (never blindly using ours/theirs).
132
132
  - **Unpushed Commits Sync**: Automatically pushes unpushed local commits even if the working tree is clean.
133
133
 
134
134
  ---
package/README_zh.md CHANGED
@@ -133,7 +133,7 @@ pi install npm:@unifan/pi-commit-zh
133
133
  - **严格半角英文标点**:括号 `()` 与冒号空格 `: ` 严格使用英文半角字符,确保 CI / Commitlint 正则解析合规。
134
134
  - **严禁 Emoji**:保持严谨、专业的纯文本工程风格。
135
135
  - **智能自动变基(Auto Rebase)**:在 `/commit-push` 时,若远端有别人先提交的代码被拒绝,**自动在后台执行 `git pull --rebase` 变基并自动重试推送**,Git 历史保持一条干净直线!
136
- - **智能冲突比对引导(严禁无脑覆盖)**:变基拉取若遇代码冲突,自动列出冲突文件清单并**明确指示:绝对严禁直接使用 `--ours` 或 `--theirs` 粗暴覆盖,必须根据对比修改和代码上下文逐行解决冲突**,并给出清晰的操作步骤!
136
+ - **智能冲突引导**:变基遇冲突时列出冲突文件,提示严禁直接用 ours/theirs 覆盖,需按修改对比与上下文解决。
137
137
  - **未推送提交自动同步**:即使当前工作区干净,若检测到本地有尚未 push 的历史 Commit,`/commit-push` 也会自动将其推送至远端!
138
138
 
139
139
  ---
@@ -60,30 +60,34 @@ async function generateCommitMessage(
60
60
  const provider = ctx.modelRegistry.getProvider(ctx.model.provider);
61
61
  if (provider) {
62
62
  const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model);
63
- const response = await provider
64
- .streamSimple(
65
- ctx.model,
66
- {
67
- systemPrompt: COMMIT_SYSTEM_PROMPT,
68
- messages: [
69
- {
70
- role: "user",
71
- content: [{ type: "text", text: userPrompt }],
72
- timestamp: Date.now(),
73
- },
74
- ],
75
- },
76
- { apiKey: auth?.apiKey, headers: auth?.headers, maxTokens: 800 },
77
- )
78
- .result();
79
-
80
- const text = response.content
81
- ?.map((c) => (c.type === "text" ? c.text : ""))
82
- .join("")
83
- .trim();
84
-
85
- if (text) {
86
- return text.replace(/^```[a-zA-Z]*\n?/, "").replace(/\n?```$/, "").trim();
63
+ if (!auth.ok) {
64
+ console.error("pi-commit getApiKeyAndHeaders error:", auth.error);
65
+ } else {
66
+ const response = await provider
67
+ .streamSimple(
68
+ ctx.model,
69
+ {
70
+ systemPrompt: COMMIT_SYSTEM_PROMPT,
71
+ messages: [
72
+ {
73
+ role: "user",
74
+ content: [{ type: "text", text: userPrompt }],
75
+ timestamp: Date.now(),
76
+ },
77
+ ],
78
+ },
79
+ { apiKey: auth.apiKey, headers: auth.headers, maxTokens: 800 },
80
+ )
81
+ .result();
82
+
83
+ const text = response.content
84
+ ?.map((c) => (c.type === "text" ? c.text : ""))
85
+ .join("")
86
+ .trim();
87
+
88
+ if (text) {
89
+ return text.replace(/^```[a-zA-Z]*\n?/, "").replace(/\n?```$/, "").trim();
90
+ }
87
91
  }
88
92
  }
89
93
  } catch (err) {
@@ -132,7 +136,7 @@ export default function (pi: ExtensionAPI) {
132
136
  });
133
137
  } else {
134
138
  if (pushRes.hasConflict) {
135
- notify("⚠️ 远端拉取变基产生代码冲突!请对比修改和上下文解决冲突,严禁直接使用 ours/theirs。", "warning");
139
+ notify("⚠️ 远端变基冲突:请对比修改与上下文解决冲突,严禁直接使用 ours/theirs。", "warning");
136
140
  } else {
137
141
  notify(`⚠️ 推送失败: ${pushRes.output}`, "error");
138
142
  }
@@ -182,7 +186,7 @@ export default function (pi: ExtensionAPI) {
182
186
  pushText = `\n\n${successMsg}`;
183
187
  } else {
184
188
  if (pushRes.hasConflict) {
185
- notify("⚠️ 远端拉取变基产生代码冲突!请对比修改和上下文解决冲突,严禁直接使用 ours/theirs。", "warning");
189
+ notify("⚠️ 远端变基冲突:请对比修改与上下文解决冲突,严禁直接使用 ours/theirs。", "warning");
186
190
  } else {
187
191
  notify(`⚠️ 推送失败: ${pushRes.output}`, "error");
188
192
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifan/pi-commit-zh",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Pi 智能 Git 提交助手(规范化 Conventional Commits 纯中文版,支持一键提审与推流)",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -129,23 +129,12 @@ export async function pushCurrentBranch(
129
129
  }
130
130
 
131
131
  const filesListText = conflictFiles.length > 0
132
- ? `\n\n📌 **发生冲突的文件 (${conflictFiles.length} 个)**:\n${conflictFiles.map((f) => `- \`${f}\``).join("\n")}`
133
- : "";
134
-
135
- const conflictOutput = `⚠️ **远端有新提交,拉取变基 (git pull --rebase) 时与本地提交产生代码冲突!**${filesListText}
136
-
137
- 🚨 **【代码冲突解决核心铁律(重中之重)】**:
138
- 1. **严禁直接无脑使用 \`--theirs\` 或 \`--ours\`**:绝对不要盲目使用其中一方覆盖另一方,否则极易覆盖远端同事的代码或丢失本地修复!
139
- 2. **必须根据对比修改和上下文解决冲突**:
140
- - 逐个打开冲突文件,对照 \`<<<<<<< HEAD\`(远端基线)与 \`>>>>>>>\`(本地提交)的具体改动;
141
- - 结合周围类、函数、接口调用与业务上下文,理解两边的意图后逐行融合成正确的最终代码。
142
-
143
- 🛠️ **解决冲突操作步骤**:
144
- 1. 对比并手工/智能修改上述冲突文件,消除所有冲突标记;
145
- 2. 执行 \`git add <已解决文件>\` 标记冲突已解决;
146
- 3. 执行 \`git rebase --continue\` 完成变基;
147
- 4. 变基成功后重新执行 \`/commit-push\` 推送至远端;
148
- (若需放弃本次变基恢复原状,可执行 \`git rebase --abort\`)。\n\n底层详细输出:\n${rebaseErr}`;
132
+ ? `\n${conflictFiles.map((f) => `- \`${f}\``).join("\n")}\n`
133
+ : "\n";
134
+
135
+ const conflictOutput = `⚠️ **远端变基拉取存在代码冲突**:${filesListText}
136
+ - **解决原则**:严禁直接使用 theirs 或 ours 覆盖,必须根据双方修改对比与代码上下文解决冲突。
137
+ - **后续步骤**:解决冲突 ➔ \`git add <文件>\` ➔ \`git rebase --continue\` ➔ 再次执行 \`/commit-push\`(放弃可 \`git rebase --abort\`)。\n\nGit 输出:\n${rebaseErr}`;
149
138
 
150
139
  return {
151
140
  ok: false,
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: bugbot
3
3
  package: pi-review
4
- description: 逻辑 Bug 审查专家:扫描新引入代码中的逻辑漏洞、空指针与边界异常(高信噪比)。
4
+ description: 逻辑 Bug 审查专家:扫描新引入代码中的逻辑缺陷、空指针与边界异常(高信噪比)。
5
5
  tools: read, grep, bash
6
6
  systemPromptMode: replace
7
7
  inheritProjectContext: false
@@ -20,6 +20,7 @@ inheritSkills: false
20
20
  - 仅关注严重的、可能在真实运行中发生的真实 Bug(如空指针、竞态条件、死锁、逻辑死循环、越界)。
21
21
  - 忽略代码格式风格、缺失单测或简单的 Linter 警告。
22
22
  - 每个问题必须尽可能定位到具体的改动行(`+` 行)。
23
+ - 明确豁免:游戏或客户端工程中合法的 GM、Debug 调试指令及内部开发辅助逻辑属于受信任代码,在确认通过编译宏/环境判断隔离于正式发布包的前提下,切勿误判为 Bug;但若正式生产包可被外部触达仍属严重缺陷。
23
24
 
24
25
  ## 严重级别分类
25
26
  - `blocker`(致命阻断)— 崩溃、数据损坏或严重逻辑破坏
@@ -2,7 +2,7 @@
2
2
  name: claude-md-compliance
3
3
  package: pi-review
4
4
  description: 项目规范守卫:审查代码是否符合 AGENTS.md / 项目规则规范。
5
- tools: read, grep
5
+ tools: read, grep, bash
6
6
  systemPromptMode: replace
7
7
  inheritProjectContext: false
8
8
  inheritSkills: false
@@ -2,7 +2,7 @@
2
2
  name: code-comments
3
3
  package: pi-review
4
4
  description: 注释与规范审查官:审查代码注释的准确性、未完成的 TODO 与废弃代码。
5
- tools: read, grep
5
+ tools: read, grep, bash
6
6
  systemPromptMode: replace
7
7
  inheritProjectContext: false
8
8
  inheritSkills: false
@@ -18,11 +18,12 @@ inheritSkills: false
18
18
  - 2–3: 无法核验 / 纯主观风格偏好且无明确规范依据
19
19
  - 5: 真实但属于极其罕见或轻微的问题
20
20
  - 8: 核验属实的重要问题(或明确违反了项目规则)
21
- - 10: 证据确凿且经过你亲自核验的致命漏洞
21
+ - 10: 证据确凿且经过你亲自核验的致命缺陷
22
22
 
23
23
  ## 仲裁与核验职责
24
24
  - 合并不同专家提出的重复问题(相同文件/行号/分类),保留最高评分。
25
25
  - 排除低置信度(<8)的无意义假警报。
26
+ - 严格过滤内部 GM/调试(Debug)指令误报:在确认其通过编译开关或运行环境隔离于正式发布包的前提下,严禁判为缺陷;但若在正式发布包中外部可直接访问,仍属严重缺陷。
26
27
 
27
28
  ## 裁决规则
28
29
  - `request_changes`(需要修改)— 存在任何存活的致命(blocker)或严重(major)问题
@@ -44,7 +45,7 @@ inheritSkills: false
44
45
  {
45
46
  "status": "ok",
46
47
  "verdict": "approve",
47
- "reason": "代码结构良好,未发现高危逻辑与安全漏洞。",
48
+ "reason": "代码结构良好,未发现高危逻辑缺陷与安全隐患。",
48
49
  "issues": [
49
50
  { "file": "src/x.ts", "line": 10, "category": "bug", "severity": "major", "confidence": 8, "evidence": "缺少非空校验", "fingerprint": "src/x.ts:10:bug:a1b2c3" }
50
51
  ],
@@ -17,7 +17,7 @@ inheritSkills: false
17
17
  3. **必须在第 2~3 轮内输出最终 Markdown 中文报告并立即停止**!严禁进行漫游探索!
18
18
 
19
19
  ## 重点关注
20
- 逻辑致命缺陷与安全隐患第一,明确的规范冲突第二。不提废话风格建议。
20
+ 逻辑致命缺陷与防御性隐患第一,明确的规范冲突第二。不提废话风格建议。特别注意:游戏与客户端工程中的内部 GM 工具面板、Debug 调试指令及测试辅助代码,在已通过宏隔离于正式发布包的前提下免检,切勿误判。
21
21
 
22
22
  ## 输出格式(所有内容必须使用纯正中文)
23
23
  请以 Markdown 格式输出最终回复:
@@ -16,6 +16,7 @@ inheritSkills: false
16
16
  2. **输入与边界**:排查外部输入数据是否缺乏合法性校验、类型断言或长度/范围限制。
17
17
  3. **资源与生命周期**:排查文件句柄、网络流、连接会话是否未正确释放或存在泄露风险。
18
18
  4. **权限与防御**:排查接口与方法调用的边界条件是否健壮。
19
+ - 💡 **免检说明**:游戏或应用中的内部 GM(Game Master)指令面板、开发者调试控制台(Debug Console)及模拟工具属于受信任的开发辅助代码,在通过编译开关(如 `#if UNITY_EDITOR || DEVELOPMENT_BUILD`)或环境判断已与正式发布包隔离的前提下,严禁误判为安全隐患;但若此类入口在正式生产包中无防护暴露,仍属严重缺陷。
19
20
 
20
21
  ## 严重级别分类
21
22
  - `blocker` — 明显的私密凭证泄露或高危防御缺失