← Catalog

@abhishek944/pi-firstmate

Configurable coordinator-first mode and bundled First Mate skill for Pi.

Extension

Install

Install with PiG

pig install npm:@abhishek944/pi-firstmate

Install with Pi

pi install npm:@abhishek944/pi-firstmate
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "skills": [
    "./skills"
  ],
  "extensions": [
    "./dist/index.js"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.2 (README.md). PiG does not review it.

pi-firstmate

A standalone Pi package with an extension and bundled First Mate skill. Turn a primary session into a coordinator: keep conversation, decisions and quick inspection local, and delegate project execution through your installed orchestration backend. While the mode is on, the extension also restricts the coordinator's tools to a fixed inspection set plus installed orchestration, tracking, monitoring and decision tools.

Install

Requires Pi 1.4.0 or a compatible version with structured prompt sections and pi.getSettings(), and Node.js 22.19 or newer.

For a local checkout:

cd /path/to/pi-firstmate
npm install --ignore-scripts
npm run build
pi install /path/to/pi-firstmate

Run Pi from any project directory. Use /reload or restart Pi after installation or changes. The explicit package manifest loads dist/index.js and skills/firstmate/SKILL.md; do not separately copy the skill into a global skills directory or register the source extension again. The injected first_mate guidance comes from skills/firstmate/SKILL.md, read when the extension starts a session and cached for that session. A skill-only edit takes effect after /reload or restart without npm run build; TypeScript changes still need npm run build before reload.

First Mate does not install an orchestration backend. Install and authorize pi-herdr or another backend separately if you want delegation. No Herdr, pi-tasks or user-global workflow skill dependency is required to load or enable this package.

Commands

CommandEffect
/firstmate or /firstmate statusShow effective mode, default, override, worker classification, tool availability, skill advertisement and guidance availability.
/firstmate onEnable coordinator guidance for this session.
/firstmate offDisable it and supersede earlier coordinator guidance.
/firstmate defaultClear the session override and follow settings.
/closeRecord the worker close retrospective in improvements.md in the worker's canonical task directory; changes nothing and never closes a terminal.

Overrides survive reload and resume of the same session. Navigating branches does not roll them back. Forks have a new session ID and do not inherit the override. Commands never write your settings.

Worker close retrospective

When a worker's assignment is complete, the coordinator verifies the result and decides whether the worker needs anything further. Only when it does not, the coordinator sends the real /close command to that still-live worker with the orchestration backend's send tool (AgentSend), waits for the resulting run, reads the improvements.md record, and then closes the worker terminal with the backend's close tool (AgentClose).

  • Records stay local in the canonical task artifact directory: <parentTaskDir>/<sessionId>/<workId>/<taskId>/improvements.md for a delegated worker, or var/<sessionId>/<workId>/<taskId>/improvements.md in a root session. Without a work or task record, the file is var/<sessionId>/improvements.md. var/ is not committed.
  • Nothing is applied. No skills, code, settings, tasks, terminals or monitors are changed, and no commits, deployments or follow-up tasks are created.
  • Repeated runs merge into the existing file instead of duplicating findings, and blocked or interrupted work is recorded honestly instead of as complete.
  • A worker is closed once its result is verified and no concrete follow-up remains. Keeping one longer needs a named dependency, such as a specific pending review or decision; an outstanding verification belongs in the handoff instead of keeping the author available, and retained workers are reassessed after review, decision and integration milestones. A worker that is still active, blocked awaiting input or not owned by this coordinator is never closed.
  • The command itself never closes a terminal and never runs automatically on a final or interim worker report. The coordinator owns both the decision and the close, so the retrospective cannot run before verification or while a named dependency is genuinely pending.

/close runs the same bundled close skill workflow in any session. A model cannot type slash commands, which is why the coordinator sends the command through the backend. A typed /close is dispatched by Pi as a command; the backend-wrapped request (<hc …>/close</hc>) is recognized by the worker's input hook and rewritten into the same workflow run, so it is not sent to the model as plain text to improvise. In a coordinator session the command reports this lifecycle instead of starting a coordinator retrospective, because the coordinator has no project-edit tools.

Default configuration

Merge this section into ~/.pi/agent/settings.json (or your custom Pi agent directory):

{
  "pi-firstmate": {
    "enabled": false,
    "banner": true
  }
}

The default is off when omitted. Set enabled to true for default-on primary sessions. A trusted project's .pi/settings.json may override it through Pi's normal settings merge. See config.example.json.

Only booleans are accepted for enabled and banner. A malformed section or enabled reports a diagnostic and treats the configured default as off; an explicit session override still applies. A malformed banner disables only the banner and reports it; a valid enabled keeps working. A malformed coordinatorSkills disables only that filter and reports it. Other settings keys are untouched.

Coordinator skill advertisement

coordinatorSkills is an optional array of exact skill names. While First Mate is effectively on in a primary coordinator session, Pi advertises only the discovered skills with those names ([] advertises none); omitting the key keeps every discovered skill advertised. For example:

{
  "pi-firstmate": {
    "enabled": true,
    "coordinatorSkills": ["implement", "model-routing-policy", "herdr"]
  }
}

Names are matched exactly against the skills Pi already discovered. User, package, explicit and trusted-project locations keep their normal precedence and collision rules, so the list cannot add, load, reorder or trust a skill; a configured name that is not currently discovered is ignored. /firstmate status reports the advertised count and names any configured skill the session did not discover, and the first effective run with a new unknown-name set adds one warning.

The filter changes only that run's model-facing <skills> advertisement. It does not delete or disable skills, change permissions or tool restrictions, or erase instructions already in the conversation. Off sessions, --firstmate-worker processes and verified Core workers advertise every discovered skill. Settings are read when the session starts, when you run /firstmate, and after /reload; a changed filter applies from the next run.

Pi resolves /skill:name from its complete discovered list, so an explicit /skill:name still loads a skill that is filtered out of the advertisement; filtering only removes automatic model routing to it. enableSkillCommands controls whether skill commands appear in interactive command discovery, but manually entered /skill:name commands still work. The bundled First Mate policy is injected separately as the first_mate prompt section, so filtering never removes coordinator guidance. A malformed value (a non-array, a non-string entry, or an empty name) disables only this filter with a diagnostic instead of hiding every skill.

Herdr banner

In a primary Herdr Core session, banner (default true) adds a warm amber strip above that session's tab panes while First Mate is effectively on. The strip is a native layout block, not a pane header: pane content, headers and buttons, terminals, themes, other tabs and worker sessions are unchanged. It also carries a reminder to read the installed First Mate skill. /firstmate off collapses it to zero height; switching to a tab or space without a First Mate session also hides it.

On session start in a verified primary Core session, the extension:

  • installs or updates ~/.config/herdr-app/mods/firstmate-banner/ from this package. Only changed files are replaced, and the previous copy is kept under ~/.config/herdr-app/data/firstmate-banner/backups/;
  • adds one firstmate-banner block to the shown personal layout, immediately above the block that contains the active tab. The layout file is backed up there first. Herdr's shipped main, terminals and win98 layouts are never edited; clone one (layout.clone) and switch to it if you want the banner there;
  • writes ~/.config/herdr-app/data/firstmate-banner/<session-id>.json with the effective mode and Core terminal address, and removes it on shutdown. Worker, non-Core and inconclusive-Core sessions never advertise coordinator mode.

The state stays local: no network call, daemon, polling loop or new IPC service. Herdr hot-reloads mods, but run /reload in Pi after installing or updating this package so the extension installs the strip; /firstmate status then reports a Banner: line. Pi must be running in a Herdr Core terminal and report agent status, which it normally does. If the banner is unavailable, the status line names the reason (for example a shipped layout or a missing Herdr app home). Set banner to false to stop the integration.

Delegation and worker isolation

While on, substantial investigation, project edits, builds, migrations, reviews and permitted checks go to workers. A quick check that grows should become delegated work. Saying "implement this" keeps coordinator mode on; use /firstmate off to leave it.

The bundled skill makes reading the installed First Mate skill mandatory whenever the mode is on. The extension reinforces that at activation with a notification, an always-present prompt guideline and a compact First Mate · read skill status line while coordinator mode is effective.

Use the available backend's actual instructions, tools, permissions, monitoring and result lifecycle. With pi-herdr, follow its bundled herdr skill and Agent tools. With another installed backend, follow that backend's own instructions. Host/project tracking, artifact and model-routing rules still apply when installed or required; this package adds no mandatory global workflow skills.

If delegation is unavailable or fails, the coordinator should report the concrete blocker and safe options instead of silently executing substantial work itself. First Mate adds no orchestrator, adapter registry, task store, model selection or automatic model fallback; its tool-call gate is limited to the coordinator allowlist below.

Coordinator tool allowlist

While coordinator mode is effective, the model can use only read, grep, find, ls and tools registered by an installed pi-tasks, pi-loop-monitor, pi-decisions, pi-herdr or pi-schedulers package. The extension derives that set from the packages' actual registrations, so their task, decision, monitor, loop and Agent tools keep their normal schemas and behavior; MonitorCreate is not argument-filtered. Other active tools are hidden from the model and re-filtered before each request, including direct tools registered during a multi-turn run such as a slow MCP connection. Direct or nested calls to them are rejected at Pi's tool_call boundary with an actionable delegation message, including nested calls made through codemode or another tool.

Off mode, an explicit --firstmate-worker process and verified Core workers keep ordinary tools. /firstmate off and /firstmate default restore the active-tool set that existed before the restriction, without enabling unrelated inactive tools. The baseline is stored in existing session state under this session's identity, so turning the mode off after resuming a saved session restores the original set even when the restricted declarations were the last ones recorded. A fork does not inherit another session's baseline.

When pi-research (/ask) owns its read-only guard, First Mate keeps that restriction intact. It answers the existing pi-ask:guard:probe event while deciding whether to restore its saved tools, and it re-runs the full gate synchronously on the existing pi-ask:guard:released event. A coordinator therefore records the restored tool list as its baseline before narrowing again, and an off-mode restore waits until the read-only mode ends instead of widening it. This cooperation uses only the pi-ask guard events; extensions that do not participate in that protocol cannot be inferred.

This is Pi tool-call enforcement, not an OS sandbox. Allowed tools can still start or control processes, and permissions, trust, user authorization and /ask or /btw limits still apply. Do not describe it as absolute prevention through every allowed command or monitor.

Shell, codemode and project-edit tools are intentionally unavailable to a coordinator; this is not a missing permission or a broken installation. A blocked call reports the restriction and points to checking the installed delegation backend, not to enabling the tool.

Optional scheduler creation

An installed pi-schedulers package owns SchedulerCreate, including its schema, preview, mandatory human Create/Cancel dialog and transactional definition save. First Mate only controls its exposure from the actual package-owned registration; it does not implement scheduling or guess a foreign tool name. Use it only when the human explicitly asks for scheduled work, never proactively or from inferred permission. Each creation, including duplicates, needs its own human confirmation.

The scheduler registers hidden by default. While resolveMode().effective is true, First Mate allows the scheduler-owned registration to become model-only and activates it, without widening /ask's read-only guard. The synchronous pi-firstmate:mode:probe event answers available, protocolVersion: 1, effective, and a generation that changes on effective-mode transitions. pi-firstmate:mode:changed asks consumers to re-probe; the owning scheduler publishes pi-schedulers:tools:changed after changing its registration so late registration is handled in either extension load order. The existing explicit /firstmate on behavior after an inconclusive Core lookup is unchanged; actual worker suppression remains authoritative.

Off, shutdown, reload and resume restoration never add coordinator-only scheduler tools to the ordinary baseline, and unrelated active/inactive choices remain unchanged. Without First Mate the registration stays hidden. The scheduler rechecks the authoritative effective generation at execute entry, after the human answers, and before initiating its definition write/commit. Off/on while a dialog is open invalidates it; no model approval flag bypasses the human dialog. Once a filesystem commit has been initiated it cannot be revoked atomically by a later mode change. No rollback/recovery infrastructure is added. Scheduled workers keep normal configured tools/MCP and First Mate suppression; this integration does not turn creation back on in those workers. Reload Pi after updating both packages when it is safe to do so; installation of native mods is separate.

Other worker launchers

Pass this package's one boolean flag to child Pi processes that load it:

pi --firstmate-worker

The flag defaults to false. When present, it always suppresses coordinator guidance, even with default-on settings or a saved /firstmate on override. It also skips optional Core detection, so it works without hc. This is a per-process CLI marker, not an inherited global mode environment variable. Ensure your launcher's actual child command passes it; First Mate does not modify launchers. When adding an initial prompt, separate it with --, for example pi --firstmate-worker -- "worker assignment". Pi 1.4.0 can otherwise consume a following positional prompt as an extension flag value.

Optional pi-herdr/Core detection

Without the explicit flag, a process with HC_TERMINAL_ID can use hc get <terminalId> --json to check the labels written by pi-herdr. Both pi.task and pi.session identify a worker. HC_TERMINAL_ID alone does not: primary Core sessions have it too. Non-Core sessions need neither hc nor Herdr installed.

A failed or partial Core lookup suppresses default-on and reports a diagnostic. An explicit /firstmate on may enable that unclassified session if you know it is a coordinator; verified workers remain suppressed.

Unknown third-party launcher workers cannot be reliably recognized automatically. Use --firstmate-worker, especially when workers share default-on configuration. This package does not claim universal launcher compatibility.

Boundaries

First Mate is coordinator guidance plus the tool-call allowlist and the optional skill-advertisement filter above. It is not a security sandbox or a guarantee that a model complies, and it does not grant permissions. Project trust, user authorization, specialized workflows and /ask or /btw restrictions remain intact. Workers follow their assignment and ordinary instructions, not coordinator delegation guidance. Filtered skills remain installed and available to explicit /skill:name commands; the filter is not a permission, trust or sandbox boundary.

The extension reads skills/firstmate/SKILL.md, strips its frontmatter, and injects the result as a structured first_mate section before each effective user or custom-message run, including monitor wakes. Turning it off removes that section and, when earlier guidance was observed, adds a superseding guideline. An unreadable policy reports a diagnostic instead of pretending guidance was installed.

Development

npm install --ignore-scripts
npm run lint
npm run typecheck
npm run build
npm pack --dry-run

The host Pi package is a peer dependency and a pinned development dependency for current API declarations; it is not bundled as a runtime dependency. src/index.ts and generated dist/index.js both resolve the same bundled policy relative to their module, independently of the working directory. No unit-test runner is included.

For user-owned live verification, enable the mode in a primary session, confirm /firstmate status reports the restricted Tools: line and an ordinary tool is unavailable, request a small project change, inspect actual worker results, then disable it and confirm ordinary execution returns. Check your launcher's child processes with --firstmate-worker before enabling a shared default.

License

MIT.