@luxass/pi-personal 0.2.1 → 0.2.2
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 +2 -0
- package/package.json +1 -1
- package/src/git-interceptor.ts +43 -2
package/README.md
CHANGED
|
@@ -16,4 +16,6 @@ The `/resources` dialog now lives in [`@luxass/pi-resources`](../pi-resources/RE
|
|
|
16
16
|
|
|
17
17
|
The dependency policy tells the model to reuse existing code, installed dependencies, and platform APIs first. It requires explicit user approval before adding, replacing, or upgrading dependencies. Routine installs of existing dependencies remain allowed through Socket Firewall. This is a model instruction, not an enforced approval gate.
|
|
18
18
|
|
|
19
|
+
The Git interceptor preserves your commit signing settings for commits and rebases. It blocks common signing bypasses, including `--no-gpg-sign`, false values for `commit.gpgsign`, removal of that setting, and indexed Git configuration environment overrides. It also tells the model to stop and ask for help if signing fails. It does not enable signing where you disabled it. These shell checks are safeguards for common commands, not a complete security boundary.
|
|
20
|
+
|
|
19
21
|
The package also includes Crow provider support, compaction continuation, Git and package-manager interceptors, and a worker configuration guard. These defaults suit one workflow and are meant to be edited in place rather than configured through settings.
|
package/package.json
CHANGED
package/src/git-interceptor.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git Interceptor
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Guards for agent-driven git commands:
|
|
5
5
|
*
|
|
6
6
|
* 1. Editor hang prevention — Sets GIT_EDITOR, GIT_SEQUENCE_EDITOR to `true`
|
|
7
7
|
* (no-op) and GIT_MERGE_AUTOEDIT to `no` so git never spawns an interactive
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* 2. Hook bypass prevention — Blocks any command containing `--no-verify` so
|
|
11
11
|
* the agent cannot circumvent git hooks (pre-commit, commit-msg, etc.).
|
|
12
12
|
* The agent should fix hook failures or ask the human for help instead.
|
|
13
|
+
*
|
|
14
|
+
* 3. Signing bypass prevention — Preserve the user's signing settings and
|
|
15
|
+
* block common attempts to disable them. Never force signing on.
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
18
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
@@ -24,10 +27,48 @@ const BLOCK_REASON =
|
|
|
24
27
|
"Do not attempt to bypass them. Instead: fix the underlying issue that " +
|
|
25
28
|
"is causing the hook to fail, or ask the user for help.";
|
|
26
29
|
|
|
30
|
+
const SIGNING_POLICY = `Git signing policy:
|
|
31
|
+
Preserve the user's configured commit signing behavior for commits and rebases.
|
|
32
|
+
Never disable or bypass signing with --no-gpg-sign, commit.gpgsign=false, false boolean equivalents, configuration removal, or environment overrides.
|
|
33
|
+
Do not change signing keys, signing programs, or signing configuration to work around a failure.
|
|
34
|
+
If signing fails, stop and ask the user for help. Do not retry with signing disabled.
|
|
35
|
+
Do not force signing in repositories where the user has not enabled it.`;
|
|
36
|
+
|
|
37
|
+
const SIGNING_BLOCK_REASON =
|
|
38
|
+
"BLOCKED: Disabling Git commit signing is not allowed. Preserve the user's signing settings. " +
|
|
39
|
+
"If signing fails, stop and ask the user for help instead of retrying without signing.";
|
|
40
|
+
|
|
41
|
+
function disablesSigning(command: string): boolean {
|
|
42
|
+
// Match common quoted shell forms without claiming to parse arbitrary shell code.
|
|
43
|
+
const normalized = command.replace(/["'\\]/g, "").toLowerCase();
|
|
44
|
+
if (/--no-gpg-sign\b/.test(normalized)) return true;
|
|
45
|
+
if (/\bcommit\.gpgsign\s*(?:=\s*|\s+)(?:false|no|off|0)(?=$|[\s;|&()])/.test(normalized)) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
/\bcommit\.gpgsign\b/.test(normalized) &&
|
|
50
|
+
/(?:^|\s)(?:--unset(?:-all)?|unset)(?=\s|$)/.test(normalized)
|
|
51
|
+
) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
for (const match of normalized.matchAll(/\bgit_config_key_(\d+)=commit\.gpgsign\b/g)) {
|
|
55
|
+
const value = new RegExp(`\\bgit_config_value_${match[1]}=(?:false|no|off|0)(?=$|[\\s;|&()])`);
|
|
56
|
+
if (value.test(normalized)) return true;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
27
61
|
export default function (pi: ExtensionAPI) {
|
|
62
|
+
pi.on("before_agent_start", (event) => {
|
|
63
|
+
event.systemPromptOptions.sections.git_signing_policy = SIGNING_POLICY;
|
|
64
|
+
});
|
|
65
|
+
|
|
28
66
|
pi.on("tool_call", (event) => {
|
|
29
67
|
if (!isToolCallEventType("bash", event)) return undefined;
|
|
30
|
-
if (
|
|
68
|
+
if (disablesSigning(event.input.command)) {
|
|
69
|
+
return { block: true, reason: SIGNING_BLOCK_REASON };
|
|
70
|
+
}
|
|
71
|
+
if (!/\bgit\b/i.test(event.input.command)) return undefined;
|
|
31
72
|
|
|
32
73
|
if (NO_VERIFY_RE.test(event.input.command)) {
|
|
33
74
|
return { block: true, reason: BLOCK_REASON };
|