@polygraph/codex-plugin 0.4.25 → 0.4.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polygraph",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "AI agent skills and subagents for Polygraph multi-repo coordination",
5
5
  "author": {
6
6
  "name": "Narwhal Technologies Inc",
@@ -23,6 +23,8 @@ The main agent provides these parameters in the prompt:
23
23
 
24
24
  Call the `spawn_agent` tool to start a child agent on the repo or to route an explicit follow-up to an active task. If the main agent supplied a `taskId` - meaning this is a user-approved follow-up turn against an already active task - forward it unchanged; otherwise omit `taskId` and a new child run is started.
25
25
 
26
+ `repo` must be a repository other than the one the parent agent is working in — never delegate into the parent's own repo. A repo has at most one active child: if it already has one, pass `taskId` to route the message to it instead of starting a new run.
27
+
26
28
  **Resume/reconstruction is read-only.** If the parent asks you to resume, reconnect, restore, or reconstruct a preserved session without an explicit new change request from the user, do not call `spawn_agent` to continue work. Use `show_agent` only as needed to read status/log context, return a concise restoration summary, and stop. After resuming, wait for explicit user instructions before any child agent makes changes.
27
29
 
28
30
  ```
@@ -28,7 +28,7 @@ The main agent provides these parameters in the prompt:
28
28
 
29
29
  Additionally, the main agent may pass in repos via **MCP resource syntax** (e.g. `polygraph://repos/org/repo-name`).
30
30
 
31
- **Direct-add rule:** If `sessionId` is provided and the prompt names exact repositories to add by ID, short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax, call `add_repo` directly with those refs in `repoIds`. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT require candidate discovery first. Candidate discovery is account-repo-only; `list_repos` is only for discovery/filtering when the user does not know the exact repo or explicitly wants candidate selection.
31
+ **Direct-add rule:** If `sessionId` is provided and the prompt names exact repositories to add by ID, short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax, call `add_repo` directly with those refs in `repoIds`. Refs are not limited to organization repos — public open-source repos can be added by `owner/repo` slug or URL, even though they never appear in `list_repos`. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT require candidate discovery first. Candidate discovery is account-repo-only; `list_repos` is only for discovery/filtering when the user does not know the exact repo or explicitly wants candidate selection.
32
32
 
33
33
  ## Workflow
34
34
 
@@ -104,7 +104,7 @@ Call `add_repo` to attach the selected repositories to the existing session —
104
104
  add_repo(sessionId: "<sessionId>", repoIds: [...])
105
105
  ```
106
106
 
107
- `repoIds` may be repository IDs from discovery, or exact refs provided by the user: short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax. For exact user-provided refs, pass the strings directly and do not call `list_repos` first.
107
+ `repoIds` may be repository IDs from discovery, or exact refs provided by the user: short name, full name, GitHub `owner/repo` slug, URL-like slug, or MCP resource syntax — including repos outside the organization, such as public open-source repos. For exact user-provided refs, pass the strings directly and do not call `list_repos` first.
108
108
 
109
109
  ### Step 4: Get Session Details
110
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polygraph/codex-plugin",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "AI agent skills and subagents for Polygraph multi-repo coordination",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: polygraph
3
- description: Guidance for coordinating changes across multiple repositories using Polygraph. Use when working on a feature that affects another repository, coordinating changes/branches/PRs across repos, delegating tasks to child agents in different repos, discovering how code is consumed across repositories, or starting a multi-repo coordination session. TRIGGER when user mentions "polygraph", "other repos", "other repositories", "who uses this", "what uses this", "cross-repo", "multi-repo", "consuming this API/endpoint", "dependent repositories", or asks about what other repos are doing with shared code/APIs/endpoints.
3
+ description: Guidance for working with Polygraph repositories, sessions, child agents, PRs, and CI. Use when discovering repositories or how code is consumed across them, starting, joining, resuming, or sharing a Polygraph session, handing off progress, coordinating changes/branches/PRs across repos, delegating tasks to child agents in different repos, or checking CI status and logs. TRIGGER when user mentions "polygraph", resuming or sharing a session, "other repos", "other repositories", "who uses this", "what uses this", "cross-repo", "multi-repo", "consuming this API/endpoint", "dependent repositories", or asks about what other repos are doing with shared code/APIs/endpoints.
4
4
 
5
5
  ---
6
6
 
7
- # Multi-Repo Coordination with Polygraph
7
+ # Working with Polygraph
8
8
 
9
- **IMPORTANT:** NEVER `cd` into cloned repositories or access their files directly. ALWAYS use Codex Polygraph subagents to invoke the Polygraph MCP `spawn_agent` tool for work in other repositories.
9
+ **IMPORTANT:** Polygraph keeps local clones only for *other* repositories in the session. NEVER `cd` into those clones or access their files directly work in other repositories ALWAYS happens through the Polygraph MCP `spawn_agent` tool, invoked via Codex Polygraph subagents.
10
10
 
11
11
  ## Critical Routing Rule (Codex Parent Conversation)
12
12
 
@@ -19,7 +19,9 @@ Read this before the tool table below — it determines which tools are yours to
19
19
  - **Allowed direct Polygraph MCP calls from the parent:** `whoami`, `login`, `list_accounts`, `select_account`, `show_session` for read-only inspection of an existing session, `update_session_description` for session metadata updates, `link_reference` for linking external references to sessions, and `add_repo` only for explicit repo additions to an existing session.
20
20
  - Do NOT pass `fork_context: true` to Codex `spawn_agent` when `agent_type` is a custom agent — Codex rejects it.
21
21
 
22
- This skill provides guidance for working on features that span multiple repositories using Polygraph for coordination.
22
+ Polygraph connects repositories and the agent work happening across them. Its central artifact is the session, which groups the repositories, branches, PRs, and CI status for one piece of work and can be shared and resumed: use it to coordinate changes across multiple repositories, and also on its own to share the session URL with collaborators, hand off progress via the session description, resume prior work, and watch CI across the session's PRs.
23
+
24
+ **Polygraph operates on the current repo in place.** Starting or joining a session never clones or modifies the repository you are in — you keep working in your real working directory, and `push_branch` pushes your local commits from that checkout. Only *other* repositories are worked on in separate Polygraph-managed clones via `spawn_agent`.
23
25
 
24
26
  ## Available Tools
25
27
 
@@ -29,10 +31,10 @@ Polygraph functionality is available via both MCP tools and CLI commands. Use wh
29
31
  | --- | --- | --- |
30
32
  | `list_repos` | `polygraph repo list` | Discover candidate repositories with descriptions and graph relationships |
31
33
  | `start_session` | `polygraph session start --repo <ids>` | Initialize a Polygraph session with selected repositories |
32
- | `spawn_agent` | — | Start a new child task or send an explicit follow-up to an active task in another repository. Input: `{ sessionId, repo, instruction, context?, taskId? }`. Output: `{ taskId, message, status: 'delegated' }`. Pass the `taskId` returned by a prior call to route a follow-up message to a specific active task; omit to start a new child run. A session resume or reconstruction is read-only context restoration; after resuming, do not use `spawn_agent` to continue changes unless the user explicitly asks for changes. |
34
+ | `spawn_agent` | — | Start a new child task or send an explicit follow-up to an active task in another repository. Input: `{ sessionId, repo, instruction, context?, taskId? }`. Output: `{ taskId, message, status: 'delegated' }`. Pass the `taskId` returned by a prior call to route a follow-up message to a specific active task; omit to start a new child run. A repo has at most one active child at a time: while a task is active in a repo, pass `taskId` to follow up — never start a second concurrent run in the same repo. A session resume or reconstruction is read-only context restoration; after resuming, do not use `spawn_agent` to continue changes unless the user explicitly asks for changes. |
33
35
  | `show_agent` | — | Poll flat per-child status for the session. Output: `{ children: PolygraphChildStatusItem[] }` where each item exposes `repositoryId`, `repoFullName`, `status`, `lastOutputLines`, `durationMs`, `instruction`, `agentType?`, `inputRequiredQuestion?`. `status` is an AcpRunStatus: `'created' \| 'in-progress' \| 'input-required' \| 'completed' \| 'failed' \| 'cancelled'` (British double-L on `'cancelled'`). `inputRequiredQuestion` is populated only when `status === 'input-required'`. |
34
36
  | `stop_agent` | — | Cancel an in-progress child. Output: `{ taskId, state: 'cancelled', sessionPreserved: true, output, message }`. Because `sessionPreserved: true`, the preserved agent session can be restored later for context, but resume must wait for explicit user instructions before making changes. |
35
- | `push_branch` | — | Push a local git branch to the remote repository. Requires a session description. |
37
+ | `push_branch` | — | Push a local git branch to the remote repository. For the repo you are in, this pushes from your current checkout. Requires a session description. |
36
38
  | `create_pr` | — | Create draft PRs with session metadata linking related PRs |
37
39
  | `show_session` | `polygraph session show <id> [--details]` | Query status of the current session. Use details when session summary, repo IDs, PR URLs, and PR descriptions are needed. |
38
40
  | `update_session_description` | `polygraph session update-description` | Set the current session description from a synthesized progress summary or user-provided text. This updates session metadata only; it does not require PR creation or mark-ready. |
@@ -40,7 +42,7 @@ Polygraph functionality is available via both MCP tools and CLI commands. Use wh
40
42
  | `mark_pr_ready` | — | Mark draft PRs as ready for review |
41
43
  | `associate_pr` | — | Associate an existing PR with a session |
42
44
  | `add_repo` | — | Add repositories to a running Polygraph session. For explicit refs, pass the refs directly and skip `list_repos`. |
43
- | `complete_session` | `polygraph session archive <id>` | Mark a session complete |
45
+ | `archive_session` | `polygraph session archive <id>` | Archive a session, hiding it from active lists (it can still be resumed) |
44
46
  | `get_ci_logs` | — | Retrieve full plain-text log for a specific CI job |
45
47
  | — | `polygraph auth login [--token]` | Authenticate with Polygraph (use `--token` for headless/CI) |
46
48
  | — | `polygraph session list` | List all sessions |
@@ -70,8 +72,10 @@ After logging in (or if logged in but no org is selected), use `polygraph accoun
70
72
 
71
73
  ## Workflow Overview
72
74
 
75
+ The delegate/monitor/stop steps apply only when working across repos. A single-repo session skips them and still benefits from shared progress, resume, and CI visibility.
76
+
73
77
  0. **Initialize or join Polygraph session** - If you were spawned inside an existing session (the startup banner names a session ID), reuse it. Call `show_session` first; if it already has repos and the user did not ask to add more, you're done. If the user asks to add exact repo refs, call `add_repo` directly with those refs and skip candidate discovery. If the session has no repos and no exact refs were provided, launch the `polygraph-init-subagent` with that `sessionId` so it discovers candidates and uses `add_repo` (NOT `start_session`). Only when there is no session ID at all should the init subagent create a new session.
74
- 1. **Delegate work to each repo** - Use the `polygraph-delegate-subagent` to start child agents in other repositories. Choose the Simple (fire-and-forget) or Multi-turn (interactive) pattern described below based on whether the child may need clarification.
78
+ 1. **Delegate work to each repo** - Use the `polygraph-delegate-subagent` to start child agents in other repositories. Delegate only to *other* repos — never to the repo you are in; work on it directly (your regular subagents are fine for local work — only Polygraph delegation is reserved for other repos). Parallel delegation across repos is encouraged, but only one active child per repo. Choose the Simple (fire-and-forget) or Multi-turn (interactive) pattern described below based on whether the child may need clarification.
75
79
 
76
80
  4. **Monitor child agents** - Use `show_agent` to poll progress and read the flat `children[]` array for each child's `status` and `lastOutputLines`.
77
81
  5. **Stop child agents** (if needed) - Use `stop_agent` to cancel an in-progress child agent. The underlying agent session is preserved for later read-only context restoration; after a resume, wait for explicit user instructions before making changes.
@@ -81,17 +85,17 @@ After logging in (or if logged in but no org is selected), use `polygraph accoun
81
85
  9. **Associate existing PRs** (optional) - Use `associate_pr` to link PRs created outside Polygraph.
82
86
  10. **Query PR status** - Use `show_session` to check progress.
83
87
  11. **Mark PRs ready** - Use `mark_pr_ready` when work is complete.
84
- 12. **Complete session** - Use `complete_session` to mark the session as completed when the user requests it.
88
+ 12. **Archive session** - Use `archive_session` to archive the session when the user requests it.
85
89
 
86
90
  ## Step-by-Step Guide
87
91
 
88
92
  ### 0. Initialize or Join Polygraph Session
89
93
 
90
- There are three cases. Pick exactly one before calling any tool.
94
+ There are three cases. Pick exactly one before calling any tool. The case labels are internal routing shorthand — never mention them in anything you show the user.
91
95
 
92
96
  **Hard rule: if a session ID is already in scope (e.g., the startup banner says "You're in Polygraph session …", or the user passed one), that session ID is authoritative for this entire conversation. NEVER call `start_session` — doing so creates a brand-new session and orphans the one the parent harness is pointed at. Reuse the existing session via `show_session` and, if needed, `add_repo`.**
93
97
 
94
- **Case A — Existing session, already has repos.** Call `show_session` directly with the known session ID. Skip the init subagent entirely. Print the session details (format below) and proceed.
98
+ **Case A — Existing session, already has repos.** Call `show_session` directly with the known session ID. Skip the init subagent entirely, show the session details (format below), and proceed.
95
99
 
96
100
  **Case B — Existing session, no repos yet (or user wants to add more).** If the user gives exact repo refs by ID, short name, full name, GitHub `owner/repo` slug, or URL-like slug, call `add_repo(sessionId, repoIds: [...])` directly with those refs. Do NOT call `list_repos`, do NOT ask for candidates, and do NOT launch the init subagent just to resolve those refs. If the user wants discovery/filtering instead, launch the `polygraph-init-subagent`, passing both the existing `sessionId` and `userContext`. The subagent will discover candidates, select relevant repositories, and call `add_repo` against the existing session — it will NOT call `start_session`.
97
101
 
@@ -131,9 +135,9 @@ The subagent will:
131
135
  4. Call `show_session` to retrieve session details
132
136
  5. Return a summary with session URL and repo info
133
137
 
134
- **Case C only — new session just created:** After the init subagent completes and creates the new session, render the session welcome card (skip the session-details block below for this case). Prefer the `session_intro` MCP tool — call it with the session ID; it returns the card as markdown. If that tool is unavailable, run `polygraph session intro -s <sessionId>` via the CLI instead. Either way, print the result to the user verbatim as markdown — do NOT wrap it in a code block or reformat it (the logo is pre-fenced; the rest is live markdown). It needs no other input, and you do not need to call `show_session` first. Then continue (ask the user what they want, or start the requested task).
138
+ **When the init subagent has just created a brand-new session,** render the session welcome card instead of the session-details block below. Prefer the `session_intro` MCP tool — call it with the session ID; it returns the card as markdown. If that tool is unavailable, run `polygraph session intro -s <sessionId>` via the CLI instead. The CLI command is intentionally hidden/internal and may not appear in public command listings, but it remains the correct skill fallback for rendering the welcome card. Either way, print the result to the user verbatim as markdown — do NOT wrap it in a code block or reformat it (the logo is pre-fenced; the rest is live markdown). It needs no other input, and you do not need to call `show_session` first. Then continue (ask the user what they want, or start the requested task).
135
139
 
136
- **After receiving the subagent's summary (Case B) or after calling `show_session` for an existing session (Case A), print the session details:**
140
+ **For an existing session after `show_session` returns or the init subagent's summary arrives — show the session details:**
137
141
 
138
142
  **Session:** POLYGRAPH_SESSION_URL
139
143
 
@@ -169,7 +173,7 @@ Use this workflow when the user gives a Polygraph session ID and asks to underst
169
173
  - PR description
170
174
  5. If the request was resume/reconnect/reconstruct only, report the restored session context and wait for the user's next instruction.
171
175
  6. If the user explicitly asked to inspect or investigate prior work, use the PR descriptions and session summary to decide whether more repo investigation is needed.
172
- 7. If the repo to investigate is already part of the session, delegate directly to that repo.
176
+ 7. If the repo to investigate is already part of the session, delegate directly to that repo (unless it is the repo you are in — investigate that one directly).
173
177
  8. If the repo to investigate is not currently initialized in the session, and either the user provided an exact repo ref or the repo appears in `<repositories>`, call `add_repo` with that ref or repo `<id>` directly. Do not call `list_repos` just to resolve the repo.
174
178
  9. After `add_repo`, call `show_session` again to verify the repo was added, then delegate to that repo.
175
179
  10. Fall back to `list_repos` only when the desired repo is not an exact ref and is missing from `<repositories>`, or when the details output came from an older Polygraph version that did not include repo IDs.
@@ -212,7 +216,7 @@ spawn_agent(
212
216
  )
213
217
  ```
214
218
 
215
- 2. Delegate to multiple repos in parallel by launching multiple `polygraph-delegate-subagent` instances before waiting for results.
219
+ 2. Delegate to multiple repos in parallel by launching multiple `polygraph-delegate-subagent` instances before waiting for results — one delegation per repo at a time.
216
220
  3. For each child, the subagent watches `child.status` in the flat `children[]` response and exits when it sees a terminal status — typically `'completed'` or `'failed'` (and `'cancelled'` if it was stopped).
217
221
  4. Collect completed results with `wait_agent` when the main flow needs them, then continue to `push_branch` + `create_pr`.
218
222
 
@@ -282,6 +286,8 @@ The `allow_agent` and `deny_agent` tools exist for parents whose MCP clients do
282
286
 
283
287
  Once work is complete in a repository, push the branch using `push_branch`. This must be done before creating a PR.
284
288
 
289
+ `push_branch` pushes from the local checkout: for the repo you are in, that is your current working directory with your commits; for delegated repos, it is the Polygraph-managed clone the child agent worked in. There is no separate session copy of the current repo.
290
+
285
291
  **Parameters:**
286
292
 
287
293
  - `sessionId` (required): The Polygraph session ID
@@ -548,6 +554,8 @@ Use `add_repo` to add repositories to an existing Polygraph session after it has
548
554
 
549
555
  **Direct-add rule:** When the user provides exact repo refs by ID, short name, full name, GitHub `owner/repo` slug, or URL-like slug, pass those refs directly to `add_repo` and do not call `list_repos` first. Candidate discovery remains account-repo-only and is only for cases where the user does not know the exact repo or asks to choose/filter candidates.
550
556
 
557
+ **Not limited to your organization:** repos outside the org — including public open-source repos — can be added by GitHub `owner/repo` slug or URL. Only `list_repos` discovery is org-scoped, so a repo missing from `list_repos` can still be added directly.
558
+
551
559
  **Parameters:**
552
560
 
553
561
  - `sessionId` (required): The Polygraph session ID
@@ -556,43 +564,33 @@ Use `add_repo` to add repositories to an existing Polygraph session after it has
556
564
  ```
557
565
  add_repo(
558
566
  sessionId: "<session-id>",
559
- repoIds: ["nrwl/ocean"]
567
+ repoIds: ["org/repo-name", "facebook/react"]
560
568
  )
561
569
  ```
562
570
 
563
- ### 8. Complete Session
571
+ ### 8. Archive Session
564
572
 
565
- **IMPORTANT: Only call this tool when the user explicitly asks to complete or close the session.** Do not automatically complete sessions as part of the workflow.
573
+ **IMPORTANT: Only call this tool when the user explicitly asks to archive or close the session.** Do not archive sessions automatically as part of the workflow.
566
574
 
567
- **Warning:** Completing a session seals it from further modifications. Only complete a session when the user explicitly confirms they are done coordinating the session.
568
-
569
- Use `complete_session` to mark the session as completed. Completing a session will:
570
-
571
- - **Mark the session as completed** and sealed from further modifications (no new PRs, status changes, etc.)
572
-
573
- This is idempotent — completing an already-completed session returns success.
575
+ Use `archive_session` (CLI: `polygraph session archive <id>`) to archive the session. Archiving only hides the session from active lists it can still be resumed and interacted with afterwards. It is idempotent — archiving an already-archived session returns success.
574
576
 
575
577
  **Parameters:**
576
578
 
577
579
  - `sessionId` (required): The Polygraph session ID
578
- - `clean` (optional): Remove local session worktrees after marking the session complete
580
+ - `clean` (optional): Remove the local clones Polygraph created for delegated repos after archiving
579
581
 
580
582
  **Returns:**
581
583
 
582
584
  - `sessionId`: The session ID
583
- - `completed`: Boolean indicating completion status
585
+ - `completed`: Boolean indicating the session is archived
584
586
 
585
587
  ```
586
- complete_session(
588
+ archive_session(
587
589
  sessionId: "<session-id>"
588
590
  )
589
591
  ```
590
592
 
591
- **When to call:**
592
-
593
- - After all cross-repo work is finished
594
- - All PRs have been created and marked ready for review
595
- - The user explicitly confirms they want to close all PRs and seal the session
593
+ **When to call:** all work is finished, PRs are created and marked ready, and the user explicitly confirms they are done with the session.
596
594
 
597
595
  ## Other Capabilities
598
596
 
@@ -685,4 +683,4 @@ If the session has a description timeline, also display:
685
683
  1. **NEVER call the Polygraph MCP `spawn_agent` or `show_agent` directly for routine delegation**. These MUST run inside `polygraph-delegate-subagent`.
686
684
 
687
685
  1. **Use `stop_agent` to clean up** — Stop child agents that are stuck or no longer needed. The child's session is preserved (`sessionPreserved: true`) so the context can be restored later, but after resuming you must wait for explicit user instructions before making changes.
688
- 1. **Only complete sessions when asked** — Only call `complete_session` when the user explicitly requests it. Completing a session seals it from further modifications. Do not automatically complete sessions.
686
+ 1. **Only archive sessions when asked** — Only call `archive_session` when the user explicitly requests it. Archiving hides the session from active lists; it can still be resumed later.