This repository has been archived on 2026-11-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
ash-bot 867dd71d2f feat: initial find_agents pi extension (agent discovery)
Graduate the find_agents pi extension from the polaris agent-discovery
worktree (commits b361398/d7449f7) into its own fetchable repo in the
ash-bot/agent-enforcement layout (manifest at repo root pointing at
./extension/index.ts; jiti compiles TS at runtime, no build step).

Exposes one LLM-callable tool: find_agents — read-only, same-daemon
discovery of Paseo agents/sessions by title, leading-emoji state, status,
labels, workspace, and requiresAttention. Domain-bounded: finds agents,
does not wake/message/mutate them.
2026-08-23 22:18:38 -07:00

agent-discovery — a pi extension exposing find_agents

A pi extension (Layer 2 of the agent-discovery design) that exposes one LLM-callable tool — find_agents — which finds Paseo agents on the local daemon (same-daemon, read-only). It reads the daemon via the paseo ls --json CLI (the stable surface), then adds the filtering and enrichment the raw MCP paseo_list_agents tool lacks: title regex, leading-emoji state, label match, status, workspace title, and a daemon field.

Domain boundary (one-way, same principle as the sentinel skill and the enforcement system): discovery finds "agents," "sessions," "workspaces," "labels." It does not know about Overseers, sentinels, or any higher pattern. The state filter parses the leading emoji of the title and understands the legend set (🟢 🔵 🔴 🟣 ✅ ⛔ ⏳), but it is stated as "leading emoji of the title," not "Overseer state" — an unrecognized leading emoji is state: null and the title is returned whole. The legend is a caller convention, not a tool dependency.

Posture: read-only. No wake, no messaging, no paseo send, no paseo agent update, no archive, no daemon mutation. The tool finds; it does not act. CLI errors are caught and returned as tool errors, never thrown into the agent loop (fail-safe).

See DESIGN.md for the full design, the search/filter API spec, Findings D1–D7, and the layer split.

Layout

extension/
  package.json      pi.extensions: ["./index.ts"], deps: typebox + @earendil-works/pi-ai
  tsconfig.json     typecheck config (paths mapped to global pi dist)
  index.ts          default export agentDiscovery(pi); registers the find_agents tool
  parse.ts          PURE: RawAgent → EnrichedAgent, parseState, applyFilters, buildSummary
                    (no I/O — the shareable composition point with enforcement, DESIGN D7)
  cli.ts            I/O: paseo ls --json --global [-a] [--label k=v] + workspace-title correlation
  test/
    parse.test.mjs  unit tests (node:test, run via jiti) — 16 tests
    e2e.mjs         live-daemon integration proof — drives the real tool

Build / typecheck

cd extension
npm install
npx tsc --noEmit

TypeScript must typecheck (tsc --noEmit) like the enforcement extension.

Test

Unit tests (pure, no I/O, no daemon):

JITI=/usr/local/lib/node_modules/@earendil-works/pi-coding-agent/node_modules/jiti/lib
node --import $JITI/jiti-register.mjs extension/test/parse.test.mjs
# 16 tests, 0 fail

End-to-end (live daemon, read-only) — the headline proof. Drives the real extension's registered find_agents tool against the live daemon and asserts the enforcement Overseer (727db2c5) is discoverable from a different worktree:

node --import $JITI/jiti-register.mjs extension/test/e2e.mjs
# 14 tests, 0 fail

E2E proof (recorded)

[headline: cross-worktree discovery by title]
  PASS  enforcement Overseer (727db2c5) is in results
  PASS  enforcement Overseer is in a DIFFERENT worktree than this agent
  PASS  all returned titles contain 'enforcement' (case-insensitive)
  PASS  enforcement Overseer state parsed from leading emoji
    -> 3 agent(s); overseer title: "🟢 Overseer — enforcement: graduate to repo + nixos-configs dist + shared rules corpus (delegating)"
[state filter: 🔴 agents only]
  PASS  every returned agent's title starts with 🔴
  PASS  count matches raw fleet 🔴 count
    -> 1 🔴 agent(s) (raw fleet: 1)
