pi-git-commit 1.0.0 → 1.0.1
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 +76 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
# pi-git-commit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Keeps mutative git operations out of the agent's bash and provides a safe, reviewable commit flow in [pi-coding-agent](https://github.com/badlogic/pi-mono/tree/main/packages/coding-agent): a bash guard, a `git_commit` tool, and `/commit` + `/toggle-allow-git` commands.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What you get
|
|
6
6
|
|
|
7
|
-
- **Bash git guard.**
|
|
7
|
+
- **Bash git guard.** Mutative git commands are blocked in the agent's bash tool — `add`, `commit`, `push`, `pull`, `merge`, `rebase`, `reset`, `clean`, `rm`, `restore`, `switch`, `cherry-pick`, `revert`, `mv`, `init`, `clone`, plus destructive forms of `branch`, `tag`, `checkout`, `stash`, `submodule`, `worktree`, `config`, `remote`, `apply`, `notes`, `update-ref`, `gc` and more. Read-only commands (`status`, `diff`, `log`, `fetch`, `branch`, `tag`, `stash list`, ...) stay allowed.
|
|
8
8
|
- **`git_commit` tool.** The agent stages everything and commits with a `FIX` / `IMPROVE` / `NEW` type prefix. Enabled automatically on session start.
|
|
9
|
-
- **`/commit` command.**
|
|
10
|
-
- **`/toggle-allow-git` command.** Temporarily allows mutative git commands in bash for the current session.
|
|
9
|
+
- **`/commit` command.** Waits for queued messages to finish, stages all changes, shows the staged diff, and asks the agent to review it and commit via `git_commit` — never via bash.
|
|
10
|
+
- **`/toggle-allow-git` command.** Temporarily allows mutative git commands in bash for the current session. The guard re-arms on the next session.
|
|
11
|
+
|
|
12
|
+
## Quick start
|
|
13
|
+
|
|
14
|
+
1. Make your changes, then run:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
/commit
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
2. The extension stages the working tree and hands the staged diff to the agent with instructions to review it.
|
|
21
|
+
|
|
22
|
+
3. The agent commits using the `git_commit` tool:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"type": "FIX",
|
|
27
|
+
"message": "Fix off-by-one in the retry loop"
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
4. If you need to run mutative git yourself, allow it for the session:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
/toggle-allow-git
|
|
35
|
+
```
|
|
11
36
|
|
|
12
37
|
## Installation
|
|
13
38
|
|
|
@@ -15,8 +40,51 @@ A [pi-coding-agent](https://github.com/badlogic/pi-mono/tree/main/packages/codin
|
|
|
15
40
|
pi install npm:pi-git-commit
|
|
16
41
|
```
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
From a local checkout:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pi install /path/to/pi-git-commit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## The git_commit tool
|
|
50
|
+
|
|
51
|
+
| Field | Description |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `type` | `FIX` (bug fix), `IMPROVE` (improvement), or `NEW` (new feature). |
|
|
54
|
+
| `message` | Commit message in imperative mood. Multi-line allowed for detailed changes. |
|
|
55
|
+
|
|
56
|
+
The tool runs `git add .` followed by `git commit -m "<TYPE>: <message>"` and reports staging or commit failures as tool errors. The agent is instructed to only use it after you run `/commit`.
|
|
57
|
+
|
|
58
|
+
## The bash guard
|
|
59
|
+
|
|
60
|
+
The guard intercepts `tool_call` events for the bash tool and blocks commands that match mutative git forms. The block list is a conservative superset: anything that can change repository state is blocked, while a curated set of read-only forms is explicitly allowed (for example `git fetch`, `git stash list`, `git remote -v`, `git config --get`, `git apply --check`, `git checkout -- <file>`, `git submodule status`, `git worktree list`).
|
|
61
|
+
|
|
62
|
+
A blocked command returns:
|
|
63
|
+
|
|
64
|
+
```text
|
|
65
|
+
Mutative git commands are blocked. Use /toggle-allow-git to allow for this session.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Troubleshooting
|
|
69
|
+
|
|
70
|
+
- **The agent refuses to commit.** The guard blocks `git commit` in bash by design. Run `/commit` and let the agent use the `git_commit` tool.
|
|
71
|
+
- **"Nothing to commit (empty diff)."** There are no staged changes — make edits first, then run `/commit` again.
|
|
72
|
+
- **I need git in bash right now.** Run `/toggle-allow-git`; the guard re-arms automatically on the next session start.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
Requires [Node.js](https://nodejs.org) ≥ 22.19 and npm.
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install
|
|
80
|
+
npm test
|
|
81
|
+
npm run typecheck
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Credits
|
|
85
|
+
|
|
86
|
+
- [badlogic](https://github.com/badlogic), pi-coding-agent and the tool/command APIs
|
|
19
87
|
|
|
20
|
-
|
|
88
|
+
## License
|
|
21
89
|
|
|
22
|
-
|
|
90
|
+
[MIT](LICENSE)
|
package/package.json
CHANGED