@polygraph/claude-plugin 0.4.50 → 0.4.51
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.
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Neither is required — they are a throughput optimization, not a correctness fi
|
|
|
61
61
|
## Skills
|
|
62
62
|
|
|
63
63
|
- **polygraph** — Comprehensive guidance for Polygraph sessions: shared context, repository graph visibility, PR/CI state, delegation, and session management.
|
|
64
|
-
- **adversarial-review** — Second-opinion review
|
|
64
|
+
- **adversarial-review** — Second-opinion review by independent per-repo agents that presents and attaches one consolidated review artifact.
|
|
65
65
|
- **await-polygraph-ci** — Wait for CI pipelines to settle across all repos in a session, investigate failures, and present fix options.
|
|
66
66
|
- **get-latest-ci** — One-shot fetch of the latest CI pipeline execution for the current branch.
|
|
67
67
|
- **session-debrief** — Analyze the raw logs of past Polygraph sessions and produce structured, rank-ordered debriefs for use in a different session.
|
|
@@ -82,6 +82,18 @@ npm install
|
|
|
82
82
|
npm run sync-artifacts
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
+
Estimate the compiled prompt cost of every skill and subagent for Claude Code,
|
|
86
|
+
Codex, and OpenCode:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
npm run report:token-costs
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The report uses four characters per estimated token by default. Override the
|
|
93
|
+
ratio when needed with `npm run report:token-costs -- --characters-per-token 3.5`.
|
|
94
|
+
Pull requests run the same report when opened or updated and keep the latest
|
|
95
|
+
results in a single collapsible comment.
|
|
96
|
+
|
|
85
97
|
## Releasing
|
|
86
98
|
|
|
87
99
|
Run the `Release PR` GitHub Actions workflow with a version bump (`patch`, `minor`, or `major`).
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
name: session-debrief
|
|
4
4
|
description: Analyze the raw logs of one or more past Polygraph sessions and return a structured, rank-ordered debrief for the current task. Launch as a background agent with a ranked list of relevant Polygraph session IDs/lines and a one-paragraph statement of the current task; it invokes the session-debrief skill, pulls parent and child transcripts via the polygraph CLI, and returns one consolidated debrief. Read-only with respect to the inspected sessions.
|
|
5
|
+
model: haiku
|
|
5
6
|
|
|
6
7
|
---
|
|
7
8
|
|
|
@@ -5,7 +5,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
5
5
|
|
|
6
6
|
const HOOK_LOG_MAX_BYTES = 5 * 1024 * 1024;
|
|
7
7
|
|
|
8
|
-
const AGENT_TYPES = new Set(['claude', 'codex', 'opencode']);
|
|
8
|
+
const AGENT_TYPES = new Set(['claude', 'codex', 'opencode', 'cursor']);
|
|
9
9
|
const COMMAND_HOOK_TOOL = /^mcp__(?:plugin_polygraph_)?polygraph[-_]mcp__/;
|
|
10
10
|
const OPENCODE_TOOL = /^polygraph(?:(?:-|_)mcp)?_/;
|
|
11
11
|
|
|
@@ -89,18 +89,30 @@ export function buildCommandHookLink(payload, agentType, env = process.env) {
|
|
|
89
89
|
if (!payload || typeof payload !== 'object') return undefined;
|
|
90
90
|
if (isManagedChildEnvironment(env)) return undefined;
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
// Cursor payloads carry the id in both session_id and conversation_id;
|
|
93
|
+
// the fallback keeps the link working if one of them disappears.
|
|
94
|
+
const agentSessionId =
|
|
95
|
+
nonEmptyString(payload.session_id) ?? nonEmptyString(payload.conversation_id);
|
|
93
96
|
if (!agentSessionId) return undefined;
|
|
94
97
|
|
|
98
|
+
// Cursor has no top-level cwd; workspace_roots[0] is the launch directory.
|
|
99
|
+
const workspaceRoot = Array.isArray(payload.workspace_roots)
|
|
100
|
+
? nonEmptyString(payload.workspace_roots[0])
|
|
101
|
+
: undefined;
|
|
102
|
+
|
|
95
103
|
const common = {
|
|
96
104
|
agentType,
|
|
97
105
|
agentSessionId,
|
|
98
|
-
cwd: nonEmptyString(payload.cwd),
|
|
106
|
+
cwd: nonEmptyString(payload.cwd) ?? workspaceRoot,
|
|
99
107
|
transcriptPath: nonEmptyString(payload.transcript_path),
|
|
100
108
|
source: 'hook',
|
|
101
109
|
};
|
|
102
110
|
|
|
103
|
-
|
|
111
|
+
// Claude and Codex send PascalCase event names; cursor sends camelCase.
|
|
112
|
+
if (
|
|
113
|
+
payload.hook_event_name === 'SessionStart' ||
|
|
114
|
+
payload.hook_event_name === 'sessionStart'
|
|
115
|
+
) {
|
|
104
116
|
const polygraphSessionId = nonEmptyString(env.POLYGRAPH_SESSION_ID);
|
|
105
117
|
if (polygraphSessionId) return { ...common, polygraphSessionId };
|
|
106
118
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: adversarial-review
|
|
3
|
-
description:
|
|
3
|
+
description: Review a Polygraph session with independent per-repo reviewers and attach one consolidated review artifact.
|
|
4
4
|
|
|
5
5
|
user-invocable: true
|
|
6
6
|
allowed-tools:
|
|
@@ -14,10 +14,10 @@ allowed-tools:
|
|
|
14
14
|
|
|
15
15
|
# Adversarial Review
|
|
16
16
|
|
|
17
|
-
1.
|
|
17
|
+
1. Skip this step entirely if a reviewer agent was already named — by the user, or in the instruction that launched you (e.g. from `polygraph session review --adversarial`); in that case use that agent and do not ask. Otherwise, **pick the agent**: Ask which should review—`claude`, `codex`, or `opencode` for `spawn_agent`'s `agent` parameter. If the user names a model, pass it via `spawn_agent`'s optional `model` parameter; don't ask about models.
|
|
18
18
|
2. **Get the session description.**
|
|
19
|
-
3. **Get each repo's plan.**
|
|
20
|
-
4. **Delegate one reviewer per repo** in parallel,
|
|
21
|
-
5. **Summarize.**
|
|
22
|
-
6. **Ask what next.** Address
|
|
19
|
+
3. **Get each repo's plan.**
|
|
20
|
+
4. **Delegate one reviewer per repo** in parallel, `role: "reviewer"`. Ask to review, identify issues. Do the delegation even for the "initiator" repo.
|
|
21
|
+
5. **Summarize and attach.** Consolidate reviews into one consolidated Markdown review with per-repo sections and present it to the user. Then call `upload_artifact` once with `sessionId`, that review as `content`, `kind: "review"`, `format: "markdown"`, name `adversarial-review-YYYY-MM-DDTHH-mm-ssZ.md`. If the upload fails, report that separately without suppressing the review.
|
|
22
|
+
6. **Ask what next.** Address feedback or continue. Skip if the user already said.
|
|
23
23
|
7. If the user selects "address the feedback", pass each repo's feedback to the repo default agent (not the reviewer). The initiator should fix things itself without delegating.
|
|
@@ -20,10 +20,14 @@ spawn_agent(
|
|
|
20
20
|
repo: "<org/repo-name>",
|
|
21
21
|
instruction: "<the task instruction>",
|
|
22
22
|
role: "<optional role>",
|
|
23
|
-
context: "<optional context>"
|
|
23
|
+
context: "<optional context>",
|
|
24
|
+
agent: "<optional: claude | codex | opencode>",
|
|
25
|
+
model: "<optional model override>"
|
|
24
26
|
)
|
|
25
27
|
```
|
|
26
28
|
|
|
29
|
+
`agent` picks the child's harness and `model` overrides its default model; include either only when the user named one.
|
|
30
|
+
|
|
27
31
|
Write the instruction as if to a competent engineer who cannot see your conversation: state the goal, the constraints, and what "done" looks like. The child has its own repo and its own context; it inherits nothing from yours.
|
|
28
32
|
|
|
29
33
|
Delegate to several repos in parallel by calling `spawn_agent` once per repo before waiting on any of them.
|