oma-coding-agent 1.2.0 → 1.2.3
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/dist/cli.js +2869 -2869
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/git-workflow.ts +69 -0
- package/examples/extensions/handoff-doc.ts +103 -0
- package/examples/hooks/README.md +0 -1
- package/package.json +1 -1
- package/src/internal-urls/docs-index.generated.txt +2 -2
|
@@ -50,6 +50,7 @@ cp permission-gate.ts ~/.omp/agent/extensions/
|
|
|
50
50
|
| ------------------------ | ------------------------------------------------------------------------- |
|
|
51
51
|
| `git-checkpoint.ts` | Creates git stash checkpoints at each turn for code restoration on branch |
|
|
52
52
|
| `auto-commit-on-exit.ts` | Auto-commits on exit using last assistant message for commit message |
|
|
53
|
+
| `handoff-doc.ts` | Auto code review on commit + handoff doc on push via tool_result |
|
|
53
54
|
|
|
54
55
|
### System Prompt & Compaction
|
|
55
56
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Workflow Extension
|
|
3
|
+
*
|
|
4
|
+
* 在 git commit/push 成功后,自动注入代码审查和交接文档指令。
|
|
5
|
+
* 通过 tool_result 事件拦截 bash 工具的输出,追加上下文指令。
|
|
6
|
+
*
|
|
7
|
+
* - git commit 成功 → 追加代码审查指令
|
|
8
|
+
* - git push 成功 → 追加交接文档指令
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* omp --extension examples/extensions/git-workflow.ts
|
|
12
|
+
*/
|
|
13
|
+
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
14
|
+
|
|
15
|
+
export default function (pi: ExtensionAPI) {
|
|
16
|
+
pi.on("tool_result", async (event) => {
|
|
17
|
+
if (event.toolName !== "bash") return;
|
|
18
|
+
if (event.isError) return;
|
|
19
|
+
|
|
20
|
+
// 从 input 中获取原始命令
|
|
21
|
+
const command = (event.input as { command?: string }).command;
|
|
22
|
+
if (!command) return;
|
|
23
|
+
|
|
24
|
+
// 获取当前输出文本
|
|
25
|
+
const outputText = event.content
|
|
26
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
27
|
+
.map((c) => c.text)
|
|
28
|
+
.join("");
|
|
29
|
+
|
|
30
|
+
// git commit 成功 → 追加代码审查指令
|
|
31
|
+
if (/^git\s+commit\b/.test(command) && outputText.includes("[main")) {
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
...event.content,
|
|
35
|
+
{
|
|
36
|
+
type: "text" as const,
|
|
37
|
+
text: [
|
|
38
|
+
"",
|
|
39
|
+
"---",
|
|
40
|
+
"📋 代码审查提醒:请在 push 前审查本次 commit 的变更。",
|
|
41
|
+
"使用 git diff HEAD~1 查看变更,确认无问题后再 push。",
|
|
42
|
+
"如有交接文档需求,请在 push 后自动完成。",
|
|
43
|
+
].join("\n"),
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// git push 成功 → 追加交接文档指令
|
|
50
|
+
if (/^git\s+push\b/.test(command) && outputText.includes("..")) {
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
...event.content,
|
|
54
|
+
{
|
|
55
|
+
type: "text" as const,
|
|
56
|
+
text: [
|
|
57
|
+
"",
|
|
58
|
+
"---",
|
|
59
|
+
"📝 交接文档提醒:请写交接文档到 OpenSpec/handoffs/ 目录下。",
|
|
60
|
+
"文件名格式:handoff-YYYY-MM-DD.md",
|
|
61
|
+
"内容包含:本次完成的工作内容、修改/创建的文件列表、关键技术决策、未完成的工作、下次继续时需要的上下文。",
|
|
62
|
+
"使用 write 工具直接写入文件。",
|
|
63
|
+
].join("\n"),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handoff Document Extension (Git-triggered)
|
|
3
|
+
*
|
|
4
|
+
* 通过 git 操作触发代码审查和交接文档生成:
|
|
5
|
+
* - git commit → 每次新 commit block 要求审查;LLM 重试时放行;成功后重置
|
|
6
|
+
* - git push → 成功后追加交接文档提示(仅首次)
|
|
7
|
+
*
|
|
8
|
+
* 状态机:
|
|
9
|
+
* 新 commit → block(reviewJustDone=true) → LLM 重试 → 放行(clear) →
|
|
10
|
+
* 新 commit → block(reviewJustDone=true) → LLM 重试 → 放行(clear) → ...
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* omp --extension examples/extensions/handoff-doc.ts
|
|
14
|
+
*/
|
|
15
|
+
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
|
|
16
|
+
|
|
17
|
+
const HANDOFF_PROMPT_ADDED = "[handoff-doc:prompt-added]";
|
|
18
|
+
|
|
19
|
+
export default function (pi: ExtensionAPI) {
|
|
20
|
+
// commit 审查状态:刚完成审查时允许下一个 commit 通过
|
|
21
|
+
let reviewJustDone = false;
|
|
22
|
+
|
|
23
|
+
pi.on("tool_call", async event => {
|
|
24
|
+
if (event.toolName !== "bash") return;
|
|
25
|
+
|
|
26
|
+
const input = event.input;
|
|
27
|
+
if (!input || typeof input !== "object" || !("command" in input)) return;
|
|
28
|
+
const command = String(input.command);
|
|
29
|
+
|
|
30
|
+
if (!/^git\s+commit\b/.test(command)) return;
|
|
31
|
+
|
|
32
|
+
// 审查后重试 → 放行,然后重置(下次新 commit 需要重新审查)
|
|
33
|
+
if (reviewJustDone) {
|
|
34
|
+
reviewJustDone = false;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 新 commit → block 要求审查
|
|
39
|
+
reviewJustDone = true;
|
|
40
|
+
return {
|
|
41
|
+
block: true,
|
|
42
|
+
reason: [
|
|
43
|
+
"请先审查本次暂存区的变更,确认无问题后再 commit。",
|
|
44
|
+
"运行 git diff --cached 查看变更内容。",
|
|
45
|
+
].join("\n"),
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// commit 成功后重置审查状态(确保下次新 commit 重新审查)
|
|
50
|
+
// push 后写交接文档(仅首次)
|
|
51
|
+
let pushHandoffTriggered = false;
|
|
52
|
+
|
|
53
|
+
pi.on("tool_result", async event => {
|
|
54
|
+
if (event.toolName !== "bash") return;
|
|
55
|
+
|
|
56
|
+
const input = event.input;
|
|
57
|
+
if (!input || typeof input !== "object" || !("command" in input)) return;
|
|
58
|
+
const command = String(input.command);
|
|
59
|
+
|
|
60
|
+
const existingText = event.content
|
|
61
|
+
.filter((c): c is { type: "text"; text: string } => c.type === "text")
|
|
62
|
+
.map(c => c.text)
|
|
63
|
+
.join("\n");
|
|
64
|
+
|
|
65
|
+
if (existingText.includes(HANDOFF_PROMPT_ADDED)) return;
|
|
66
|
+
|
|
67
|
+
if (event.isError) return;
|
|
68
|
+
const { details } = event;
|
|
69
|
+
if (details?.exitCode !== undefined && details.exitCode !== 0) return;
|
|
70
|
+
|
|
71
|
+
// commit 成功 → 重置审查状态
|
|
72
|
+
if (/^git\s+commit\b/.test(command)) {
|
|
73
|
+
reviewJustDone = false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// push 成功 → 提示写交接文档(仅首次)
|
|
77
|
+
if (/^git\s+push\b/.test(command) && !pushHandoffTriggered) {
|
|
78
|
+
pushHandoffTriggered = true;
|
|
79
|
+
return {
|
|
80
|
+
content: [
|
|
81
|
+
...event.content,
|
|
82
|
+
{
|
|
83
|
+
type: "text" as const,
|
|
84
|
+
text: [
|
|
85
|
+
HANDOFF_PROMPT_ADDED,
|
|
86
|
+
"",
|
|
87
|
+
"代码已推送成功。请将本次工作的交接文档写到 OpenSpec/handoffs/ 目录下,文件名格式 handoff-YYYY-MM-DD.md。",
|
|
88
|
+
"",
|
|
89
|
+
"交接文档应包含:",
|
|
90
|
+
"1. 本次完成的工作内容",
|
|
91
|
+
"2. 修改/创建的文件列表",
|
|
92
|
+
"3. 关键技术决策",
|
|
93
|
+
"4. 未完成的工作",
|
|
94
|
+
"5. 下次继续时需要的上下文",
|
|
95
|
+
"",
|
|
96
|
+
"使用 write 工具直接写入文件。",
|
|
97
|
+
].join("\n"),
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
package/examples/hooks/README.md
CHANGED
|
@@ -28,7 +28,6 @@ cp permission-gate.ts ~/.omp/agent/hooks/
|
|
|
28
28
|
| `snake.ts` | Snake game with custom UI, keyboard handling, and session persistence |
|
|
29
29
|
| `status-line.ts` | Shows turn progress in footer via `ctx.ui.setStatus()` with themed colors |
|
|
30
30
|
| `handoff.ts` | Transfer context to a new focused session via `/handoff <goal>` |
|
|
31
|
-
|
|
32
31
|
## Writing Hooks
|
|
33
32
|
|
|
34
33
|
See [docs/hooks.md](../../docs/hooks.md) for full documentation.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "oma-coding-agent",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"description": "AI coding agent optimized for low-end models (MiMo, DeepSeek, GLM, Qwen, Kimi)",
|
|
6
6
|
"homepage": "https://github.com/wangneal/my-agent",
|
|
7
7
|
"author": "wangneal",
|