fleet-pi
AGENTS.md5 starsChanged 4 months agoApache-2.0View on GitHub
The repository includes a VS Code devcontainer configuration at .devcontainer/devcontainer.json with Node.js, pnpm, Git, and recommended editor extensions. Open the project in a devcontainer to get a fully pre-configured development environment. Port 3000 is forwarded automatically and pnpm install runs after container creation.
- Reads credentials
In this repository3 other files it gives its agents.
- agent-workspace/AGENTS.mdAGENTS.md
- agent-elementsSkill
- openuiSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
27 rules. About 0 are common, 3 are distinctive, and 24 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
24
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 5
Use pnpm from the repository root for dependency and task commands.
- Very specific: line 7
Run workspace commands with pnpm --filter <workspace> <script> when only one package is affected.
- Very specific: line 15
Run unit tests with pnpm test.
- Very specific: line 16
Run end-to-end tests with pnpm e2e.
- Very specific: line 17
Check dependency version consistency with pnpm syncpack.
- Very specific: line 26
Verify Vercel deployment readiness with pnpm verify-deployment-readiness (set migration URLs to validate Neon grants/RLS).
- Very specific: line 39
When doc-generation sources change, run pnpm generate:docs.
- Very specific: line 72
Do not add React components under apps/web/src/components/.
- Very specific: line 94
Use resource_install for chat-driven Pi resource installs.
- Very specific: line 97
When FLEET_PI_CHAT_DATABASE_URL is set, Fleet Pi mirrors full Pi session entries, run events, tool executions, and file mutations into Neon …
- Very specific: line 110
Ask read package.json and verify a Read tool card appears.
- Very specific: line 111
Ask create a small temp file under this repo and verify Write renders and the file is created inside the repo.
- Very specific: line 112
Ask edit that temp file and verify Edit renders a diff.
- Very specific: line 113
Ask run pnpm --version and verify Bash renders command and output.
- Very specific: line 119
After a plan, choose Execute and verify the app switches to Agent mode, full tools are available, and [DONE:n] progress updates the plan …
- Very specific: line 125
Keep floating pill-style header chrome.
- Distinctive: line 126
When executing an attached implementation plan, do not edit the plan file.
- Very specific: line 127
Avoid inline style props in Fleet Pi UI.
- Very specific: line 128
Keep ChatWorkspace header panel tabs (Pi Resources, Workspace, Artifacts) inline when panels are open.
- Very specific: line 129
Prefer semantic tokens in fleet-pi/styles/tokens.ts and primitives in fleet-pi/primitives/ (especially ItemRow variants) over nested card …
- Distinctive: line 130
Avoid generic AI SaaS aesthetics (cream backgrounds, gradient heroes, card grids) and heavy IDE-style dense toolbars unless explicitly …
- Distinctive: line 131
Keep the chat column a single full-width transcript plus InputBar.
- Very specific: line 134
Use Playwright testInfo.outputPath() for E2E screenshots and artifacts instead of hardcoded machine-specific paths.
- Very specific: line 135
Prefer Neon Managed Auth cutover (neon_auth identity + pi_* tenancy RLS) over RLS-hardening legacy public Better Auth leftovers as a …
- Very specific: line 157
Use autoctx capabilities to inspect supported commands and project state.
- Very specific: line 158
Use autoctx whoami to confirm provider credentials before running evaluations.
- Very specific: line 159
Run autoctx run from this directory to use the defaults stored in .autoctx.json.
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Project Conventions
- Use
pnpmfrom the repository root for dependency and task commands. - The root
pnpm-lock.yamlis the canonical lockfile; do not create nested app lockfiles. - Run workspace commands with
pnpm --filter <workspace> <script>when only one package is affected.
Validation
- Install/update dependencies with
pnpm install. - Type-check with
pnpm typecheck. - Lint with
pnpm lint. - Build with
pnpm build. - Run unit tests with
pnpm test. - Run end-to-end tests with
pnpm e2e. - Check dependency version consistency with
pnpm syncpack. - Auto-fix dependency version drift with
pnpm syncpack:fix. - Detect unused exports and dependencies with
pnpm knip. - Detect duplicate code with
pnpm jscpd. - Scan for tech debt markers with
pnpm tech-debt. - Validate AGENTS.md commands with
pnpm validate-agents-md. - Analyze bundle size with
pnpm build --filter webthen openapps/web/bundle-report/stats.html. - Apply Neon chat mirror migrations with
pnpm chat:migrateafter settingFLEET_PI_CHAT_MIGRATION_DATABASE_URL. - Link the existing Neon project with
neon link, pin a branch withneon checkout, then provision services from repo-rootneon.tsviapnpm neon:deploy(orneon deploy --env .env.local --update-existing --allow-protected).neon deployprovisions Auth, buckets, and Functions only—runpnpm auth:migrateandpnpm chat:migrateseparately for schema. Pull branch env withpnpm neon:env-pull, then verify withpnpm neon:verify. - Verify Vercel deployment readiness with
pnpm verify-deployment-readiness(set migration URLs to validate Neon grants/RLS). - Quarantine legacy ownerless mirror rows with
pnpm quarantine-orphan-sessions(owner URL required; use--purgeonly after approval). - Remap
pi_*ownership after Neon Managed Auth cutover withpnpm remap-auth-user-ids -- --file=remap.csv(email,oldUserId,newUserIdor legacyemail,newUserIdwhenpublic."user"still exists;--dry-runfirst). - Validate the Vercel build output with
NITRO_PRESET=vercel pnpm --filter web build:vercelwhen deployment routing changes.
Public Docs & Community Health
README.mdis the public landing page. Keep it concise, user-focused, and centered on the recommended standalone path.docs/README.mdis the docs hub and the recommended entrypoint for the human-facing docs set.docs/quickstart.mdis the primary onboarding doc for setup and local verification.docs/agent-workspace.mdexplains howagent-workspace/acts as Fleet Pi's durable adaptive layer.docs/api.md,docs/project-structure.md, anddocs/architecture.mdare secondary reference docs. If they drift, fix the generator or its source inputs rather than hand-waving around stale output.CONTRIBUTING.md,CODE_OF_CONDUCT.md,SECURITY.md, and the issue templates are part of the public repository surface and should stay aligned with actual maintainer workflow.- When doc-generation sources change, run
pnpm generate:docs. When command examples or AGENTS instructions change, runpnpm validate-agents-md.
Devcontainer
The repository includes a VS Code devcontainer configuration at .devcontainer/devcontainer.json with Node.js, pnpm, Git, and recommended editor extensions. Open the project in a devcontainer to get a fully pre-configured development environment. Port 3000 is forwarded automatically and pnpm install runs after container creation.
Vercel Deployment
- The
fleet-pi-webVercel project builds fromapps/web; keep Vercel-specific settings inapps/web/vercel.json. - Vercel builds run
NITRO_PRESET=vercel pnpm build:vercel; TanStack Start emitsdist/, thenapps/web/scripts/build-vercel-output.mjspackages it into.vercel/output. - Better Auth on Vercel requires
BETTER_AUTH_SECRET,BETTER_AUTH_URL,BETTER_AUTH_TRUSTED_ORIGINS, andFLEET_PI_AUTH_DATABASE_URLwhen not using Neon Managed Auth. With Neon Managed Auth (NEON_AUTH_BASE_URLor Vercel↔NeonNEON_AUTH_URL), useNEON_AUTH_COOKIE_SECRET,VITE_NEON_AUTH_URL,NEON_AUTH_JWKS_URL,NEON_AUTH_ISSUER(required so bearer JWTs fail closed), and consolidateFLEET_PI_AUTH_DATABASE_URLwithFLEET_PI_CHAT_DATABASE_URLonfleet-pi-neon(also linked to Vercel + GitHub). Under Managed Auth,BETTER_AUTH_SECRETis still required for BYOK provider AES-GCM encryption (cookie gate prefersNEON_AUTH_COOKIE_SECRET). Local anonymous/SQLite Better Auth applies only when neither Neon Auth URL is set. - BYOK provider credentials and Pi session mirroring on Vercel also require
FLEET_PI_CHAT_DATABASE_URL. Runpnpm chat:migrateafter deploy when schema changes affectpi_user_providers(for examplegoogle-genai→googleremap). - On Vercel, Pi project settings overrides (skills/packages/models/paths) persist in Neon
pi_user_settings(not writable.pi/settings.json). Fleet base defaults (packages, skill commands) live in code (fleet-default-project-settings.ts) and merge at runtime — but carry nodefaultProvider/defaultModel/enabledModels: the user chooses the provider and model in Settings. Fleet base ships no models enabled; user overrideenabledModels: []is deny-all. Settings paths must be portable (no/Users/…absolutes)..vercelignoreships.pi/{skills,extensions,settings.json}and skips.pi/npmplus heavyagent-workspace/{indexes,artifacts,scratch,evals}. PATCH /api/chat/settingsrequires authentication on Vercel; settings hot-reload applies only to the signed-in user's active sessions. Vercel Preview deployments needBETTER_AUTH_SECRET,FLEET_PI_AUTH_DATABASE_URL, andFLEET_PI_CHAT_DATABASE_URLscoped to Preview (not only feature-branch aliases). Runpnpm chat:migratewithFLEET_PI_CHAT_MIGRATION_DATABASE_URLafter schema or ownership-probe changes.GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare Better Auth OAuth credentials. Register the production callback ashttps://fleet-pi-web.vercel.app/api/auth/callback/google.- Daytona on Vercel requires each authenticated user's BYOK Daytona API key (
daytonainpi_user_providers); org Daytona keys andDAYTONA_API_KEYmust not back end-user sandboxes. Local/dev may useDAYTONA_API_KEYonly. Optional:DAYTONA_TARGET,DAYTONA_API_URL,DAYTONA_WEBHOOK_SECRET,FLEET_PI_REPOSITORY_URL.
Pre-commit Hooks
The repository uses Husky + lint-staged to enforce code quality before every commit.
- The pre-commit hook is registered at
.husky/pre-commitand runspnpm exec lint-staged. git config core.hooksPathmust return.husky.- Staged files are automatically processed:
- Prettier (
prettier --write) runs on*.{ts,tsx,js,jsx,json,css,md} - ESLint (
eslint --fix) runs on{apps,packages}/**/*.{ts,tsx,js,jsx}
- Prettier (
- Commits are blocked if ESLint reports errors that cannot be auto-fixed.
- The root
eslint.config.jsdelegates to workspace configs so lint-staged works from the repository root.
Architecture Notes
apps/webis a TanStack Start app. File routes are generated intoapps/web/src/routeTree.gen.ts; do not edit that generated file manually.packages/hax-designis the shadcn-style registry (components.json, primitives,agent-elements/, generative UI incomponents/openui/, Fleet Pi UI undercomponents/fleet-pi/). Import from@workspace/hax-design/*in apps; use relative imports inside the package. UI registries:@shadcn(base-nova primitives),@agent-elements(chat; owned fork underagent-elements/),@fluid(motion; wire-only unless explicitly adopting controls). Add components withpnpm dlx shadcn@latest add <name> -c packages/hax-designonly — never emit UI intoapps/web.- Do not add React components under
apps/web/src/components/. All UI goes inpackages/hax-design. Routes may only compose hax-design exports. OpenUI library/registry code must live incomponents/openui/, not inapps/web. - Chat UI types live in
packages/hax-design/src/components/agent-elements/chat-types.ts.
AI Integration
- The chat backend uses
@earendil-works/pi-coding-agentv0.82.1 on top of@earendil-works/pi-ai, not Vercel AI SDK. - Pi 0.82.1 extensions can access
ctx.mode(tui/rpc/json/print) andctx.getSystemPromptOptions()for context-aware behavior. BYOK usesservices.modelRuntime(setRuntimeApiKey/getRuntimeApiKey). Follow-up queues wait foragent_settled. - The platform LLM backend for authenticated deploys is Neon AI Gateway via Pi's
openai-chat-completionsprovider (model idsqwen35-122b-a10bandgpt-oss-120bare available to pick; gateway rejectsmax_tokensabove 25_000). No provider/model is pre-selected — the user configures one in Settings. Local anonymous chat uses env/BYOK providers instead. User BYOK OCC replaces the Gateway OCC registration when configured. - The chat API route is
apps/web/src/routes/api/chat.ts. apps/web/src/lib/app-runtime.tsresolves the active runtime context, falling back to this repo root.- Shared browser-safe chat protocol types and Zod schemas live in
@workspace/pi-protocol(packages/pi-protocol/src/chat-protocol.ts,chat-protocol.zod.ts);packages/hax-design/src/lib/pi/*keeps only non-protocol helpers such aschat-helpers.ts. Server-only Pi integration is centralized inapps/web/src/lib/pi/runtime/(session factory, settings bridge, model/resource/provider catalogs, hot reload) withapps/web/src/lib/pi/server.tsas the route-facing barrel. - The browser chat client consumes newline-delimited JSON events from
/api/chat. /api/chatis session-based: the client sends a singlemessageplus optional PisessionFile/sessionIdmetadata, and the server resumes or creates a persistent Pi session.- Supporting chat endpoints are
/api/chat/models,/api/chat/models/discover,/api/chat/resources,/api/chat/settings,/api/chat/providers,/api/chat/commands,/api/chat/session,/api/chat/sessions,/api/chat/new,/api/chat/resume,/api/chat/abort,/api/chat/question,/api/chat/runs,/api/chat/run,/api/chat/provenance,/api/workspace/tree,/api/workspace/file,/api/workspace/item,/api/workspace/items,/api/workspace/search,/api/workspace/reindex, and/api/workspace/health. - The server keeps live Pi
AgentSessionRuntimeinstances in memory for a short TTL (FLEET_PI_RUNTIME_TTL_MS, default 10 minutes) so aborts and queued follow-ups operate on the same runtime. Invalid, outside, or missing session files must still start a fresh project-scoped session for the active runtime context. - The web chat enables Pi's built-in
read,write,edit, andbashtools scoped to the activeprojectRoot. File paths and bash cwd must remain project-scoped. Tool execution is direct in v1; there is no approval gate. - Pi tool execution events are normalized into existing agent-elements tool parts (
tool-Read,tool-Write,tool-Edit,tool-Bash) for rendering. - The chat InputBar includes Agent, Plan, and Harness mode selectors. Agent mode enables the normal coding tools plus approved external Pi tools; Plan mode enables read-only
read,bash,grep,find,ls,questionnaire,project_inventory,workspace_index, and safe Autocontext status tools only; Harness mode enables evaluation-oriented tools with workspace writes. - Plan mode is implemented in
apps/web/src/lib/pi/plan-mode.tsas a web-native Pi extension. It injects read-only planning instructions, blocks unsafe bash commands, extracts numberedPlan:steps, persists plan state in the Pi session, and usestool-Questionparts plus/api/chat/questionfor InputBar question prompts and plan execute/refine/stay decisions. - The Pi resources browser in
apps/web/src/routes/index.tsxfetches/api/chat/resourcesand surfaces discovered skills, prompts, extensions, themes, context files, and diagnostics. It opens as a resizable right-side canvas that opens at 70% viewport width and clamps resizing to that maximum; mobile open state is a compact overlay. The canvas has read-onlyWorkspaceandArtifactstabs backed by workspace APIs. Pi settings, providers, LLM models, skills, appearance, and sandbox controls live in the Settings dialog (not the right panel). apps/web/src/lib/workspace/server.tsowns theagent-workspace/layout, creates seeded Markdown stubs without overwriting existing files, returns a sorted read-only filesystem tree, and safely previews file contents for paths inside the activeworkspaceRoot.- Fleet Pi's repo-local agent home is
agent-workspace/: durable skills, tool context, memory, plans, evals, artifacts, and extension orientation should be discoverable there. Chat-installed Pi runtime resources live underagent-workspace/pi/{skills,prompts,extensions,packages}. Root.pi/settings.jsonremains the Pi compatibility bridge for user/workspace overrides; Fleet base defaults merge from code at runtime. - Use
resource_installfor chat-driven Pi resource installs. Skills/prompts become usable after reload/new session; executable extensions and package bundles are staged unless the user explicitly asks to activate them. In v1, "plugins" means Pi resource packages/bundles, not Codex or Claude plugin bundles. - Canonical durable project memory lives in
agent-workspace/memory/project/{architecture,decisions,preferences,open-questions,known-issues}.md. Normal "remember this" requests should update the narrowest canonical file; ad hoc project-memory files are only for explicit user requests, temporary harness tests, or raw material that will later be synthesized. - Pi sessions are persistent JSONL sessions. Browser mode stores only Pi session metadata in localStorage and hydrates visible messages from the Pi session file after refresh.
- When
FLEET_PI_CHAT_DATABASE_URLis set, Fleet Pi mirrors full Pi session entries, run events, tool executions, and file mutations into Neon Postgres tables prefixed withpi_. Pi JSONL remains the source of truth; mirror failures must not break chat streaming. - Settings saves hot-reload every in-memory Pi runtime in the deployment because
.pi/settings.jsonis project-scoped; BYOK provider credential saves hot-reload only the authenticated user's active runtimes viahotReloadActiveRuntimesForUser. - Model choices should come from Pi
ModelRegistry/SettingsManager, not a hard-coded UI list. Project-local Pi resources under.pi/skills,.pi/prompts, and.pi/extensionsare loaded throughDefaultResourceLoaderand surfaced through/api/chat/resources. - Project-local Pi skills currently include
.pi/skills/fleet-pi-orientation,.pi/skills/chat-runtime-debugging,.pi/skills/agent-ui-workflows, and the.pi/skills/agent-elementssymlink to.agents/skills/agent-elements. .pi/settings.jsonmay be{}locally; runtime merges Fleet base packages (npm:pi-autoresearch,npm:pi-skill-palette,npm:pi-autocontext,npm:pi-web-access) from code. Vendored extensions under.pi/extensions/auto-load without listing each path..pi/extensions/project-inventory.tsregisters the read-onlyproject_inventorytool,.pi/extensions/workspace-index.tsregisters the read-onlyworkspace_indextool, and.pi/extensions/trust-handler.tsimplements Piproject_trustevent handling with mode-aware auto-approval for workspace-native paths. All are included in Agent and Plan mode tool allowlists..pi/extensions/vendor/filechangesprovides/filechanges,/filechanges-accept, and/filechanges-decline;.pi/extensions/vendor/subagentsregisters thesubagenttool. Keep each folder'sUPSTREAM.mdcurrent when refreshing vendored source.- Agent mode explicitly allows external tools
init_experiment,run_experiment,log_experiment,autocontext_judge,autocontext_improve,autocontext_status,autocontext_scenarios,autocontext_queue,autocontext_runtime_snapshot,subagent,web_search,fetch_content,code_search,get_search_content,daytona_get_status, andpreview_url. Do not add mutating research, file-change, or subagent tools to Plan mode. - Plan mode and Harness mode also allow
web_search,code_search, andget_search_content(read-only).fetch_contentis Agent and Harness mode only — it can clone GitHub repos to/tmp/, which is a side effect inconsistent with Plan mode's read-only contract. - Bedrock credentials should come from standard AWS environment/profile configuration.
AWS_REGIONdefaults tous-east-1when unset.
Manual Chat Checks
- Ask
read package.jsonand verify a Read tool card appears. - Ask
create a small temp file under this repoand verify Write renders and the file is created inside the repo. - Ask
edit that temp fileand verify Edit renders a diff. - Ask
run pnpm --versionand verify Bash renders command and output. - Refresh the page and confirm the visible transcript hydrates from stored Pi session metadata.
- Corrupt localStorage with
/etc/hostsassessionFile; the app should silently start a fresh repo-scoped session instead of showing an outside-session error. - While streaming, send another prompt and verify a follow-up queue status appears.
- Switch to Plan mode, ask for a plan, and verify the assistant produces a numbered
Plan:without edit/write tool use. - In Plan mode, ask an ambiguous request and verify the InputBar Question bar appears, answer it, and confirm the same Pi turn continues.
- After a plan, choose Execute and verify the app switches to Agent mode, full tools are available, and
[DONE:n]progress updates the plan status. - Open the Pi resources browser and verify the starter skills, npm package resources, vendored extensions,
project-inventory.ts, andworkspace-index.tsappear. Verify the resources canvas docks to the right and resizes; on mobile, verify it opens as an overlay. Switch to the Workspace tab, verifyagent-workspaceplus representative seeded files appear, and click a Markdown file to verify the preview panel renders its content. Open Settings and verify Pi settings load, provider/model controls can become dirty and save, and Light/Dark/System theme control remains local. If both project-local and globalagent-elementsskills are installed, the resources diagnostics may include that expected name collision.
Learned User Preferences
- Treat
@workspace/hax-designas the sole UI source of truth; if a surface is missing, add it to hax-design rather than creating app-local components. Prefer export-map hygiene over shell/page-controller deepens (e.g.FleetPiChatShell) until protocol types settle. Deepen the custom OpenUI library undercomponents/openui/rather than adopting@openuidev/react-uiunless explicitly requested. - Keep floating pill-style header chrome; do not replace it with a unified full-width top bar unless explicitly requested. Prefer
bg-sidebarfor inactive header pills and floating panel launcher buttons; use pill-shaped rounding (rounded-full/rounded-[100px]) for header controls and InputBar mode/model selectors. - When executing an attached implementation plan, do not edit the plan file; follow existing todos to completion.
- Avoid inline
styleprops in Fleet Pi UI; prefer Tailwind utilities,cva, co-located component CSS, or shared hax-design tokens. - Keep ChatWorkspace header panel tabs (Pi Resources, Workspace, Artifacts) inline when panels are open; use hax-design
TabsSubtle(tabs-subtle) with Active Label and pill variants; stack the header above the content row (CHAT_HEADER_LAYER_CLASS/relative z-10 overflow-visible). - Prefer semantic tokens in
fleet-pi/styles/tokens.tsand primitives infleet-pi/primitives/(especiallyItemRowvariants) over nested card stacks or duplicated Tailwind class strings in Settings lists. - Avoid generic AI SaaS aesthetics (cream backgrounds, gradient heroes, card grids) and heavy IDE-style dense toolbars unless explicitly requested.
- Keep the chat column a single full-width transcript plus InputBar; show artifact previews in the right panel Artifacts tab, not a horizontal split inside chat.
- Settings dialog should follow shadcn sidebar-13: icon+label nav only (no subtitles), scrollable main pane, and flat
ItemRowlists without nested SectionSurface wrappers; Providers lists only configured/active providers and Add provider uses an inline drill-down (picker → configure), not nested Dialog modals inside Settings; OpenAI Chat Completions requires API key + base URL + model ID; LLM Models should discover models from configured providers into a curated enable/remove list (grouped by provider, All/Enabled filter)—except OCC, which must stay limited to the configured model ID, not a full remote/modelscatalog—and add/remove auto-saves immediately viaPATCH /api/chat/settings(routine changes should not depend on Commit). - InputBar slash-command suggestions must be scrollable and arrow-key navigable; Pi builtins like
/modelopen the model picker (and/models//settings//configopen Settings), not insert as a chat prompt. - Use Playwright
testInfo.outputPath()for E2E screenshots and artifacts instead of hardcoded machine-specific paths; put new tests under dedicated__tests__/directories rather than scattering colocated test files. - Prefer Neon Managed Auth cutover (
neon_authidentity +pi_*tenancy RLS) over RLS-hardening legacy public Better Auth leftovers as a permanent posture; keep security/isolation audit notes gitignored (e.g..cursor/hooks/state/), not under trackedagent-workspace/artifacts/.
Learned Workspace Facts
- Repo-root
neon.ts(@neon/config) enables Managed Auth, Neon AI Gateway (preview.aiGateway: true), and thechatNeon Function onfleet-pi-neoninaws-us-east-2(required for Neon beta services). Authenticated chat defaults to Gateway models viaNEON_AI_GATEWAY_TOKEN+NEON_AI_GATEWAY_BASE_URLinjected into the Function env. Object Storage buckets are not declared inneon.ts; ifneon deploystill pullsAWS_*Object Storage vars into.env, discard them—Fleet Pi does not use Neon Object Storage locally. Link the existing project withneon link(.neonbranch pin is gitignored).neon deployprovisions services only—runpnpm auth:migrate/pnpm chat:migrateseparately. Deployed chat runtime APIs stream from the Neon Function whenVITE_FLEET_PI_CHAT_RUNTIME_URLis set (set in Vercel Production to the Function invocation URL); the Function'sFLEET_PI_CHAT_RUNTIME_CORS_ORIGINSallowlist must include the Vercel app origins or browser streaming is blocked. Settings/providers/workspace stay on Vercel..github/workflows/neon_workflow.ymlcreates/deletes Neon preview branches for PRs (needs repoNEON_PROJECT_ID+NEON_API_KEY). - Hard-cutover auth migration: users re-authenticate on Neon Managed Auth; best-effort email remap via
pnpm remap-auth-user-ids -- --file=remap.csv(owner migration URL). Orphan mirror cleanup:pnpm quarantine-orphan-sessions. Identity lives inneon_auth(Managed Auth);pnpm auth:migratedrops legacypublicBetter Auth tables whenneon_authexists—do not keep those leftovers as the long-term model. Keep Neon-owned identity tables private and do not create views that exposeneon_auth.userto Data API roles. Fleet Pi follows Neon’s Managed Auth server/Function pattern (cookies + JWKS Bearer JWT + per-user scoping onfleet_pi_app); Neon Data API is a separate optional product and must stay off—do not enable it to “complete” Managed Auth. Neon user-scoped RLS applies topi_*mirror tables viaapp.current_user_id(live DBs may also exposefleet_pi_current_user_id()wrappingauth.user_id()then the GUC);FORCE ROW LEVEL SECURITYis required onpi_*so owner connection strings cannot silently bypass isolation—runtimeFLEET_PI_CHAT_DATABASE_URLmust be non-ownerfleet_pi_app. Better Auth tables (user,session,account,verification) andneon_auth.*must not use RLS—pnpm auth:migratechainsauth-post-migrate.tsto disable RLS and grantfleet_pi_appDML. Chat migrations revoke Neon Data APIauthenticated/anonymoustable grants onpi_*and EXECUTE on ownership SECURITY DEFINER probes (fleet_pi_check_session_owner,fleet_pi_lookup_session_id_by_file)—onlyfleet_pi_appmay call them. Keep Neon Data API disabled inneon.ts(dataApi: false) and in console (no public-schema grants). Do not re-applychat-postgres-data-api-authgrant migrations for closed beta; re-assert with20260723_revoke_data_api_pi_grants_againif orphan Data API grant migrations reappear;verify-deployment-readinessfails when those roles still hold privileges onpi_sessions/pi_user_providers/pi_user_settings. Neon Managed Auth open signup is closed-beta only until restricted signups exist (seedocs/runbooks/deployment-release-gate.md). On Vercel, per-user Pi project settings (skills/packages/models) live inpi_user_settingsJSONB and are hydrated into liveSettingsManagerinstances because.pi/settings.jsonis not writable. - Daytona provisions per-user sandboxes via
resolveUserSandboxContext({ userId, surface })(apps/web/src/lib/daytona/resolve-user-sandbox-context.ts). Deployed users require BYOK (daytonainpi_user_providers); missing BYOK means no Daytona sandbox (org keys andDAYTONA_API_KEYnever back end-user sandboxes on Vercel). Durable volumefleet-pi-ws-{userId}mounts only at/home/daytona/agent-workspace(sparse-seeded from gitagent-workspace/, never the full repo; seed must not overwrite user changes on reopen). Legacy sandboxes on/home/daytona/fleet-piand sandboxes stuck inerror(for example failed volume mount) are recreated on warm-up with the same volume. Phase 2 Secrets (sync-daytona-secrets.ts,secret-hosts.ts): upsert org secretsfleet_pi_<providerId>with host allowlists; changing Secrets-eligible BYOK recreates the sandbox on that volume; unavailable Secrets API falls back to plaintextauth.json/env. OAuth, Vertex ADC, Bedrock, and similar stay onauth.json/plain env. Web path uses Fleet adapter.pi/extensions/daytona-sandbox(ops viacreateSandboxOperations); stocknpm:@daytona/piis CLI/global-only—do not list it in project.pi/settings.jsonpackages (CLI loads project packages without the web filter and conflicts with Fleet tools); the web loader also excludes it. Agent/Harness allowdaytona_get_status+preview_urlonly. Authenticated chat must not block the stream on cold Daytona sandbox creation—use a cached sandbox or background warm-up (server-runtime.ts). Vercel serverless output must pintslib@2beside traced@daytona/*packages becausetslib@1(via Neon Auth passkey) lacks__esDecorate. - On Vercel (
VERCEL=1), session-scoped chat endpoints require auth (Neon Managed Auth whenNEON_AUTH_BASE_URL/NEON_AUTH_URLis set, otherwise Better Auth):/api/chat,/api/chat/session,/api/chat/resume,/api/chat/sessions,/api/chat/new,/api/chat/abort,/api/chat/question,/api/chat/runs,/api/chat/run,/api/chat/provenance,PATCH /api/chat/settings, plus catalog/api/chat/models,/api/chat/models/discover,/api/chat/resources, and/api/chat/commands. Workspace APIs (/api/workspace/tree,/file,/item(s),/search,/reindex,/health) use the samewithAuthenticatedChatRequestgate when chat auth is required and resolve Daytona viaresolveWorkspaceContextwhen the user has Daytona BYOK. Local anonymous chat/workspace applies only when neither Neon Auth URL is set.auth-mode.tsmust stay client-safe—server chat auth (isChatAuthRequired,chat-auth-surface,node:async_hooks) lives inchat-api-auth.ts. Neon Auth clients use same-origin/api/authwhenVITE_NEON_AUTH_URLis set (proxy to Managed Auth) so cookies are first-party; mint JWTs viaauthClient.token()withcredentials: "include"(cached + single-flight; not Better AuthgetJWTToken())./api/chat/providersusesgetChatAuthSession/withAuthenticatedChatRequestlike settings. Mirror ownership fail-closed (shouldFailClosedOnMirrorError/requiresAuthenticatedMirrorOwner) lives indeployment/trust-zone.ts(not client-safeenvironment.ts) on Vercel, Neon Managed Auth, Neon Function surface, orFLEET_PI_CHAT_RUNTIME_REQUIRE_AUTH; probes usefleet_pi_check_session_owner(SECURITY DEFINER) so RLS cannot hide foreign-owned rows—runpnpm chat:migrateafter deploy when ownership or Data API revoke migrations change. - Chat shell layout constants (
layout-constants.ts,canvas-utils.ts, 960px breakpoint, 70% panel width) live in hax-design. Appearance, Sandbox, Providers, LLM Models, and Skills live in the Settings dialog; the right panel is Workspace, Pi Resources, and Artifacts only. Settings resource catalog option values must ignore Pi provenance sources (auto/local/…) and persist portable paths viatoSettingsResourcePath(extensions/…,../agent-workspace/…), never absolute machine paths. Slash suggestions come from/api/chat/commands; Pi builtins are intercepted client-side (picker/Settings/new session), while skill/prompt commands go to the agent. - Agent instruction surface is
AGENTS.mdonly; do not recreateCLAUDE.md. - OpenUI components and registry code belong under
packages/hax-design/src/components/openui/(shared tones intones.ts; regenerate prompt signatures withpnpm generate:openui-signaturesintopackages/pi-protocol/src/openui-signatures.tsonly); files insidepackages/hax-designmust use relative imports and apps import via@workspace/hax-design/*. PRODUCT.md,DESIGN.md,CONTEXT.md,packages/hax-design/ARCHITECTURE.md, and Fleet Pi building blocks underfleet-pi/{layout,chat,pi,primitives,styles}/are canonical UI design context; semantic tokens live infleet-pi/styles/tokens.ts.- Pi provider credential IDs live in
@workspace/pi-protocol/provider-catalog.ts; Settings UI metadata infleet-pi/pi/config-panel/shared/provider-metadata.ts. Canonical Google id isgoogle(GEMINI_API_KEY);GOOGLE_CLIENT_*are Better Auth only. OpenAI Chat Completions (openai-chat-completions) needsOPENAI_CHAT_COMPLETIONS_{API_KEY,BASE_URL,MODEL}in one atomic providers POST for BYOK; on authenticated deploys without OCC BYOK, Neon AI Gateway supplies the OCC backend withqwen35-122b-a10bandgpt-oss-120b. Vite must ignore.env/.env.localinserver.watchso credential saves do not restart mid-request;/chat/completionsbase URLs normalize to the API root; OCC BYOK registers only the configured model ID (do not ingest full OpenCode Zen/modelscatalogs). Chat model catalog (model-catalog.ts) must select an available enabled model—rematch staleopenaidefaults ontoopenai-chat-completionswhen that provider holds the model. On Vercel, org LLM env keys (e.g.GEMINI_API_KEY,HF_TOKEN,OPENROUTER_API_KEY) must never back chat — only signed-in user BYOK or platformNEON_AI_GATEWAY_*for authenticated OCC; those org keys are scrubbed from the process so tools/Pi cannot read them. AutoContext may still default to provider idopenaiwith OCC model ids—that mismatch is intentional. Dev loads.envthen.env.localwith override. PostHog lives inapps/web/src/lib/analytics/posthog.ts. - Custom providers (native Pi mechanism). Users can register any OpenAI/Anthropic/Google-compatible endpoint, each
{ displayName, apiKey, baseUrl, api, modelIds }withapione ofopenai-completions,openai-responses,anthropic-messages,google-genai. General custom providers get a slug idcustom+<slug>; legacy named OCC instances keepopenai-chat-completions+<slug>— both register through the same path. The reservedopenai-chat-completionsid stays the default/Neon AI Gateway slot. Storage reusespi_user_providers(provider_id= slug, encryptedencrypted_keyfor the apiKey, encryptedencrypted_payloadJSON{displayName, baseUrl, api, modelIds}— legacy payloads withmodelIdnormalize on read); no Neon migration.apps/web/src/lib/db/occ-instances.tsis the persistence layer;custom-provider-registry.ts(registerCustomProviders) registers each instance as its own native Pi provider (<instanceId>/<modelId>in the model picker;google-genaimaps to Pi'sgoogle-generative-ai) with a per-hostmax_tokenscap (25k + gateway compat on*.neon.techOCC endpoints, else 32k). Custom instances pick a storage backend at runtime: Postgrespi_user_providerswhen the account is DB-backed (userId+FLEET_PI_CHAT_DATABASE_URL), otherwise a gitignored per-scope local file store at<projectRoot>/.fleet/providers.anonymous.json(anonymous chat) or<projectRoot>/.fleet/providers.user-<hash>.json(local signed-in accounts; plaintext, atomic temp-file+rename) that enables anonymous/local non-DB chat —POST /api/chat/providerswithcreateOccInstance: trueor an existing…+<slug>id. OCC-family instances may use loopbackhttp://localhostbase URLs in local dev; everything else stays https-only. The reserved default OCC slot remains the env-backedOPENAI_CHAT_COMPLETIONS_{API_KEY,BASE_URL,MODEL};apps/web/src/lib/db/local-provider-instances.tsis the local store (anduseLocalProviderStorepicks the backend). Sandbox credential sync covers only the reserved default OCC slot for now (custom instances are not yet pushed to Daytona). - Workspace and Artifacts panels are agent-workspace-scoped only (local and Daytona)—never the full repo tree; Artifacts uses
agent-workspace/artifacts/via the workspace tree API; both shareselectedWorkspacePathandworkspace-panelclears selections outside each panel'sscopePath. .vercelignoreexcludesagent-workspace/,.fleet/,.pi/,dist/, andnode_modules(apps/web must not import from.pi/on Vercel—colocate server helpers likecontext-filterunderapps/web/src/lib/pi/). Feature-branch previews needBETTER_AUTH_SECRETandFLEET_PI_AUTH_DATABASE_URLscoped to Preview, not Production-only or a single branch alias.@workspace/pi-protocol(packages/pi-protocol) is the canonical chat wire layer: message types, Zod schemas, model-patterns,buildOpenUIPrompt(no React); import protocol types from@workspace/pi-protocol(or hax-designchat-helpersfor UI helpers only). Server code imports protocol, notagent-elements/openuicomponents.handleChatTurninapps/web/src/lib/pi/handle-chat-turn.tsowns stream turn logic;/api/chatis auth/parse/pipe only. PienabledModels: []means deny-all models. Chat client setsstatustoreadyon each NDJSONdoneevent while the HTTP stream may stay open for queued follow-ups; abort/stop clears the follow-up queue and remains available during bothsubmittedandstreaming.
<!-- AUTOCTX_GUIDE_START -->AutoContext
- Use
autoctx capabilitiesto inspect supported commands and project state. - Use
autoctx whoamito confirm provider credentials before running evaluations. - Run
autoctx runfrom this directory to use the defaults stored in.autoctx.json.
<!-- AUTOCTX_GUIDE_END -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

