{"slug": "pi-change-directories-mid-session", "title": "pi: change directories mid-session", "summary": "Pi 0.82.1, the interactive coding agent from earendil-works, cannot change its working directory mid-session, as commands like `cd` run in child processes and no built-in `/cd` exists. The maintainer, @badlogic, has closed multiple feature requests for runtime cwd changes, citing the need for a large refactor, and the new extension API promised in issue #4423 is still not available in 0.82.1. Users must quit and restart Pi in the desired directory.", "body_md": "♠ **Today I learned**: [pi](https://pi.dev/) 0.82.1 cannot change its working\ndirectory mid-session.\n\nThe interactive shell syntax looks tempting, but `!`\n\nand `!!`\n\nrun commands in a\nchild process. `cd`\n\nends with that process; Pi keeps the session’s original cwd.\nThere is no built-in `/cd`\n\neither:\n\n```\n% pi --version\n0.82.1\n% docs=\"$(brew --prefix pi-coding-agent)/libexec/lib/node_modules/@earendil-works/pi-coding-agent/docs\"\n% rg -n 'ctx\\.(newSession|switchSession|changeCwd|switchCwd)' \"$docs/extensions.md\"\n1109:### ctx.newSession(options?)\n1117:const result = await ctx.newSession({\n1187:### ctx.switchSession(sessionPath, options?)\n1192:const result = await ctx.switchSession(\"/path/to/session.jsonl\", {\n1220:      await ctx.switchSession(choice, {\n1247:    await ctx.newSession({\n1262:    await ctx.newSession({\n% rg -n '^\\| `/[^|]+`' \"$docs/usage.md\" | tail -5\n56:| `/share` | Upload as private GitHub gist with shareable HTML link |\n57:| `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |\n58:| `/hotkeys` | Show all keyboard shortcuts |\n59:| `/changelog` | Display version history |\n60:| `/quit` | Quit pi |\n```\n\nThis has been requested several times upstream:\n\n```\n% for n in 2102 2992 3921 4423 6997; do\n    gh issue view \"$n\" --repo earendil-works/pi \\\n      --json number,title,state,stateReason \\\n      --jq '[.number, .title, .state, .stateReason] | @tsv'\n  done\n2102\tAllow extensions to change cwd at runtime\tCLOSED\tCOMPLETED\n2992\tAllow session CWD to be changed\tCLOSED\tCOMPLETED\n3921\tFeature request: ExtensionCommandContext.changeCwd() for lightweight cwd switching\tCLOSED\tNOT_PLANNED\n4423\tAdd command API to switch cwd\tCLOSED\tCOMPLETED\n6997\tWindows Bash inside Pi not working properly\tCLOSED\tNOT_PLANNED\n```\n\nThe exact `/cd`\n\nproposal lives in\n[#3921](https://github.com/earendil-works/pi/issues/3921). The maintainer\nresponses on [#2102](https://github.com/earendil-works/pi/issues/2102),\n[#2992](https://github.com/earendil-works/pi/issues/2992), and\n[#4423](https://github.com/earendil-works/pi/issues/4423) capture the trade-off:\n\n```\n#2102 @badlogic: use case makes sense, however, it can be done by overriding the built-in tools to support cwd changes.\n#2992 @badlogic: setting a new cwd in a session is not great, as a bunch of things need to be rewired. currently unsupported.\n#4423 @badlogic: this is part of the big refactor work and will be available in the new extension api.\n```\n\nThat last API still is not exposed in 0.82.1. Changing cwd means rebuilding tools,\nproject settings, extensions, skills, context files, autocomplete, footer state,\nand session storage—not merely calling `process.chdir()`\n\n.\n\nFor now, the boring path is the supported one:\n\n```\n/quit\n% cd ~/Workspace/perrotta.dev\n% pi\n```\n\nSession cwd is a runtime boundary. Oh well.\n\n🤖 *Drafted with *\n\n`/bloggify`\n\n.— § —\n\nReply via [email](mailto:serendipity@perrotta.dev?subject=Reply to: pi: change directories mid-session)", "url": "https://wpnews.pro/news/pi-change-directories-mid-session", "canonical_source": "https://perrotta.dev/2026/07/pi-change-directories-mid-session/", "published_at": "2026-07-29 12:13:03+00:00", "updated_at": "2026-08-04 09:04:03.102063+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["pi", "earendil-works", "@badlogic"], "alternates": {"html": "https://wpnews.pro/news/pi-change-directories-mid-session", "markdown": "https://wpnews.pro/news/pi-change-directories-mid-session.md", "text": "https://wpnews.pro/news/pi-change-directories-mid-session.txt", "jsonld": "https://wpnews.pro/news/pi-change-directories-mid-session.jsonld"}}