pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Compare Notes Search fix(git-safe): preserve policy across PATH changes
963fe2ca5f239ed57863fa4c580494708699e2c7
Oliver Krylow <o.krylow@isp-insoft.de > · 19 Aug 2026
SSH signature · not checked
Browse files Compare with HEAD
Changed files (4) 62 62 - Fix RTK rewriting so `find` commands keep exact path semantics unless RTK passes a path capability probe, and notify users when rewrites are disabled or the compatibility guard can be removed
63 63 - Replace the tmux-only terminal skill with a terminal harness for observable TUI testing through tmux or WezTerm
64 64 - Harden git-safe against hook-skipping Git options through aliases, shell indirection, nested Bash, `xargs`, and child-process PATH lookup, including Git Bash on Windows
65 + - Fix git-safe startup on Windows when commands clear or replace `PATH`
65 66 - Fix git-safe cloning on Windows so valid deep destination paths are accepted
66 67 - Fix Overkill's Aftermath skill picker so large skill lists scroll within the terminal
67 68 - Fix Overkill Aftermath completion when mining finds insufficient tasks so it offers report-only actions and shows consistent artifact paths
extensions/git-safe/__tests__/harness.test.ts Modified 31 31 return path.
resolve (
import .
meta .dirname,
"../../rtk/index.ts" );
34 - function installFakeGit (root
: string )
: string {
34 + function installFakeGit (root
: string )
: { bin
: string ; executable
: string } {
35 35 const bin
= path.
join (
root ,
"fake-bin" );
37 + if (
process .
platform === "win32" ) {
38 + const gitExe
= path.
join (bin,
"git.exe" );
39 + copyFileSync (
process .
execPath , gitExe);
40 + const implementation
= path.
join (
root ,
"fake-git.cjs" );
44 + 'const path = require("node:path");' ,
45 + "const command = path.basename(process.argv[1]);" ,
46 + "const args = process.argv.slice(2);" ,
47 + "if (command === 'config' && args.includes('--get')) process.exit(1);" ,
48 + "process.stdout.write('FAKE_GIT\\n');" ,
49 + "process.stdout.write(`ARGS:<${[command, ...args].join('><')}>\\n`);" ,
50 + "process.stdout.write(`EDITOR=<${process.env.GIT_EDITOR ?? ''}> SEQUENCE=<${process.env.GIT_SEQUENCE_EDITOR ?? ''}> MERGE=<${process.env.GIT_MERGE_AUTOEDIT ?? ''}>\\n`);" ,
55 + for (
const command
of [
71 + path.
join (
root , command),
72 + `require(${ JSON . stringify (implementation)});\n` ,
76 + return { bin, executable: gitExe };
37 79 const git
= path.
join (bin,
"git" );
52 94 chmodSync (git,
0o755 );
53 - const gitExe
= path.
join (bin,
"git.exe" );
54 - writeFileSync (gitExe,
readFileSync (git));
55 - chmodSync (gitExe,
0o755 );
95 + return { bin, executable: git };
59 98 function installFakeRtk (bin
: string )
: void {
99 138 async function startWithFakeGit (useRtk
= false )
: Promise <
void > {
100 139 root = mkdtempSync (path.
join (
tmpdir (),
"pi-git-safe-test-" ));
101 - const fakeBin
= installFakeGit (
root );
102 - if (useRtk)
installFakeRtk (fakeBin);
103 - fakeGit
= path.
join (fakeBin,
"git" );
140 + const installed
= installFakeGit (
root );
141 + if (useRtk)
installFakeRtk (installed.bin);
142 + fakeGit
= installed.executable;
104 143 t
= await createTestSession ({
106 - env: { PATH:
`${fakeBin}${path.delimiter}${ process . env .PATH}` },
145 + env: { PATH:
`${installed.bin}${path.delimiter}${ process . env .PATH}` },
107 146 extensions: useRtk
? [
gitSafePath (),
rtkPath ()]
: [
gitSafePath ()],
140 179 async function expectRejected (command
: string )
: Promise <
void > {
141 180 const result
= await execute (command);
142 - expect (result.output).
toContain (
"git-safe blocked --no-verify" );
143 - expect (result.output).not.
toContain (
"FAKE_GIT" );
181 + expect (result.output, command).
toContain (
"git-safe blocked --no-verify" );
182 + expect (result.output, command).not.
toContain (
"FAKE_GIT" );
146 185 it (
"loads in real Pi extension runtime" ,
async ()
=> {
249 288 it (
"permits no-verify when Git treats it as data" ,
async ()
=> {
250 289 await startWithFakeGit ();
252 - for (
const command
of [
253 292 "git add -- --no-verify" ,
254 293 "git grep -e --no-verify" ,
255 294 "git commit -m --no-verify" ,
270 309 "command git commit -m 'Document --no-verify usage'" ,
271 310 'env -i PATH="$PATH" git status' ,
272 311 "GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=alias.nv GIT_CONFIG_VALUE_0='commit --no-verify' git -c alias.nv=status nv" ,
273 - "GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=alias.status GIT_CONFIG_VALUE_0='commit --no-verify' git status" ,
312 + "GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=alias.commit GIT_CONFIG_VALUE_0='rebase --no-verify' git commit -m safe" ,
314 + if (
process .
platform !== "win32" ) {
316 + "GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=alias.status GIT_CONFIG_VALUE_0='commit --no-verify' git status" ,
319 + for (
const command
of commands) {
275 320 const result
= await execute (command);
276 321 expect (result.blocked, command).
toBeUndefined ();
277 - expect (result.output, command).
toContain (
"FAKE_GIT" );
322 + if (
process .
platform !== "win32" || ! command.
includes (
"git -c " )) {
323 + expect (result.output, command).
toContain (
"FAKE_GIT" );
extensions/git-safe/git-policy.ts Modified 65 - template.
replace (
'"__PI_GIT_SAFE_REAL_GIT__"' ,
JSON .
stringify (realGit)),
66 + .
replace (
/ ^ #![ ^ \r\n] * / u ,
`#!${ bashPath ( process . execPath )}` )
67 + .
replace (
'"__PI_GIT_SAFE_REAL_GIT__"' ,
JSON .
stringify (realGit)),
68 70 await chmod (wrapper,
0o755 );
49 49 const BASE_ENV_KEYS
= [
84 83 env.XDG_DATA_HOME
= path.
join (
root ,
".test-data" );
86 85 for (
const [key, value]
of Object .
entries (options.env
?? {})) {
87 - if (value
=== undefined )
delete env[key];
88 - else env[key]
= value;
86 + setEnvValue (env, key, value);
200 198 from : NodeJS.ProcessEnv,
203 - const value
= from[key];
204 - if (value
!== undefined ) to[key]
= value;
202 + process .
platform === "win32" 203 + ? Object .
keys (from).
find (
204 + (candidate)
=> candidate.
toLowerCase ()
=== key.
toLowerCase (),
207 + if (
! sourceKey)
return ;
208 + setEnvValue (to, sourceKey, from[sourceKey]);
211 + function setEnvValue (
212 + env
: NodeJS .
ProcessEnv ,
214 + value
: string | undefined ,
216 + if (
process .
platform === "win32" ) {
217 + for (
const candidate
of Object .
keys (env)) {
218 + if (candidate.
toLowerCase ()
=== key.
toLowerCase ())
delete env[candidate];
223 + if (value
!== undefined ) env[key]
= value;