@ghyper9023/pi-dev-workflow 0.1.7
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/LICENSE +21 -0
- package/README.md +124 -0
- package/agents/git-agent.md +38 -0
- package/agents/review-agent.md +36 -0
- package/extensions/git-commands.ts +231 -0
- package/extensions/sub-agents.ts +741 -0
- package/package.json +40 -0
- package/prompts/APPEND_SYSTEM.md +12 -0
- package/prompts/review-commit.md +2 -0
- package/prompts/review-diff.md +2 -0
- package/skills/karpathy-guidelines/SKILL.md +67 -0
- package/skills/review-html/SKILL.md +45 -0
- package/themes/claude-code-theme.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ghyper9023
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# @ghyper9023/pi-dev-workflow
|
|
2
|
+
|
|
3
|
+
> Developer workflow toolkit for [pi coding agent](https://pi.dev/): git agents, code review, Karpathy guidelines, themes
|
|
4
|
+
|
|
5
|
+
## 快速安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 通过 npm 安装(推荐)
|
|
9
|
+
pi install npm:@ghyper9023/pi-dev-workflow
|
|
10
|
+
|
|
11
|
+
# 或通过 git 安装
|
|
12
|
+
pi install git:github.com/cherish-ltt/pi-dev-workflow
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
然后 `/reload` 热加载即可使用所有功能。
|
|
16
|
+
|
|
17
|
+
## 目录结构
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pi-package/
|
|
21
|
+
├── package.json # 包元数据 & pi 配置
|
|
22
|
+
├── README.md # 本文件
|
|
23
|
+
├── .gitignore
|
|
24
|
+
├── agents/
|
|
25
|
+
│ ├── git-agent.md # git-sub-agent 定义(专注 git 操作)
|
|
26
|
+
│ └── review-agent.md # review-sub-agent 定义(专注代码审查)
|
|
27
|
+
├── prompts/
|
|
28
|
+
│ ├── APPEND_SYSTEM.md # 全局追加提示:强制使用简体中文+英文专业名词
|
|
29
|
+
│ ├── review-commit.md # 审查 commit 的提示模板
|
|
30
|
+
│ └── review-diff.md # 审查 diff 的提示模板
|
|
31
|
+
├── skills/
|
|
32
|
+
│ ├── karpathy-guidelines/
|
|
33
|
+
│ │ └── SKILL.md # Karpathy 编码准则(避免 LLM 常见错误)
|
|
34
|
+
│ └── review-html/
|
|
35
|
+
│ └── SKILL.md # 代码审查 → 输出交互式 HTML 报告
|
|
36
|
+
├── extensions/
|
|
37
|
+
│ └── sub-agents.ts # 子代理系统:git-sub-agent + review-sub-agent
|
|
38
|
+
└── themes/
|
|
39
|
+
└── claude-code-theme.json # Claude Code CLI 风格主题
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Sub-Agents(子代理)
|
|
43
|
+
|
|
44
|
+
子代理运行在独立的 `pi` 进程中,拥有隔离的上下文窗口,专注处理特定领域任务。
|
|
45
|
+
|
|
46
|
+
| 子代理 | 触发方式 | 职责 |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| **git-sub-agent** | `/git-commit [msg]` / `/git-push` / `/git-commit-push [msg]` | Git 全流程操作 |
|
|
49
|
+
| **review-sub-agent** | 自动检测用户提示中的审查意图 | 代码审查、diff 分析 |
|
|
50
|
+
|
|
51
|
+
### git-sub-agent
|
|
52
|
+
|
|
53
|
+
在隔离进程中执行 git 操作,支持三种子命令:
|
|
54
|
+
|
|
55
|
+
| 命令 | 说明 |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `/git-commit [message]` | 暂存所有变更并提交(空信息让 AI 根据 diff 自动生成 Conventional Commits message) |
|
|
58
|
+
| `/git-push` | 推送到远程 |
|
|
59
|
+
| `/git-commit-push [message]` | 暂存 + 提交 + 推送一键完成 |
|
|
60
|
+
|
|
61
|
+
### review-sub-agent
|
|
62
|
+
|
|
63
|
+
当用户输入包含 review/审查/审阅 + code/代码/diff/commit/html 等关键词时,自动弹出三种模式选择:
|
|
64
|
+
|
|
65
|
+
| # | 模式 | 行为 |
|
|
66
|
+
|---|------|------|
|
|
67
|
+
| **1** | 后台审查(非阻塞,异步通知) | 后台运行审查,不阻塞对话,完成后通过消息通知 |
|
|
68
|
+
| **2** | 仅审查(阻塞,等待结果) | 等待审查完成才恢复交互 |
|
|
69
|
+
| **3** / Esc | 不是审查(放行给主代理) | 不启动子代理,原消息交给主 AI 处理 |
|
|
70
|
+
|
|
71
|
+
也支持 `/skill:review-html` 直接触发阻塞审查。
|
|
72
|
+
审查结果以交互式 HTML 报告形式写入 `pi-review/` 目录。
|
|
73
|
+
|
|
74
|
+
### subagent 工具
|
|
75
|
+
|
|
76
|
+
LLM 也可以直接调用 `subagent` 工具委派任务给任意子代理:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
可用子代理:git-agent, review-agent
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Themes
|
|
83
|
+
|
|
84
|
+
| Theme | 说明 |
|
|
85
|
+
|---|---|
|
|
86
|
+
| **claude-code-theme** | 仿 Claude Code CLI 配色:深色底 + 琥珀金主色 + 紫罗兰辅色 |
|
|
87
|
+
|
|
88
|
+
## Skills
|
|
89
|
+
|
|
90
|
+
| Skill | 来源 | 说明 |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| **karpathy-guidelines** | [forrestchang/andrej-karpathy-skills](https://github.com/forrestchang/andrej-karpathy-skills) | 基于 Andrej Karpathy 对 LLM 编码陷阱的观察,强调简洁、精准、可验证 |
|
|
93
|
+
| **review-html** | 自制 | git diff / commit 审查,输出自包含的交互式 HTML 报告 |
|
|
94
|
+
|
|
95
|
+
## 使用方式
|
|
96
|
+
|
|
97
|
+
### 安装
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 通过 npm 安装(推荐)
|
|
101
|
+
pi install npm:@ghyper9023/pi-dev-workflow
|
|
102
|
+
|
|
103
|
+
# 或通过 git 安装
|
|
104
|
+
pi install git:github.com/cherish-ltt/pi-dev-workflow
|
|
105
|
+
|
|
106
|
+
# 或从本地目录安装
|
|
107
|
+
pi install /path/to/pi-dev-workflow
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 加载
|
|
111
|
+
|
|
112
|
+
pi 会自动加载包内的 `skills/`、`prompts/`、`extensions/`、`themes/` 内容。
|
|
113
|
+
安装后执行 `/reload` 热加载所有变更。
|
|
114
|
+
|
|
115
|
+
### 包更新
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pi install git:github.com/cherish-ltt/pi-dev-workflow
|
|
119
|
+
/reload
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: git-agent
|
|
3
|
+
description: Git operations specialist for commit, push, and commit-push
|
|
4
|
+
tools: bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a git operations specialist. Your sole responsibility is executing git commands.
|
|
8
|
+
|
|
9
|
+
You have access to only one tool: `bash`.
|
|
10
|
+
|
|
11
|
+
## CRITICAL: Output constraint
|
|
12
|
+
|
|
13
|
+
Your output MUST NOT exceed 3 short lines (50 chars max per line). NEVER print git diff output, file contents, or any verbose status output.
|
|
14
|
+
|
|
15
|
+
## Operations
|
|
16
|
+
|
|
17
|
+
1. **Commit:** `git add -A` then `git commit -m "message"`
|
|
18
|
+
2. **Push:** `git push`
|
|
19
|
+
3. **Commit & Push:** Stage, commit, then push
|
|
20
|
+
|
|
21
|
+
## Guidelines
|
|
22
|
+
|
|
23
|
+
- Always run `git status` first to check state
|
|
24
|
+
- For commit messages, use Conventional Commits format: `feat:`, `fix:`, `refactor:`, `docs:`, `style:`, `test:`, `chore:`, `perf:`
|
|
25
|
+
- Base message on what the diff actually contains
|
|
26
|
+
- Keep summary line under 72 chars
|
|
27
|
+
- If no changes to commit, report that clearly
|
|
28
|
+
|
|
29
|
+
## Output format (50 chars max per line)
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
<status>✅</status>
|
|
33
|
+
<summary>commit: <first 40 chars of message></summary>
|
|
34
|
+
<details>
|
|
35
|
+
- files: N files changed
|
|
36
|
+
- push: success / failed - reason
|
|
37
|
+
</details>
|
|
38
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review-agent
|
|
3
|
+
description: Review 代码,生成 HTML 审查报告并输出到 pi-review/ 目录
|
|
4
|
+
tools: read, write, bash, grep, find, ls
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
你是一个代码审查助手,运行在隔离的上下文窗口中。
|
|
8
|
+
|
|
9
|
+
## 工作流程
|
|
10
|
+
|
|
11
|
+
1. **读取技能**:使用 `read` 工具加载 `skills/review-html/SKILL.md`,严格遵循其指令。
|
|
12
|
+
2. **获取改动**:运行 `git diff`(未提交改动)或 `git log -p -n 3`(最近提交),查看代码变更。
|
|
13
|
+
3. **分析审查**:按 skill 中的约束检查 BUG、敏感信息、可维护性、规范等。
|
|
14
|
+
4. **生成 HTML**:按 skill 的 HTML 约束生成完整的自包含 HTML 审查报告。
|
|
15
|
+
5. **写入文件**:使用 `write` 工具将 HTML 保存到 `pi-review/` 目录。
|
|
16
|
+
- 文件名格式:`YYYYMMDD-HHmm-任务简述-index.html`
|
|
17
|
+
- `pi-review/` 目录不存在则先 mkdir 创建(已存在于 .gitignore)
|
|
18
|
+
6. **汇报结果**:stdout 只输出以下格式的简要总结,**不要输出 HTML 内容到 stdout**:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
<status>✅</status>
|
|
22
|
+
<summary>审查完成,报告文件</summary>
|
|
23
|
+
<details>
|
|
24
|
+
- 审查范围: git diff (X files changed)
|
|
25
|
+
- 报告: pi-review/20260513-xxxx-xxx-index.html
|
|
26
|
+
- 发现问题: X bugs, X warnings, X suggestions
|
|
27
|
+
</details>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 重要规则
|
|
31
|
+
|
|
32
|
+
- HTML 必须**写文件到 pi-review/**,**不要输出到 stdout**
|
|
33
|
+
- stdout 只输出上面的简短结构化摘要(参考 git-agent 的做法)
|
|
34
|
+
- 使用 `bash` 运行 git 命令和创建目录
|
|
35
|
+
- 使用 `write` 工具写 HTML 文件
|
|
36
|
+
- 使用 `read` 工具读取 skill 文件
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Commands Extension
|
|
3
|
+
*
|
|
4
|
+
* Registers three commands that delegate to git-sub-agent:
|
|
5
|
+
* /git-commit [message] - Stage all changes and commit
|
|
6
|
+
* /git-push - Push commits to remote
|
|
7
|
+
* /git-commit-push [message] - Stage, commit, and push in one go
|
|
8
|
+
*
|
|
9
|
+
* Associated extension: sub-agents.ts (provides spawnSubagent infrastructure)
|
|
10
|
+
*
|
|
11
|
+
* Place in .pi/extensions/ or ~/.pi/agent/extensions/ for auto-discovery.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
15
|
+
import { discoverAgents, spawnSubagent, extractFinalOutput, type AgentDef } from "./sub-agents";
|
|
16
|
+
|
|
17
|
+
// ── Helpers ──────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
function getAgent(
|
|
20
|
+
ctx: { ui: { notify: (msg: string, type: string) => void } },
|
|
21
|
+
agent: AgentDef | undefined,
|
|
22
|
+
name: string,
|
|
23
|
+
): AgentDef | null {
|
|
24
|
+
if (!agent) {
|
|
25
|
+
ctx.ui.notify(`❌ ${name} not found (check agents/${name}.md)`, "error");
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return agent;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Parse git-agent structured output into a clean summary. */
|
|
32
|
+
interface GitSummary {
|
|
33
|
+
status: "success" | "fail" | "unknown";
|
|
34
|
+
summary: string;
|
|
35
|
+
details: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parseGitOutput(output: string): GitSummary {
|
|
39
|
+
const result: GitSummary = { status: "unknown", summary: "", details: [] };
|
|
40
|
+
|
|
41
|
+
// Parse <status>...</status>
|
|
42
|
+
const statusMatch = output.match(/<status>([^<]*)<\/status>/);
|
|
43
|
+
if (statusMatch) {
|
|
44
|
+
const s = statusMatch[1].trim();
|
|
45
|
+
if (s.includes("✅") || s.includes("✔")) result.status = "success";
|
|
46
|
+
else if (s.includes("❌") || s.includes("✖")) result.status = "fail";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Parse <summary>...</summary>
|
|
50
|
+
const summaryMatch = output.match(/<summary>([\s\S]*?)<\/summary>/);
|
|
51
|
+
if (summaryMatch) result.summary = summaryMatch[1].trim();
|
|
52
|
+
|
|
53
|
+
// Parse <details>...</details> → extract each line
|
|
54
|
+
const detailsMatch = output.match(/<details>([\s\S]*?)<\/details>/);
|
|
55
|
+
if (detailsMatch) {
|
|
56
|
+
const lines = detailsMatch[1]
|
|
57
|
+
.split("\n")
|
|
58
|
+
.map((l) => l.replace(/^[-*]\s*/, "").trim())
|
|
59
|
+
.filter(Boolean);
|
|
60
|
+
result.details = lines;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Fallback: if no structured format, use raw lines
|
|
64
|
+
if (!statusMatch && !summaryMatch) {
|
|
65
|
+
const lines = output.split("\n").filter((l) => l.trim());
|
|
66
|
+
result.summary = lines[0] || "";
|
|
67
|
+
result.details = lines.slice(1).map((l) => l.replace(/^[-*]\s*/, "").trim()).filter(Boolean);
|
|
68
|
+
// Infer status from content
|
|
69
|
+
if (output.includes("✅") || output.includes("success") || output.includes("完成")) {
|
|
70
|
+
result.status = "success";
|
|
71
|
+
} else if (output.includes("❌") || output.includes("fail") || output.includes("失败")) {
|
|
72
|
+
result.status = "fail";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Enrich a detail line with relevant emoji icons. */
|
|
80
|
+
function iconify(line: string): string {
|
|
81
|
+
const lc = line.toLowerCase();
|
|
82
|
+
if (lc.startsWith("commit")) return `📝 ${line}`;
|
|
83
|
+
if (lc.startsWith("push")) return `📤 ${line}`;
|
|
84
|
+
if (lc.includes("file") || lc.includes("文件")) return `📁 ${line}`;
|
|
85
|
+
if (lc.startsWith("branch") || lc.includes("branch")) return `🌿 ${line}`;
|
|
86
|
+
if (lc.startsWith("tag") || lc.includes("tag")) return `🏷️ ${line}`;
|
|
87
|
+
return ` ${line}`; // indent others
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async function runSubAgent(
|
|
91
|
+
agent: AgentDef,
|
|
92
|
+
task: string,
|
|
93
|
+
ctx: {
|
|
94
|
+
cwd: string;
|
|
95
|
+
signal?: AbortSignal;
|
|
96
|
+
ui: {
|
|
97
|
+
setStatus: (key: string, status: string | undefined) => void;
|
|
98
|
+
notify: (msg: string, type: string) => void;
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
): Promise<void> {
|
|
102
|
+
const startTime = Date.now();
|
|
103
|
+
ctx.ui.setStatus("subagent", "🤖 git-sub-agent working...");
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const result = await spawnSubagent(
|
|
107
|
+
agent,
|
|
108
|
+
task,
|
|
109
|
+
ctx.cwd,
|
|
110
|
+
ctx.signal,
|
|
111
|
+
undefined, // use agent's default timeout
|
|
112
|
+
(progress) => {
|
|
113
|
+
ctx.ui.setStatus("subagent", progress.slice(0, 50));
|
|
114
|
+
},
|
|
115
|
+
);
|
|
116
|
+
const dur = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
117
|
+
|
|
118
|
+
// Extract output with fallback to raw stdout
|
|
119
|
+
let output = extractFinalOutput(result.output);
|
|
120
|
+
if (!output && result.output.trim()) {
|
|
121
|
+
const lines = result.output.split("\n").filter((l) => {
|
|
122
|
+
const t = l.trim();
|
|
123
|
+
return t && !t.startsWith("{") && !t.startsWith("[");
|
|
124
|
+
});
|
|
125
|
+
if (lines.length > 0) {
|
|
126
|
+
output = lines.join("\n").trim();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
ctx.ui.setStatus("subagent", undefined);
|
|
131
|
+
|
|
132
|
+
if (output) {
|
|
133
|
+
const parsed = parseGitOutput(output);
|
|
134
|
+
const statusIcon = parsed.status === "success" ? "✅" : parsed.status === "fail" ? "❌" : "ℹ️";
|
|
135
|
+
const detailText = parsed.details.length > 0 ? ` | ${parsed.details.join(" | ")}` : "";
|
|
136
|
+
const msg = `${statusIcon} ${parsed.summary || "done"} (${dur}s)${detailText}`;
|
|
137
|
+
const notifyType = parsed.status === "fail" ? "error" : "success";
|
|
138
|
+
ctx.ui.notify(msg, notifyType);
|
|
139
|
+
} else if (result.exitCode !== 0) {
|
|
140
|
+
const errMsg = result.stderr || result.output.slice(0, 300) || "未知错误";
|
|
141
|
+
ctx.ui.notify(`❌ git-sub-agent 失败 (${dur}s): ${errMsg}`, "error");
|
|
142
|
+
} else {
|
|
143
|
+
ctx.ui.notify(`✅ git-sub-agent 完成 (${dur}s)`, "success");
|
|
144
|
+
}
|
|
145
|
+
} finally {
|
|
146
|
+
ctx.ui.setStatus("subagent", undefined);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ── Extension ────────────────────────────────────────────────
|
|
151
|
+
|
|
152
|
+
export default function (pi: ExtensionAPI) {
|
|
153
|
+
const agents = discoverAgents();
|
|
154
|
+
const gitAgent = agents.find((a) => a.name === "git-agent");
|
|
155
|
+
|
|
156
|
+
// ── /git-commit ────────────────────────────────────────────
|
|
157
|
+
pi.registerCommand("git-commit", {
|
|
158
|
+
description: "(sub-agent) Stage all changes and create a commit via git-sub-agent",
|
|
159
|
+
handler: async (args, ctx) => {
|
|
160
|
+
const agent = getAgent(ctx, gitAgent, "git-agent");
|
|
161
|
+
if (!agent) return;
|
|
162
|
+
|
|
163
|
+
let message = args.trim();
|
|
164
|
+
if (!message) {
|
|
165
|
+
const input = await ctx.ui.input("Commit message", {
|
|
166
|
+
placeholder: "直接回车让 AI 自动生成,或输入信息后提交...",
|
|
167
|
+
required: false,
|
|
168
|
+
});
|
|
169
|
+
if (input === undefined) {
|
|
170
|
+
ctx.ui.notify("Commit cancelled", "warning");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
message = input.trim();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
ctx.ui.notify("🤖 正在委派 git-sub-agent 处理...", "info");
|
|
177
|
+
|
|
178
|
+
const task = message
|
|
179
|
+
? `Stage all changes with git add -A, then commit with message: "${message}". Do NOT ask for confirmation.`
|
|
180
|
+
: `Stage all changes with git add -A, check the diff, write a Conventional Commits message, and commit. Do NOT ask for confirmation.`;
|
|
181
|
+
|
|
182
|
+
await runSubAgent(agent, task, ctx);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// ── /git-push ─────────────────────────────────────────────
|
|
187
|
+
pi.registerCommand("git-push", {
|
|
188
|
+
description: "(sub-agent) Push commits to remote via git-sub-agent",
|
|
189
|
+
handler: async (_args, ctx) => {
|
|
190
|
+
const agent = getAgent(ctx, gitAgent, "git-agent");
|
|
191
|
+
if (!agent) return;
|
|
192
|
+
|
|
193
|
+
ctx.ui.notify("🤖 正在委派 git-sub-agent 处理...", "info");
|
|
194
|
+
await runSubAgent(
|
|
195
|
+
agent,
|
|
196
|
+
"Push commits to remote with git push. Do NOT ask for confirmation.",
|
|
197
|
+
ctx,
|
|
198
|
+
);
|
|
199
|
+
},
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// ── /git-commit-push ──────────────────────────────────────
|
|
203
|
+
pi.registerCommand("git-commit-push", {
|
|
204
|
+
description: "(sub-agent) Stage, commit, and push via git-sub-agent",
|
|
205
|
+
handler: async (args, ctx) => {
|
|
206
|
+
const agent = getAgent(ctx, gitAgent, "git-agent");
|
|
207
|
+
if (!agent) return;
|
|
208
|
+
|
|
209
|
+
let message = args.trim();
|
|
210
|
+
if (!message) {
|
|
211
|
+
const input = await ctx.ui.input("Commit message", {
|
|
212
|
+
placeholder: "直接回车让 AI 自动生成,或输入信息后提交并推送...",
|
|
213
|
+
required: false,
|
|
214
|
+
});
|
|
215
|
+
if (input === undefined) {
|
|
216
|
+
ctx.ui.notify("Commit & push cancelled", "warning");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
message = input.trim();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
ctx.ui.notify("🤖 正在委派 git-sub-agent 处理...", "info");
|
|
223
|
+
|
|
224
|
+
const task = message
|
|
225
|
+
? `Stage all changes with git add -A, commit with message: "${message}", then push. Do NOT ask for confirmation.`
|
|
226
|
+
: `Stage all changes with git add -A, check the diff, write a Conventional Commits message, commit, then push. Do NOT ask for confirmation.`;
|
|
227
|
+
|
|
228
|
+
await runSubAgent(agent, task, ctx);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
}
|