@unifan/pi-unifan-zh 1.0.0
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/README.md +111 -0
- package/extensions/review/CHANGELOG.md +540 -0
- package/extensions/review/LICENSE +15 -0
- package/extensions/review/README.md +55 -0
- package/extensions/review/agents/bugbot.md +46 -0
- package/extensions/review/agents/claude-md-compliance.md +46 -0
- package/extensions/review/agents/code-comments.md +43 -0
- package/extensions/review/agents/conventions.md +41 -0
- package/extensions/review/agents/gate.md +70 -0
- package/extensions/review/agents/history-context.md +45 -0
- package/extensions/review/agents/lite-review.md +51 -0
- package/extensions/review/agents/security-review.md +45 -0
- package/extensions/review/index.ts +205 -0
- package/extensions/review/package.json +38 -0
- package/extensions/review/reference/README.md +20 -0
- package/extensions/review/reference/claude-code-review.md +133 -0
- package/extensions/review/reference/cursor-review-skills.md +72 -0
- package/extensions/review/reference/pi-review-roadmap.md +183 -0
- package/extensions/review/reference/structured-output.md +26 -0
- package/extensions/review/reference/v0.2-plan.md +268 -0
- package/extensions/review/src/cli-args.ts +105 -0
- package/extensions/review/src/config.ts +340 -0
- package/extensions/review/src/directive.ts +481 -0
- package/extensions/review/src/gate-enforce.ts +151 -0
- package/extensions/review/src/lean-agents.ts +105 -0
- package/extensions/review/src/pr-ref.ts +39 -0
- package/extensions/review/src/report-tool.ts +394 -0
- package/extensions/review/src/report.ts +399 -0
- package/extensions/review/src/review-report.ts +279 -0
- package/extensions/review/src/review-run.ts +568 -0
- package/extensions/review/src/target-workspace.ts +239 -0
- package/extensions/review/src/tool-wrapper.ts +75 -0
- package/extensions/review/src/tui-renderer.ts +92 -0
- package/extensions/review/src/types.ts +207 -0
- package/extensions/review/src/workflow-schemas.ts +172 -0
- package/extensions/sessions/README.md +41 -0
- package/extensions/sessions/index.ts +862 -0
- package/extensions/sessions/package.json +21 -0
- package/extensions/sessions/sessions.ts +264 -0
- package/package.json +36 -0
- package/skills/README.md +29 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schema fragments injected as `outputSchema` on each reviewer and the
|
|
3
|
+
* gate. Kept in sync with src/schema.ts (used by the legacy spawn pipeline).
|
|
4
|
+
*
|
|
5
|
+
* The plugin no longer reads reviewer Markdown text; the workflowScript
|
|
6
|
+
* receives validated `result.structuredOutput` from pi-subagents.
|
|
7
|
+
*/
|
|
8
|
+
import type { IssueSeverity, IssueCategory, Verdict } from "./types.js";
|
|
9
|
+
|
|
10
|
+
export type JsonSchema = Record<string, unknown>;
|
|
11
|
+
|
|
12
|
+
const SEVERITY: IssueSeverity[] = ["blocker", "major", "minor", "nit"];
|
|
13
|
+
const CATEGORY: IssueCategory[] = [
|
|
14
|
+
"compliance",
|
|
15
|
+
"bug",
|
|
16
|
+
"convention",
|
|
17
|
+
"history",
|
|
18
|
+
"security",
|
|
19
|
+
"performance",
|
|
20
|
+
"docs",
|
|
21
|
+
"other",
|
|
22
|
+
];
|
|
23
|
+
const VERDICT: Verdict[] = ["approve", "request_changes", "comment"];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Stable JSON Schema describing the structured output of every reviewer.
|
|
27
|
+
* `status` distinguishes runtime `ok` (tool succeeded) from business
|
|
28
|
+
* `limited/skipped` (no findings because of missing context, not silence).
|
|
29
|
+
*/
|
|
30
|
+
export const REVIEWER_OUTPUT_SCHEMA: JsonSchema = {
|
|
31
|
+
type: "object",
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
required: ["status", "issues", "summary", "coverage"],
|
|
34
|
+
properties: {
|
|
35
|
+
status: {
|
|
36
|
+
type: "string",
|
|
37
|
+
enum: ["ok", "limited", "skipped"],
|
|
38
|
+
description:
|
|
39
|
+
"ok = reviewer produced findings normally; limited = could not run some checks (still may have issues); skipped = lane does not apply.",
|
|
40
|
+
},
|
|
41
|
+
issues: {
|
|
42
|
+
type: "array",
|
|
43
|
+
maxItems: 200,
|
|
44
|
+
items: {
|
|
45
|
+
type: "object",
|
|
46
|
+
additionalProperties: false,
|
|
47
|
+
required: ["file", "category", "severity", "confidence", "evidence", "fingerprint"],
|
|
48
|
+
properties: {
|
|
49
|
+
file: { type: "string", minLength: 1, maxLength: 500 },
|
|
50
|
+
line: { type: "integer", minimum: 1 },
|
|
51
|
+
relatedChangedLine: { type: "integer", minimum: 1 },
|
|
52
|
+
category: { type: "string", enum: CATEGORY },
|
|
53
|
+
severity: { type: "string", enum: SEVERITY },
|
|
54
|
+
confidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
55
|
+
evidence: { type: "string", minLength: 1, maxLength: 280 },
|
|
56
|
+
fingerprint: {
|
|
57
|
+
type: "string",
|
|
58
|
+
minLength: 1,
|
|
59
|
+
maxLength: 80,
|
|
60
|
+
description:
|
|
61
|
+
"Stable id (file:line:category[:short-hash-of-evidence]) so the gate can dedupe across reviewers.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
summary: { type: "string", minLength: 1, maxLength: 2000 },
|
|
67
|
+
coverage: {
|
|
68
|
+
type: "object",
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
required: ["filesChecked", "commandsRun", "limitations"],
|
|
71
|
+
properties: {
|
|
72
|
+
filesChecked: { type: "array", items: { type: "string" } },
|
|
73
|
+
commandsRun: { type: "array", items: { type: "string" } },
|
|
74
|
+
limitations: {
|
|
75
|
+
type: "array",
|
|
76
|
+
items: { type: "string" },
|
|
77
|
+
description: "Plain-language reasons for limited/skipped status.",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Stable JSON Schema describing the gate's structured output. Adds
|
|
86
|
+
* `dispositions` so every candidate (kept/dropped/merged) is auditable.
|
|
87
|
+
*/
|
|
88
|
+
export const GATE_OUTPUT_SCHEMA: JsonSchema = {
|
|
89
|
+
type: "object",
|
|
90
|
+
additionalProperties: false,
|
|
91
|
+
required: ["status", "verdict", "issues", "dispositions", "reason"],
|
|
92
|
+
properties: {
|
|
93
|
+
status: {
|
|
94
|
+
type: "string",
|
|
95
|
+
enum: ["ok", "limited", "skipped"],
|
|
96
|
+
},
|
|
97
|
+
verdict: { type: "string", enum: VERDICT },
|
|
98
|
+
issues: {
|
|
99
|
+
type: "array",
|
|
100
|
+
maxItems: 500,
|
|
101
|
+
items: {
|
|
102
|
+
type: "object",
|
|
103
|
+
additionalProperties: false,
|
|
104
|
+
required: ["file", "category", "severity", "confidence", "evidence", "fingerprint"],
|
|
105
|
+
properties: {
|
|
106
|
+
file: { type: "string", minLength: 1, maxLength: 500 },
|
|
107
|
+
line: { type: "integer", minimum: 1 },
|
|
108
|
+
relatedChangedLine: { type: "integer", minimum: 1 },
|
|
109
|
+
category: { type: "string", enum: CATEGORY },
|
|
110
|
+
severity: { type: "string", enum: SEVERITY },
|
|
111
|
+
confidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
112
|
+
evidence: { type: "string", minLength: 1, maxLength: 280 },
|
|
113
|
+
fingerprint: { type: "string", minLength: 1, maxLength: 80 },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
dispositions: {
|
|
118
|
+
type: "array",
|
|
119
|
+
description:
|
|
120
|
+
"Per-candidate disposition: kept | dropped | merged. Required for every reviewer candidate so reports can audit threshold/dedupe/verify decisions.",
|
|
121
|
+
items: {
|
|
122
|
+
type: "object",
|
|
123
|
+
additionalProperties: false,
|
|
124
|
+
required: ["fingerprint", "decision", "originalConfidence", "finalConfidence", "reason"],
|
|
125
|
+
properties: {
|
|
126
|
+
fingerprint: { type: "string", minLength: 1, maxLength: 80 },
|
|
127
|
+
decision: { type: "string", enum: ["kept", "dropped", "merged"] },
|
|
128
|
+
originalConfidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
129
|
+
finalConfidence: { type: "integer", minimum: 1, maximum: 10 },
|
|
130
|
+
sourceReviewers: {
|
|
131
|
+
type: "array",
|
|
132
|
+
items: { type: "string" },
|
|
133
|
+
},
|
|
134
|
+
reason: { type: "string", minLength: 1, maxLength: 500 },
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
reason: { type: "string", minLength: 1, maxLength: 500 },
|
|
139
|
+
coverage: {
|
|
140
|
+
type: "object",
|
|
141
|
+
additionalProperties: false,
|
|
142
|
+
properties: {
|
|
143
|
+
limitations: { type: "array", items: { type: "string" } },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Serialize a JSON Schema as a JS string literal safe to embed in the
|
|
151
|
+
* generated workflowScript. Avoids escaping mistakes from JSON.stringify +
|
|
152
|
+
* double-quoting gymnastics.
|
|
153
|
+
*/
|
|
154
|
+
export function serializeSchemaForJs(schema: JsonSchema): string {
|
|
155
|
+
return JSON.stringify(schema);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Serialize a JSON Schema as a multi-line JS object literal for embedding
|
|
160
|
+
* directly in the generated workflowScript (v0.7.3). The single-line form
|
|
161
|
+
* produced 1400+ character lines — the exact spot where the main agent's
|
|
162
|
+
* copy slipped a character (PR 19291 incident, `"maxLength":80",`).
|
|
163
|
+
* Multi-line keeps every line short enough to copy reliably.
|
|
164
|
+
*/
|
|
165
|
+
export function serializeSchemaAsObjectLiteral(schema: JsonSchema, indent = " "): string {
|
|
166
|
+
const json = JSON.stringify(schema, null, 2);
|
|
167
|
+
// Indent every line so the literal sits cleanly inside the script body.
|
|
168
|
+
return json
|
|
169
|
+
.split("\n")
|
|
170
|
+
.map((line, i) => (i === 0 ? line : indent + line))
|
|
171
|
+
.join("\n");
|
|
172
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 📜 @unifan/pi-sessions-zh (历史会话管理器·中文版)
|
|
2
|
+
|
|
3
|
+
为 **Pi Coding Agent** 打造的高颜值双栏历史会话选择器与实时预览恢复扩展。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ✨ 核心特性
|
|
8
|
+
|
|
9
|
+
- **双栏分屏浏览**:左侧会话列表(带 Git 变更统计 `+2 ~3 -1` 与相对时间),右侧毫秒级**实时渲染对话内容**。
|
|
10
|
+
- **对话结构化展示**:支持区分 `◆ 用户`、`● 助手`、`◌ 思考过程`、`▸ 工具调用` 与结果折叠。
|
|
11
|
+
- **全中文交互体验**:界面提示词、相对时间(刚刚/X分钟前/昨天)、操作指引全面中文化。
|
|
12
|
+
- **零负担独立运行**:完全解耦自 `pi-agent-extensions`,不附带任何无用工具,零额外 Token 消耗。
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 🚀 安装方式
|
|
17
|
+
|
|
18
|
+
### 独立单独安装:
|
|
19
|
+
```bash
|
|
20
|
+
pi install D:/program/my/pi-unifan-zh/extensions/sessions
|
|
21
|
+
```
|
|
22
|
+
*(或者推送到 GitHub 后使用 `pi install git:github.com/你的用户名/pi-unifan-zh?path=extensions/sessions`)*
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 🎮 使用方法
|
|
27
|
+
|
|
28
|
+
在 Pi 中直接输入:
|
|
29
|
+
```text
|
|
30
|
+
/sessions
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 快捷键指南:
|
|
34
|
+
- **`↑` / `↓`**:在左侧列表中移动选择会话。
|
|
35
|
+
- **`Enter`**:**一键恢复并切换到所选会话**。
|
|
36
|
+
- **`Tab` 或 `←` / `→`**:在左侧列表与右侧预览窗之间切换焦点。
|
|
37
|
+
- **`t`**:展开 / 折叠工具执行详细输出。
|
|
38
|
+
- **`h`**:展开 / 隐藏模型思考过程(Thinking)。
|
|
39
|
+
- **`PgUp` / `PgDn`** 或 **`Ctrl+U` / `Ctrl+D`**:预览窗上下滚屏翻页。
|
|
40
|
+
- **`Ctrl+T` 或 `Alt+W`**:切换“仅当前工作区会话”与“全部工作区会话”。
|
|
41
|
+
- **`Esc`**:退出选择器,回到当前会话。
|