pi-non-interactive 0.1.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.
Files changed (3) hide show
  1. package/README.md +26 -0
  2. package/index.ts +44 -0
  3. package/package.json +37 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # pi-non-interactive
2
+
3
+ Prevent agent hangs on interactive commands. Overrides the bash tool to inject env vars that make git and other tools non-interactive.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pi install npm:pi-non-interactive
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ Replaces the default bash tool with one that injects these env vars into every command:
14
+
15
+ | Variable | Value | Effect |
16
+ | --------------------- | ------ | -------------------------------------------------------------------- |
17
+ | `GIT_EDITOR` | `true` | `git rebase --continue`, `git commit` (no -m) succeed without editor |
18
+ | `GIT_SEQUENCE_EDITOR` | `true` | `git rebase -i` sequence editing |
19
+ | `GIT_PAGER` | `cat` | `git log`, `git diff`, `git show` don't hang on pager |
20
+ | `PAGER` | `cat` | Any tool respecting `$PAGER` |
21
+ | `LESS` | `-FX` | `less` exits immediately if output fits one screen |
22
+ | `BAT_PAGER` | `cat` | `bat` syntax highlighter non-interactive |
23
+
24
+ ## Why
25
+
26
+ AI agents can't interact with editors or pagers. Without this, commands like `git rebase --continue` or `git log` hang forever waiting for user input.
package/index.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * non-interactive-env Extension
3
+ *
4
+ * Prevents pi from hanging on commands that open interactive editors or pagers.
5
+ * Sets env vars that make git/tools fail gracefully instead of blocking.
6
+ *
7
+ * Covered:
8
+ * - GIT_EDITOR=true → git rebase --continue, git commit (no -m), etc.
9
+ * - GIT_SEQUENCE_EDITOR=true → git rebase -i sequence editing
10
+ * - GIT_PAGER=cat → git log, git diff, git show (no pager hang)
11
+ * - PAGER=cat → any tool that respects $PAGER
12
+ * - LESS=-FX → less exits immediately if output fits one screen
13
+ * - BAT_PAGER=cat → bat (syntax highlighter) non-interactive
14
+ */
15
+
16
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
17
+ import { createBashTool } from "@mariozechner/pi-coding-agent";
18
+
19
+ export default function (pi: ExtensionAPI) {
20
+ const cwd = process.cwd();
21
+
22
+ const bashTool = createBashTool(cwd, {
23
+ spawnHook: ({ command, cwd, env }) => ({
24
+ command,
25
+ cwd,
26
+ env: {
27
+ ...env,
28
+ GIT_EDITOR: "true",
29
+ GIT_SEQUENCE_EDITOR: "true",
30
+ GIT_PAGER: "cat",
31
+ PAGER: "cat",
32
+ LESS: "-FX",
33
+ BAT_PAGER: "cat",
34
+ },
35
+ }),
36
+ });
37
+
38
+ pi.registerTool({
39
+ ...bashTool,
40
+ execute: async (id, params, signal, onUpdate, _ctx) => {
41
+ return bashTool.execute(id, params, signal, onUpdate);
42
+ },
43
+ });
44
+ }
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "pi-non-interactive",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Prevent agent hangs on interactive commands — sets GIT_EDITOR=true, PAGER=cat, etc. for all bash executions",
6
+ "main": "./index.ts",
7
+ "keywords": [
8
+ "pi",
9
+ "pi-extension",
10
+ "pi-package",
11
+ "non-interactive",
12
+ "pager",
13
+ "git-editor"
14
+ ],
15
+ "author": "Edmund Miller <edmundmiller@hey.com>",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/edmundmiller/dotfiles.git",
20
+ "directory": "pi-packages/pi-non-interactive"
21
+ },
22
+ "files": [
23
+ "index.ts",
24
+ "README.md"
25
+ ],
26
+ "peerDependencies": {
27
+ "@mariozechner/pi-coding-agent": "*"
28
+ },
29
+ "pi": {
30
+ "extensions": [
31
+ "./index.ts"
32
+ ]
33
+ },
34
+ "scripts": {
35
+ "typecheck": "tsc --noEmit"
36
+ }
37
+ }