Skip to content

fix: smooth the first local run - #235

Merged
camielvs merged 2 commits into
mainfrom
first-run-quick-fixes
Dec 3, 2026
Merged

camielvs merged 2 commits into
mainfrom
first-run-quick-fixes

Conversation

@camielvs

@camielvs camielvs commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Four small fixes for someone running the shell locally for the first time:

  • .env.example no longer ships a half-configured LLM gateway. It set PI_PROXY_URL to a placeholder and left PI_PROXY_API_KEY empty, so every .env copied from it was half-configured and the server quietly fell back to direct providers. Both lines are now commented out, with a note that they are only for routing through an LLM gateway and need to be set together.
  • Agents no longer load your personal pi setup. pi reads its config from ~/.pi/agent (global extensions, settings, model store, logins). Anyone who already uses pi had all of that loaded into every agent the shell starts; for example, a global extension that re-registered providers broke runs with a missing key. pnpm dev and start_local.sh now set PI_CODING_AGENT_DIR to a gitignored .pi-agent folder in the repo, the same way they already set the session, bundle and memory paths. An exported PI_CODING_AGENT_DIR still wins.
  • start_local.sh pins pi. It installed the latest @earendil-works/pi-coding-agent, while the Dockerfile pins 1.6.0. It now installs the same version, set in one PI_VERSION variable.
  • The example bundle's Tangle CLI commands actually run. The tangle-cli skill and the agent and prompt files told agents to run uv run tangle …, but nothing installs the CLI in the agent's workspace, so those commands failed. They now use uvx tangle-cli … (85 places in 12 files, mostly mechanical), which fetches the CLI from PyPI on first use and caches it.

Screenshots

N/A

How to test

  1. cp .env.example .env and start the server with only OPENAI_API_KEY (or ANTHROPIC_API_KEY) set. Agents use the direct provider, and no gateway values come from the template.
  2. With a personal ~/.pi/agent (for example a global extension), run pnpm dev, open a session and send a message. The extension is not loaded, and a .pi-agent/ folder appears in the repo. git status stays clean.
  3. PI_CODING_AGENT_DIR=~/.pi/agent pnpm dev loads your personal setup again.
  4. On a machine without pi on PATH, run ./start_local.sh. .pi/package.json lists @earendil-works/pi-coding-agent at 1.6.0.
  5. uvx tangle-cli --help and uvx tangle-cli sdk pipelines validate --help run without any install step.
  6. pnpm typecheck, pnpm lint, bash -n start_local.sh, pnpm pack:bundle and cd apps/server && pnpm test pass.

Not run: start_local.sh or pnpm dev end to end, or a real agent turn.

