Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(agentic): add initialize workspace skill to pi (#4652)
Will Hutchinsona0e5d45631da
diff --git a/.agents/skills/debug-service/SKILL.md b/.agents/skills/debug-service/SKILL.mdindex c22213386e..c7ae7fc9a0 100644--- a/.agents/skills/debug-service/SKILL.md+++ b/.agents/skills/debug-service/SKILL.md@@ -1,3 +1,9 @@+---+name: debug-service+description: "Interactively debug a Rust binary in the current crate by starting it with debug logging and tailing its log. Use when asked to debug or inspect a running Rust service."+allowed-tools: Bash Read+---+You are going to help me interactively debug the rust binarythat's in this crate.diff --git a/.pi/bin/nix-develop-shell b/.pi/bin/nix-develop-shellnew file mode 100755index 0000000000..fc527a3c26--- /dev/null+++ b/.pi/bin/nix-develop-shell@@ -0,0 +1,26 @@+#!/usr/bin/env bash+set -euo pipefail++# Pi invokes shellPath as: .pi/bin/nix-develop-shell -c '<command>'.+# Re-exec bash inside the repo flake so normal bash tool calls see Rust and+# other development tooling without requiring `direnv exec`.+#+# Deliberately use bash, not $SHELL: Pi's tool is a bash tool and generated+# commands commonly use bash syntax. If $SHELL is fish/nu/etc., those commands+# fail even though the Nix environment loaded correctly.++script_path="${BASH_SOURCE[0]:-$0}"+script_dir="$(CDPATH= cd -- "$(dirname -- "$script_path")" && pwd)"+repo_root="$(CDPATH= cd -- "$script_dir/../.." && pwd)"++if [ -n "${PI_NIX_DEVELOP_SHELL_ACTIVE:-}" ] || [ -n "${IN_NIX_SHELL:-}" ]; then+ exec bash "$@"+fi++export PI_NIX_DEVELOP_SHELL_ACTIVE=1++if command -v nix >/dev/null 2>&1 && [ -f "$repo_root/flake.nix" ]; then+ exec nix develop "$repo_root" -c bash "$@"+fi++exec bash "$@"diff --git a/.pi/settings.json b/.pi/settings.jsonnew file mode 100644index 0000000000..360a2d3135--- /dev/null+++ b/.pi/settings.json@@ -0,0 +1,3 @@+{+ "shellPath": ".pi/bin/nix-develop-shell"+}diff --git a/.pi/skills/initialize-workspace/SKILL.md b/.pi/skills/initialize-workspace/SKILL.mdnew file mode 100644index 0000000000..c57bee7a37--- /dev/null+++ b/.pi/skills/initialize-workspace/SKILL.md@@ -0,0 +1,90 @@+---+name: initialize-workspace+description: "Initialize the current repo when an agent first starts in a repository. Use at the beginning of every new agent session before editing files by verifying the Pi bash tool is already running inside the repo Nix shell, setting up direnv on NixOS when available, then running `just rust/cloud-storage/setup_test_envs`."+allowed-tools: Bash Read+---++# Initialize Workspace++Run this skill once near the beginning of a new agent session for this repository, before making other changes. Do not rerun it in the same session unless the user asks or the earlier run failed for an environmental reason that has since been fixed.++## Working Directory++Run all commands from the repository root.++## Important Pi/Nix Behavior++A command such as `direnv allow`, `eval "$(direnv export bash)"`, or `nix develop -c "$SHELL"` only affects the child shell running that command. It cannot mutate the already-running Pi process or automatically change later `bash` tool calls.++This repository solves that with checked-in Pi project config:++- `.pi/settings.json` sets `shellPath` to `.pi/bin/nix-develop-shell`.+- `.pi/bin/nix-develop-shell` wraps Pi `bash` tool calls with `nix develop <repo> -c bash` only when `nix` and `flake.nix` are available; otherwise it falls back to plain `bash`.++After Pi starts or reloads with that setting, normal `bash` tool calls automatically run inside the repo Nix shell on machines with Nix. On machines without Nix, the wrapper is a no-op pass-through to `bash`. The wrapper deliberately uses `bash`, not `$SHELL`, because Pi's tool sends bash commands and user shells such as fish are not bash-compatible.++If the verification step below says the Nix shell is not active, stop and tell the user to run `/reload` or restart Pi from a trusted repo/workspace before continuing.++## Steps++### 1. Verify this agent's bash tool is already inside the Nix shell++```bash+set -euo pipefail++if [ -f flake.nix ] && command -v nix >/dev/null 2>&1; then+ if [ -n "${IN_NIX_SHELL:-}" ]; then+ echo "nix-shell-active: IN_NIX_SHELL=${IN_NIX_SHELL}"+ else+ echo "nix-shell-not-active: run /reload or restart Pi so .pi/settings.json shellPath is applied" >&2+ exit 1+ fi+else+ echo "nix-shell-check-skipped: no flake.nix or nix command unavailable"+fi+```++### 2. Set up `.envrc` and allow direnv only when supported++Run this only when both conditions are true:++- The machine is running NixOS.+- `direnv` is installed and available on `PATH`.++Use this safe wrapper so the direnv command is never run on unsupported systems:++```bash+if { [ -e /etc/NIXOS ] || ( [ -f /etc/os-release ] && . /etc/os-release && [ "${ID:-}" = "nixos" ] ); } && command -v direnv >/dev/null 2>&1; then+ [ -f .envrc ] || : > .envrc++ ensure_envrc_line() {+ local line="$1"++ if ! grep -qxF "$line" .envrc; then+ if [ -s .envrc ] && [ "$(tail -c 1 .envrc)" != "" ]; then+ printf '\n' >> .envrc+ fi+ printf '%s\n' "$line" >> .envrc+ fi+ }++ ensure_envrc_line "use flake"+ ensure_envrc_line "watch_file nix/*.nix"+ direnv allow+ echo "direnv-setup-ran"+else+ echo "direnv-setup-skipped: requires NixOS and direnv on PATH"+fi+```++### 3. Run the test-environment setup command++```bash+just rust/cloud-storage/setup_test_envs+```++If any command fails, stop and report the failure before proceeding with repo work.++## Final Response++Briefly say whether the Nix shell verification passed, whether direnv setup ran or was skipped, and whether `just rust/cloud-storage/setup_test_envs` passed.