Last reviewed: 2026-02-12
Notes for agents working in this repo.
- Tool behavior rules:
src/tools/DECISIONS.md - UI/CSS architecture:
src/ui/README.md(Tailwind v4@layergotcha) - Upstream divergences:
docs/upstream-divergences.md(read before adding new divergences) - Docs index:
docs/README.md - Model registry freshness:
docs/model-updates.md(if Last verified > 1 week, refresh Pi deps + re-verify model IDs before model UX changes)
- Define core tool names in
src/tools/registry.ts(CORE_TOOL_NAMES,CoreToolName,createCoreTools()). - Do not duplicate tool-name lists; import
CORE_TOOL_NAMES. - When adding/removing a core tool, update in the same PR:
src/tools/registry.tssrc/ui/tool-renderers.tssrc/ui/humanize-params.tssrc/context/tool-disclosure.tssrc/prompt/system-prompt.ts(if documented tool list changes)
- Keep human-readable output in
result.content. - Put stable machine metadata in
result.details. - UI should prefer
details, with fallback for older persisted sessions. - Reuse guards/types from
src/tools/tool-details.ts.
- Never persist raw
Office.context.document.url. - Use
getWorkbookContext()fromsrc/workbook/context.ts. - Use
src/workbook/session-association.tshelpers for SettingsStore mapping keys.
- Avoid
innerHTMLfor user/tool/session content; use DOM APIs orsrc/utils/html.ts. - Keep markdown protections from
installMarkedSafetyPatch()(src/compat/marked-safety.ts). - Keep strict origin allowlists in:
scripts/cors-proxy-server.mjsscripts/tmux-bridge-server.mjsscripts/python-bridge-server.mjs
- Keep proxy target filtering strict in
scripts/proxy-target-policy.mjs.- Do not commit permissive defaults (e.g.
ALLOW_ALL_TARGET_HOSTS=1).
- Do not commit permissive defaults (e.g.
- Avoid Node-only imports and side-effect barrel imports.
- After import/dependency changes, run
npm run buildand check chunk sizes + Vite browser-compat warnings.
- Prompt cache keys are prefix-based and sensitive to: model identity, system prompt, tool schemas, and session key.
- Keep static prefix content stable (no timestamps/random IDs in system prompt or tool metadata).
- Prefer message-tail updates for volatile state (auto-context/system reminders) instead of mutating base prompt text every turn.
- Keep tool ordering deterministic; do not rebuild tool lists with unstable ordering.
- Do not reintroduce blanket eager
setTools(...)on refresh passes when extension tools exist; use fingerprint + extension tool revision semantics. - When changing context/tool/model wiring, validate against
docs/cache-observability-baselines.mdand record expected vs observedprefixChangeReasons.
- No
// @ts-ignore. - If unavoidable:
// @ts-expect-error -- <reason>with a real reason. - Avoid explicit
any/as any; prefer specific types, unions, generics, orunknown+ narrowing. - Avoid non-null assertions where practical; use guards/early throws.
npm run checknpm run buildnpm run test:modelsnpm run test:contextwhen touching prompt/context/tool disclosure/session wiringnpm run test:securitywhen touching proxy/bridge/auth/HTML safety paths- Manual Excel smoke test when touching session persistence, tools, auth, or UI wiring
Use the UI Gallery (src/ui-gallery.html) to verify CSS and component changes
without needing Excel. It renders mock components with the real CSS theme.
# Ensure dev server is running (starts automatically if needed)
./scripts/ui-verify.sh # Full gallery screenshot
./scripts/ui-verify.sh diff-table # Screenshot a specific section
./scripts/ui-verify.sh taskpane # Screenshot the real taskpane (waits for Office timeout)
./scripts/ui-verify.sh stop # Clean up browser sessionAvailable gallery sections (use as argument):
badges, file-items, tool-cards, tool-groups, diff-table,
text-preview, buttons, toasts, markdown
Or use agent-browser directly for interactive inspection:
npx agent-browser --session pi-ui open http://localhost:3000/src/ui-gallery.html
npx agent-browser --session pi-ui wait 2000
npx agent-browser --session pi-ui snapshot -i # See interactive elements
npx agent-browser --session pi-ui screenshot shot.png # Capture
npx agent-browser --session pi-ui close # Clean upFor full taskpane inspection (boots without Excel after 3s timeout):
npx agent-browser open http://localhost:3000/src/taskpane.html
npx agent-browser wait 4000 # Wait for Office.js fallback
npx agent-browser snapshot -i -c # Interactive snapshot
npx agent-browser console --json # Check for JS errors
npx agent-browser errors --json # Check for page errorsWhen to add new gallery sections:
- Adding a new component type → add a mock render in
src/ui-gallery.ts - Changing CSS for an existing component → verify via
./scripts/ui-verify.sh <section> - Before/after comparison → screenshot before change, make edit, screenshot again
.githooks/pre-commitrunsnpm run lint+npm run typecheck.- Bypass only when needed:
git commit --no-verify.
Excel loads a sideloaded manifest from:
~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/{add-in-id}.manifest.xml
If local changes do not show up:
- Verify sideloaded manifest points to
https://localhost:3000/...(not production URL). - Recopy manifest:
cp manifest.xml ~/Library/Containers/com.microsoft.Excel/Data/Documents/wef/a1b2c3d4-e5f6-7890-abcd-ef1234567890.manifest.xml - Quit Excel fully and reopen.
- If still stale, clear WKWebView cache and relaunch Excel:
rm -rf ~/Library/Containers/com.microsoft.Excel/Data/Library/WebKit/rm -rf ~/Library/Containers/com.microsoft.Excel/Data/Library/Caches/WebKit/