[caller: exclude default hides the calling agent]
  PASS  calling agent (PASEO_AGENT_ID) is excluded by default
  PASS  calling agent included when caller: self
[limit truncation]
  PASS  limit:1 returns ≤1 agent
  PASS  truncated flag set when fleet exceeds limit
[daemon scope: peer/all deferred, non-throwing]
  PASS  daemon:all returns empty agents
  PASS  daemon:all returns a note (cross-daemon deferred)
[status + workspace filters compose]
  PASS  status-filtered results are all in the requested set
  PASS  title-filtered results all match 'Overseer'
14 passed, 0 failed

E2E PROOF: find_agents discovered the enforcement Overseer (727db2c5) in a
different worktree from a same-daemon call — exactly what the cwd-scoped
MCP paseo_list_agents (no cwd) cannot do. ✅

Install (global — pending Overseer + John sign-off)

Global install loads the extension into every pi agent (incl. all Paseo agents). Not done yet — pending review.

cp -r extension ~/.pi/agent/extensions/agent-discovery
# deps (typebox, @earendil-works/pi-ai) are in extension/node_modules after npm install

Or as a pi package (once published): pi install git:git.johnogle.info/…/agent-discovery.

No daemon restart; the extension loads on the next agent session (or /reload). No daemon mutation.

API

find_agents({
  title?:             string | { regex: string },   // substring or regex on session name
  state?:              "🟢"|"🔵"|"🔴"|"🟣"|"✅"|"⛔"|"⏳",  // leading-emoji of title
  status?:             ("initializing"|"idle"|"running"|"error"|"closed")[],
  labels?:             { [key]: string },            // exact key=value (CLI --label, server-side)
  workspace?:          string,                       // substring on cwd or workspace title
  requiresAttention?:  boolean,
  includeArchived?:     boolean = false,
  sinceHours?:          number,                      // accepted; CLI exposes no timestamp → no-op
  limit?:               number = 50,                 // cap 200
  daemon?:              "local" | "peer:<id>" | "all" = "local",  // peer/all deferred (Layer 3)
  caller?:              "self" | "exclude" = "exclude",          // hide the calling agent by default
}) -> {
  agents: { id, shortId, title, state, status, cwd, workspaceTitle,
            labels, requiresAttention, attentionReason, daemon }[],
  truncated?: boolean,
  note?: string,
}

Known limitations / deviations from DESIGN.md

  • D3 deviation (CLI does not expose the rich snapshot). On this daemon paseo ls --json and paseo inspect <id> --json do not expose title (distinct from name), labels, requiresAttention, attentionReason, or workspaceId. Only the MCP paseo_get_agent_status snapshot exposes those (one agent at a time), and that is not reachable from extension code without re-implementing the daemon RPC. So:
    • name is treated as title (they are equal on this daemon — verified).
    • state is parsed from the leading emoji of name.
    • labels: {}, requiresAttention: null, attentionReason: null are returned unless/until an upstream CLI widening or a daemon-RPC read path lands.
    • The labels filter still works: passed through to the CLI as --label k=v (server-side).
    • requiresAttention filtering operates on the (null) values and is a no-op in the live path; the pure logic is unit-tested on synthetic records.
    • workspaceTitle IS populated: correlated from paseo workspace ls --json (one cheap extra call), matching the agent's cwd.
  • sinceHours is accepted for API parity but is a no-op on the CLI path (the CLI ls has no --since flag and created is a relative string, not a parseable timestamp).
  • Cross-daemon (daemon: "peer:<id>" | "all") is accepted but returns a clear "cross-daemon discovery not yet available" note (Layer 3 deferred per DESIGN.md — the bridge remoteListAgents primitive is the bridge Overseer's job). Non-throwing.
  • Composition with enforcement (D7): parse.ts is pure and is the shareable composition point; a shared parseAgentSnapshot helper and a snapshot cache are later optimizations, not required for either to ship.
S
Description
pi extension exposing an LLM-callable find_agents tool — discover Paseo agents on the local daemon (same-daemon, read-only)
Readme
84 KiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 56.4%
JavaScript 43.6%