pi-ext bugabingas pi extensions
owned by bugabinga
README Source History Refs Compare Notes Search fix(nushell): reject unusable PATH entries on activation
021491b47c9295cc3c25c6f8dde6bb1e1d9932f5
Oliver Jan Krylow <oliver@bugabinga.net > · 27 Sep 2026
SSH signature · not checked
Browse files Compare with HEAD
Changed files (3) extensions/nushell/__tests__/harness.test.ts Modified 93 + it (
"keeps shell tools active and warns when PATH has no executable Nu" ,
async ()
=> {
94 + t
= await createTestSession ({ extensions: [extensionPath] });
95 + root = mkdtempSync (path.
join (
process .
cwd (),
".pi/tmp/nushell-path-" ));
96 + mkdirSync (path.
join (
root ,
process .
platform === "win32" ? "nu.exe" : "nu" ));
98 + const runner
= t.session.extensionRunner;
99 + const initial
= t.session.
getActiveToolNames ();
100 + runner.
setFlagValue (
"nushell" ,
true );
101 + await runner.
emit ({ type:
"session_start" , reason:
"startup" });
102 + expect (t.session.
getActiveToolNames ()).
toEqual (initial);
103 + expect (t.events.
uiCallsFor (
"notify" ).
at (
- 1 )?.args).
toEqual ([
104 + "Nushell executable not found on PATH; tools unchanged" ,
108 + .
getCommand (
"nushell" )
109 + ?.
handler (
"on" , runner.
createCommandContext ());
110 + expect (t.session.
getActiveToolNames ()).
toEqual (initial);
111 + expect (t.events.
uiCallsFor (
"notify" ).
at (
- 1 )?.args).
toEqual ([
112 + "Nushell executable not found on PATH; tools unchanged" ,
93 117 it (
"registers --nushell to enable both tools on session start" ,
async ()
=> {
94 118 t
= await createTestSession ({ extensions: [extensionPath] });
95 119 const runner
= t.session.extensionRunner;
141 165 for (
const name
of [
"nu" ,
"nu_session" ]) {
142 166 const tool
= tools?.
get (name)?.definition;
167 + const icon
= name
=== "nu" ? "" : "" ;
168 + expect (tool?.
label ).
toBe (
`${icon} ${name === "nu" ? "nu" : "nu session"}` );
143 169 const context
= {
145 171 executionStarted:
false ,
193 219 '<syntaxString>"safe"</syntaxString>' ,
195 221 expect (palette).
toContain (token);
196 - expect (lines).
toContain (name
=== "nu" ? "nu>" : "nu session>" );
222 + expect (lines).
toContain (
`${icon} ${name === "nu" ? "nu>" : "nu session>"}` );
197 223 const result
= tool?.
renderResult ?.(
extensions/nushell/index.ts Modified 184 184 pi.
registerTool ({
189 189 "Execute Nushell commands in a fresh process in Pi's cwd. Syntax is Nushell, not Bash or PowerShell. Each call has independent variables, functions, environment, and cwd. Streams output; timeout in seconds is optional." ,
194 194 "Use Nushell syntax: structured pipelines, $env.NAME, (command), o> file or save. Use try/catch for expected command failures." ,
196 196 renderCall : (args, theme, context)
=> 197 - renderNuCall (args, theme, context,
"nu>" ),
197 + renderNuCall (args, theme, context,
" nu>" ),
200 200 pi.
registerTool ({
201 201 name:
"nu_session" ,
202 - label:
"nu session" ,
202 + label:
" nu session" ,
204 204 "Evaluate Nushell in a persistent session. Variables, functions, environment, and cwd survive subsequent nu_session calls; nu calls stay independent. Prefer nu unless state must persist. MCP captures expression results as NUON; use ^command | complete and inspect exit_code for external status. Do not rely on print: MCP uses stderr for diagnostics." ,
220 220 return { content: [{ type:
"text" , text }], details:
undefined };
222 222 renderCall : (args, theme, context)
=> 223 - renderNuCall (args, theme, context,
"nu session>" ),
223 + renderNuCall (args, theme, context,
" nu session>" ),
224 224 renderResult : freshTool.renderResult,
extensions/nushell/runtime.ts Modified 1 1 import { spawn }
from "node:child_process" ;
2 - import { constants, existsSync }
from "node:fs" ;
2 + import { accessSync, constants, statSync }
from "node:fs" ;
3 3 import { access }
from "node:fs/promises" ;
4 4 import { delimiter, join }
from "node:path" ;
5 5 import type { BashOperations }
from "@earendil-works/pi-coding-agent" ;
32 32 if (
! directory)
continue ;
33 33 for (
const name
of names) {
34 34 const candidate
= join (directory, name);
35 - if (
existsSync (candidate))
return candidate;
36 + if (
! statSync (candidate).
isFile ())
continue ;
37 + if (
process .
platform !== "win32" )
accessSync (candidate, constants.X_OK);