Notes

  • Behaviour change for existing pi users: anything stored under ~/.pi/agent no longer reaches the shell's agents. That includes logins and API keys saved by pi's own login flow (auth.json), custom models.json, settings.json defaults, global extensions, prompts and themes, and the fd/rg binaries pi manages (it may download them again into .pi-agent). Provider keys passed as environment variables work as before. Export PI_CODING_AGENT_DIR=~/.pi/agent to opt back in.
  • The .pi-agent change doesn't affect the Docker images: they already run with HOME=/tmp.
  • The pin only applies when start_local.sh installs pi itself. A pi already on PATH is still used as-is, and the server's startup version check still applies.
  • uvx tangle-cli needs uv where the agent runs and picks up the latest tangle-cli release on first use. The shipped Docker images don't include uv, so these commands don't run inside them yet (the old uv run tangle didn't either); the skill, Prime's prompt and the README prerequisites now say so.

🤖 Generated with Claude Code

- Comment out PI_PROXY_URL/PI_PROXY_API_KEY in .env.example; a copied .env no
  longer ships a half-configured gateway.
- Point Pi at a repo-local .pi-agent dir (PI_CODING_AGENT_DIR) in pnpm dev and
  start_local.sh so a personal ~/.pi/agent setup does not load into the
  shell's agents. An exported value still wins.
- Pin the pi version start_local.sh installs to the one the Dockerfile uses.
- Run the Tangle CLI in the example bundle with `uvx tangle-cli`, which needs
  no prior install, instead of `uv run tangle`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@camielvs
camielvs marked this pull request as ready for review December 1, 2026 16:32
@camielvs
camielvs requested a review from a team as a code owner December 1, 2026 16:32
@EdwardGallant

Copy link
Copy Markdown

🤖 AI-assisted review (worry pass + test validation). Generated by my review agents and read by me before posting. Nothing here is a blocker unless it says so.

Hi @camielvs. Before reviewing I ran my agents over the diff and what it depends on outside the repo: the tangle-cli package on PyPI, the two Dockerfiles, and how pi handles its agent dir. Nobody tophatted it or ran a real agent turn, so take this with a grain of salt.

Worth acting on

  1. The Docker images still can't run the bundle's uvx tangle-cli … commands, because neither image installs uv.
    The new text in examples/tangle-oss/skills/tangle-cli/SKILL.md:23 says "Nothing to install beyond uv". But Dockerfile:20-35 and Dockerfile.fullstack only install git, ripgrep, fd-find, jq and ca-certificates, plus pi and qmd through npm. Neither image has uv, Python or tangle-cli. The only uv-related setting in either image is ENV UV_SYSTEM_CERTS=true (Dockerfile.fullstack:142), which suggests someone expects uv to run there, but nothing installs it. This isn't a regression, since the old uv run tangle couldn't run there either. Still, the PR's notes read as if the images are covered: "Docker images are unaffected: they already run with HOME=/tmp." That sentence is about the agent dir, but next to "The example bundle's Tangle CLI commands actually run", a reader may assume the CLI works in the container too.
    Suggest: either install uv in both images (for example COPY --from=ghcr.io/astral-sh/uv, or an apt/pipx step), or add a line to the PR notes and SKILL.md saying the CLI commands need uv on the host and don't work in the shipped images yet.
Checked and fine · what was run · not checked

What was run

  • From your "How to test" list: pnpm typecheck exited 0. pnpm lint had 0 errors and 5 max-lines-per-function warnings that were already there. bash -n start_local.sh was OK. I skipped pnpm pack:bundle.
  • cd apps/server && pnpm test: 848 tests ran and 1 failed, the same one both times. It's "server and local Pi extensions register the same deployment models" at apps/server/src/modelCatalog.test.ts:92. It fails the same way on the base commit 3e82ae54 (one side has compat: undefined), so this PR didn't cause it. Your notes say pnpm test passes, so you may want to compare your local install against a fresh one.
  • No mutation testing, because the PR doesn't add or change any tests. That means no test covers pnpm dev and start_local.sh passing PI_CODING_AGENT_DIR through, an exported value still winning, or start_local.sh installing pi at 1.6.0.
  • Nobody ran start_local.sh or pnpm dev end to end, same as in your notes.

Checked and fine

  • uvx tangle-cli reaches the same CLI as uv run tangle: fine. tangle-cli 0.1.34 on PyPI ships both a tangle and a tangle-cli script pointing at tangle_cli.cli:main. All 17 command forms the diff writes print --help, and api pipeline-runs list --help works without [native]. Only --help was run, with no backend.
  • PI_PKG now carries a version: fine. All four uses in start_local.sh (lines 33, 98, 104, 105) are an install spec or a log line, and the pi binary is found by a path that doesn't include the package name. I only read the script and didn't run it.

Good to know

  • Shopify's uv mirror and tangle-cli: good to know. With Shopify's default uv config, the internal mirror returned HTTP 400 for tangle-cli. Plain uvx only worked with UV_NO_CONFIG=1 and the public PyPI index.

Not checked

  • The server actually forwarding PI_CODING_AGENT_DIR to the pi child, and not reading ~/.pi/agent itself: not checked.
  • Existing local sessions stored under ~/.pi/agent/sessions still reopening after the switch: not checked.
  • Setups that relied on ~/.pi/agent (trust.json, auth.json OAuth, models.json) now failing a turn while the credential check still says OK: not checked.
  • uvx's isolated env vs sdk components generate from-python, which may need to import the user's dependencies: not checked.
  • Unpinned uvx tangle-cli letting machines drift onto different CLI releases (submit/publish): not checked.
  • uv run tangle text surviving outside the 12 edited files (seeded .agent-bundles, live session prompts, the designer role): not checked.
  • First-use cost inside a turn (pi re-downloading fd/rg into .pi-agent/bin, a cold uv cache) and tool timeouts: not checked.
  • Personal setup leaking in by other routes (--env-mode=loose passing PI_* vars, a .pi/ in the cwd): not checked.
  • Dev watchers or lint picking up files pi writes into .pi-agent: not checked.
  • An absolute .pi-agent path reused in another worktree, or a relative override: not checked.
  • The 1.6.0 pin drifting from the Dockerfile string, and existing .pi/ installs never picking up the pin: not checked.
  • Existing .env copies keeping the half-set gateway, and the README rows next to fix(server): warn at startup when only half of the LLM gateway is configured #236's: not checked.
  • The new turbo.json env entry changing task hashes: not checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@camielvs

camielvs commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

🤖 This is an AI-generated response.

Thanks @EdwardGallant.

  • uv in the Docker images: fixed the wording in 1f48fa2. The tangle-cli skill, Prime's prompt and the README prerequisites now say the commands need uv where the agent runs and that the shipped images don't include it yet. I also corrected the PR notes, where "Docker images are unaffected" was only about the .pi-agent change. Installing uv in both images is left for a follow-up.
  • modelCatalog.test.ts:92 failing: couldn't reproduce. "server and local Pi extensions register the same deployment models" passes on fresh installs of both this branch and fix(server): warn at startup when only half of the LLM gateway is configured #236, both based on main at 3e82ae5. It may depend on the local install or an older base.

camielvs added a commit that referenced this pull request Dec 2, 2026
The "smooth the first local run" PR (#235) comments out both LLM gateway
lines in .env.example, which is the better fix for the same placeholder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
camielvs added a commit that referenced this pull request Dec 3, 2026
…or it (#242)

* fix: start the local shell on port 5173, where the Tangle app looks for it

start_local.sh served the UI on 9010, but the Tangle app looks for a
local shell at 5173, so following both quick starts left "Tangent isn't
reachable". The README gets a "Connect an LLM" section and loses two
typos, and .env.example no longer sets a placeholder PI_PROXY_URL that a
copied .env would hand to every agent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: leave .env.example to the first-run fixes

The "smooth the first local run" PR (#235) comments out both LLM gateway
lines in .env.example, which is the better fix for the same placeholder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@camielvs
camielvs merged commit 72f927e into main Dec 3, 2026
10 checks passed
@camielvs
camielvs deleted the first-run-quick-fixes branch December 3, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants