@pharaoh-so/mcp 0.3.19 → 0.3.20

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.
@@ -2,4 +2,285 @@
2
2
  description: Architecture-aware code review with Pharaoh
3
3
  ---
4
4
 
5
- Invoke the `pharaoh-review` skill to handle this request. Pass through any arguments: $ARGUMENTS
5
+ # Review with Pharaoh
6
+
7
+ The definitive code review. Architecture-aware, branch-aware, multi-agent, adversarial. Five phases that combine Pharaoh's knowledge graph with parallel specialized reviewers and an independent cross-model second opinion.
8
+
9
+ Final verdict: **SHIP** / **SHIP WITH CHANGES** / **BLOCK**
10
+
11
+ ## When to Use
12
+
13
+ Before merging any branch. Before opening any PR. When reviewing changes that touch shared modules, export new functions, modify core data flows, or claim to implement a spec.
14
+
15
+ ---
16
+
17
+ ## Phase 0 — Git Context
18
+
19
+ **Goal:** Know exactly what changed and where you are. This phase is mandatory and runs before anything else.
20
+
21
+ 1. Detect the current environment:
22
+ ```bash
23
+ git rev-parse --show-toplevel # repo root (may be a worktree)
24
+ git worktree list # detect if running in a worktree
25
+ git branch --show-current # current branch name
26
+ git log --oneline -1 # latest commit
27
+ ```
28
+
29
+ 2. Determine the base branch (what this branch diverged from):
30
+ ```bash
31
+ git merge-base HEAD main # or master, or whatever the default is
32
+ ```
33
+
34
+ 3. Collect the full changeset from the base:
35
+ ```bash
36
+ git diff --name-only $(git merge-base HEAD main)...HEAD # all changed files
37
+ git diff --stat $(git merge-base HEAD main)...HEAD # summary stats
38
+ git log --oneline $(git merge-base HEAD main)..HEAD # all commits on this branch
39
+ ```
40
+
41
+ 4. Also check for uncommitted work:
42
+ ```bash
43
+ git diff --name-only # unstaged changes
44
+ git diff --cached --name-only # staged but uncommitted
45
+ ```
46
+
47
+ 5. Extract the **touched modules** from the changed file paths. Group files by their top-level directory or module boundary. These module names feed Phase 1.
48
+
49
+ **Output of Phase 0:** Branch name, base branch, commit count, list of changed files, list of touched modules, and whether there's uncommitted work.
50
+
51
+ ---
52
+
53
+ ## Phase 1 — Pharaoh Recon
54
+
55
+ **Goal:** Get the full architectural picture in one call. Do NOT skip this phase — it is what makes this review architecture-aware instead of just a code diff review.
56
+
57
+ Call `pharaoh_recon` with:
58
+ - **repo:** The repository name
59
+ - **include_map:** `true`
60
+ - **modules:** The touched modules from Phase 0 (up to 5)
61
+ - **blast_radius:** The most critical changed files/functions as blast radius targets (up to 3). Pick the files with the most downstream risk — entry points, shared utilities, exported APIs.
62
+ - **dependencies:** Pairs of touched modules to trace coupling between (up to 3)
63
+
64
+ Then call these additional tools for data recon doesn't cover:
65
+ - `get_regression_risk` — overall change risk score for the repo
66
+ - `get_consolidation_opportunities` — duplicate logic the PR may introduce
67
+ - `check_reachability` — are new exports wired to entry points?
68
+ - `get_vision_gaps` — do changes align with or drift from specs?
69
+
70
+ **Output of Phase 1:** Architecture map, module profiles for every touched module, blast radius for high-risk changes, dependency paths between coupled modules, regression risk level, duplication findings, reachability status, and spec alignment.
71
+
72
+ ---
73
+
74
+ ## Phase 2 — Parallel Specialized Review
75
+
76
+ **Goal:** Deep-dive the actual code changes from multiple expert angles simultaneously. Launch these as **parallel subagents** — they are independent and should run concurrently.
77
+
78
+ ### Determine which reviewers to dispatch
79
+
80
+ | Agent | When to dispatch | Focus |
81
+ |-------|-----------------|-------|
82
+ | **Code Reviewer** | Always | Bugs, logic errors, CLAUDE.md compliance, code quality. Confidence-filtered (only issues >= 80/100). |
83
+ | **Security Reviewer** | When changes touch auth, encryption, tokens, tenant isolation, data access, billing, webhooks, Cypher queries, or any security-sensitive surface. Also dispatch when Phase 1 regression risk is HIGH. | OWASP Top 10, injection vectors, access control bypasses, tenant isolation violations, cryptographic misuse, secret exposure, plus project-specific security rules. See checklist below. |
84
+ | **Silent Failure Hunter** | When changes touch error handling, catch blocks, fallback logic, API calls, or any code that could suppress errors | Silent failures, broad catches, swallowed errors, missing user feedback, unjustified fallbacks. |
85
+ | **Test Analyzer** | When test files are changed, or when new functionality lacks corresponding tests | Behavioral coverage gaps, brittle tests, missing edge cases, tests that prove nothing. |
86
+ | **Type Design Analyzer** | When new types/interfaces are introduced or existing types are modified | Encapsulation, invariant expression, invariant enforcement. Rates each type 1-10 on four axes. |
87
+
88
+ ### Security Reviewer — Checklist
89
+
90
+ The Security Reviewer agent runs a systematic audit against two layers: universal web security (OWASP) and project-specific invariants.
91
+
92
+ **Layer 1 — OWASP Top 10 + Common Vulnerabilities:**
93
+ - **Injection:** SQL/Cypher injection, command injection, XSS (reflected/stored/DOM), template injection
94
+ - **Broken auth:** Hardcoded credentials, weak token generation, missing expiry, session fixation
95
+ - **Broken access control:** Missing authorization checks, IDOR, privilege escalation, path traversal
96
+ - **Cryptographic failures:** Weak algorithms, plaintext secrets, missing encryption at rest/transit, key exposure
97
+ - **Security misconfiguration:** Permissive CORS, verbose error messages leaking internals, debug endpoints in production
98
+ - **Vulnerable dependencies:** Known CVEs in direct dependencies (check against changed package.json/lockfile)
99
+ - **SSRF:** Unvalidated URLs in fetch/request calls, redirect chains
100
+ - **Logging & monitoring:** Sensitive data in logs, missing audit trails for privileged operations
101
+
102
+ **Layer 2 — Project-Specific Security Rules (from CLAUDE.md):**
103
+ - Every Cypher query takes `repo` as first parameter — no unanchored MATCH clauses
104
+ - `validateRepoOwnership()` runs before every tool handler
105
+ - No default/fallback repo values — repo always from tenant's Postgres `tenant_repos`
106
+ - Tokens stored as SHA-256 hashes, never plaintext
107
+ - GitHub tokens encrypted at rest (AES-256-GCM with per-tenant HKDF-derived keys)
108
+ - Webhook signatures verified on every request (`PHARAOH_GITHUB_WEBHOOK_SECRET`)
109
+ - Org membership re-checked on every token refresh
110
+ - Tenant Neo4j users get `reader` role only — graph writes use admin connection
111
+ - Rate limiting enforced per tenant, not per user
112
+ - Neo4j admin credentials never leave server-side env vars
113
+
114
+ **Detection triggers (auto-dispatch when changed files match):**
115
+ - `src/auth/**`, `src/crypto/**` — authentication, encryption
116
+ - `src/mcp/server.ts`, `src/mcp/tenant-resolver.ts` — session management, tenant isolation
117
+ - `src/mcp/neo4j-queries.ts` — Cypher query construction
118
+ - `src/stripe/**`, `src/web/routes/billing.ts` — payment flows
119
+ - `src/github/webhooks.ts`, `src/web/routes/webhooks.ts` — webhook verification
120
+ - `src/db/**` — database access, schema changes
121
+ - `src/upload/**` — file upload validation
122
+ - Any file containing `validateRepoOwnership`, `runQuery`, `encryptProperty`, `verifyWebhookSignature`
123
+
124
+ **Output format:** Each finding must include:
125
+ 1. Vulnerability class (e.g., "Cypher Injection", "Missing Ownership Check")
126
+ 2. Severity: CRITICAL / HIGH / MEDIUM
127
+ 3. Affected file:line
128
+ 4. Attack scenario: how an attacker would exploit this
129
+ 5. Remediation: specific code change required
130
+
131
+ ### How to dispatch each agent
132
+
133
+ For each agent, launch a subagent (via the Agent tool) with:
134
+ 1. The **git diff** of the relevant changed files (not the full session history)
135
+ 2. The **Pharaoh context** from Phase 1 (architecture map, blast radius, module profiles) — this is what makes these agents architecture-aware
136
+ 3. The **CLAUDE.md rules** relevant to the review (testing requirements, security non-negotiables, code style)
137
+ 4. A clear instruction to focus ONLY on changed code, not pre-existing issues
138
+ 5. For the **Security Reviewer** specifically: include the full Layer 2 checklist above and the list of security-sensitive file paths so it knows the project's threat model
139
+
140
+ Each agent returns a structured report with findings categorized by severity:
141
+ - **CRITICAL** (90-100): Must fix before merge
142
+ - **IMPORTANT** (80-89): Should fix before merge
143
+ - **SUGGESTION** (70-79): Consider for a follow-up
144
+
145
+ ### What NOT to dispatch
146
+
147
+ - **Comment Analyzer** and **Code Simplifier** are polish agents. Do not include them in the review — they distract from correctness. Run them separately if wanted.
148
+ - Do not dispatch agents for trivial changes (typo fixes, dependency bumps, config changes). If Phase 0 shows < 20 lines changed across non-test files, skip Phase 2 entirely and go straight to Phase 4.
149
+
150
+ ---
151
+
152
+ ## Phase 3 — Adversarial Review
153
+
154
+ **Goal:** Independent second opinion on security-sensitive changes. A different agent evaluates the code fresh, without knowledge of your reasoning.
155
+
156
+ ### When to trigger
157
+
158
+ Trigger Phase 3 when ANY of these are true:
159
+ - Changes touch **auth, encryption, access control, token handling, or session management**
160
+ - Changes touch **tenant isolation, query construction, or data access patterns**
161
+ - Changes touch **billing, subscription management, or payment flows**
162
+ - Changes modify **webhook verification or signature checking**
163
+ - Regression risk from Phase 1 is **HIGH**
164
+ - You are not confident about a specific change's correctness
165
+
166
+ If none of these triggers are met, **skip Phase 3** and proceed to Phase 4.
167
+
168
+ ### How to run
169
+
170
+ 1. **Prepare a review package** — do NOT send your session history:
171
+ - The changed files (full diff or complete file contents)
172
+ - What the code does and why it was changed (1-2 sentences)
173
+ - Security constraints from CLAUDE.md (tenant isolation rules, encryption requirements, etc.)
174
+ - Specific concerns you want the reviewer to focus on
175
+
176
+ 2. **Dispatch to an independent subagent** with instructions to evaluate the code fresh and assign verdicts:
177
+
178
+ | Verdict | Meaning |
179
+ |---------|---------|
180
+ | **AGREE** | Implementation is correct for the stated concern |
181
+ | **DISAGREE** | Concrete issue identified with evidence and suggested fix |
182
+ | **CONTEXT** | Cannot determine correctness — needs more information |
183
+
184
+ 3. **Evaluate findings:**
185
+ - AGREE items: no action
186
+ - DISAGREE items: verify against actual code. If confirmed, it becomes a CRITICAL finding. If the reviewer lacked context, document why the current approach is correct.
187
+ - CONTEXT items: provide the missing information and note it in the review output
188
+
189
+ ---
190
+
191
+ ## Phase 4 — Synthesis & Verdict
192
+
193
+ **Goal:** Merge all findings into a single, actionable review. No raw dumps — synthesize.
194
+
195
+ ### Structure the output as:
196
+
197
+ ```markdown
198
+ # Review: [branch-name] → [base-branch]
199
+
200
+ **[X] commits | [Y] files changed | [Z] modules touched**
201
+ **Worktree:** [path] (or "main repo")
202
+
203
+ ---
204
+
205
+ ## Architecture Impact
206
+ - Modules affected: [list with blast radius numbers]
207
+ - Dependency changes: [new coupling, removed coupling]
208
+ - Highest blast radius: [module/function] → [N downstream callers across M modules]
209
+
210
+ ## Risk Assessment
211
+ - Regression risk: [LOW / MEDIUM / HIGH] — [one-line reason]
212
+ - Volatile modules touched: [list, if any]
213
+ - Wiring status: [all new exports reachable? / N unreachable exports found]
214
+
215
+ ## Code Quality ([N] findings)
216
+
217
+ ### Critical ([count])
218
+ - [finding with file:line, source agent, and fix]
219
+
220
+ ### Important ([count])
221
+ - [finding with file:line, source agent, and fix]
222
+
223
+ ### Suggestions ([count])
224
+ - [finding with file:line]
225
+
226
+ ## Security ([N] findings, or "No security-sensitive changes")
227
+ - [Security reviewer findings with vulnerability class, severity, file:line, attack scenario, and remediation]
228
+ - [Or: "Security reviewer not dispatched — no security-sensitive files in changeset"]
229
+
230
+ ## Test Coverage
231
+ - [Test analyzer summary — gaps, quality issues, positive observations]
232
+
233
+ ## Spec Alignment
234
+ - [Vision gaps introduced or resolved]
235
+
236
+ ## Adversarial Review
237
+ - [Phase 3 results, or "Skipped — no security-sensitive changes detected"]
238
+
239
+ ---
240
+
241
+ ## Verdict: [SHIP / SHIP WITH CHANGES / BLOCK]
242
+
243
+ [If not SHIP: numbered list of specific required changes before merge]
244
+ ```
245
+
246
+ ### Auto-block triggers (any of these = BLOCK)
247
+
248
+ - Any CRITICAL security finding (injection, broken access control, tenant isolation violation, secret exposure)
249
+ - Unreachable exports (new public code with zero callers)
250
+ - New circular dependencies between modules
251
+ - HIGH regression risk without corresponding test coverage
252
+ - Vision spec violations (building against spec intent)
253
+ - Any CRITICAL finding from Phase 2 or Phase 3 that is confirmed and unfixed
254
+ - DISAGREE verdict from adversarial review on security-sensitive code, confirmed after verification
255
+ - Unanchored Cypher query (MATCH without traversing through `Repo {name: $repo}`)
256
+ - Missing `validateRepoOwnership()` on a new tool handler
257
+
258
+ ### SHIP WITH CHANGES triggers
259
+
260
+ - IMPORTANT findings that are confirmed but non-blocking
261
+ - Test coverage gaps for new functionality
262
+ - Duplication that should be consolidated in a follow-up
263
+ - Spec drift that is intentional but should be documented
264
+
265
+ ### SHIP triggers
266
+
267
+ - No CRITICAL or confirmed IMPORTANT findings
268
+ - All new exports are reachable
269
+ - Regression risk is LOW or MEDIUM with adequate test coverage
270
+ - Spec alignment is clean or intentionally divergent with documentation
271
+
272
+ ---
273
+
274
+ ## Quick Mode
275
+
276
+ For small changes (< 50 lines, single module, no security surface):
277
+ - Run Phase 0 + Phase 1 + Phase 4 only
278
+ - Skip Phase 2 (parallel agents) and Phase 3 (adversarial)
279
+ - Still architecture-aware, just faster
280
+
281
+ Explicitly opt in with: `/review quick`
282
+ ---
283
+
284
+ Here is the task to review:
285
+
286
+ $ARGUMENTS
@@ -0,0 +1,101 @@
1
+ ---
2
+ description: Decompose work into parallel, isolated sessions using git worktrees
3
+ ---
4
+
5
+ # Session Decomposition
6
+
7
+ Break large tasks into parallel, isolated work sessions. Each session runs in its own git worktree with fresh context, focused scope, and atomic commits.
8
+
9
+ ## When to Use
10
+
11
+ - Task is too large for a single context window
12
+ - Work has 3+ independent sub-tasks that don't touch the same files
13
+ - You need to preserve context quality across a multi-hour effort
14
+ - Multiple features or fixes can proceed in parallel
15
+
16
+ ## Do Not Use When
17
+
18
+ - Sub-tasks share files or state
19
+ - Work is sequential (each step depends on the previous)
20
+ - Task fits comfortably in one session
21
+
22
+ ## Step 1: Reconnaissance
23
+
24
+ If Pharaoh MCP tools are available, call `get_codebase_map` and `get_module_context` on affected modules to understand the current landscape before decomposing.
25
+
26
+ ## Step 2: Decompose
27
+
28
+ Break the task into sessions. Each session must:
29
+
30
+ - Have a clear, narrow goal (one feature, one fix, one module)
31
+ - Touch a distinct set of files — no overlap between sessions
32
+ - Be independently verifiable (tests pass, build succeeds)
33
+ - Produce atomic commits that make sense on their own
34
+
35
+ ## Step 3: Write Session Prompts
36
+
37
+ For each session, write a complete prompt containing:
38
+
39
+ - **Goal:** what this session produces (1-2 sentences)
40
+ - **Scope:** which files/modules to touch (explicit list)
41
+ - **Constraints:** what NOT to change
42
+ - **Verification:** how to confirm the work is correct
43
+ - **Context:** any architectural decisions or patterns to follow
44
+
45
+ ## Step 4: Present for Review (MANDATORY — do NOT skip)
46
+
47
+ **STOP. Paste every session prompt into the chat as a numbered list.**
48
+
49
+ For each session, show:
50
+ 1. The session name
51
+ 2. The full prompt text
52
+ 3. Which sessions need `/plan` review (flag anything non-trivial)
53
+
54
+ **Wait for the user to approve, modify, add, remove, or reorder sessions before proceeding.** Do not create worktrees or execute any work until the user explicitly approves the decomposition.
55
+
56
+ If the user says "looks good" or similar, proceed. If they request changes, update the prompts and present again.
57
+
58
+ ## Step 5: Create Worktrees
59
+
60
+ Only after user approval. For each session, create an isolated worktree:
61
+
62
+ ```bash
63
+ git worktree add .worktrees/<session-name> -b <branch-name>
64
+ ```
65
+
66
+ Install dependencies in each worktree. Verify clean baseline (tests pass).
67
+
68
+ ## Step 6: Execute Sessions
69
+
70
+ Run each session independently. Sessions should not reference each other's work-in-progress — they operate on the same base commit.
71
+
72
+ ## Step 7: Integrate
73
+
74
+ After all sessions complete:
75
+
76
+ 1. Verify each branch independently (tests pass, build succeeds)
77
+ 2. Merge branches sequentially into the target branch
78
+ 3. Resolve any conflicts (rare if decomposition was clean)
79
+ 4. Run full verification on the integrated result
80
+
81
+ ## Decomposition Rules
82
+
83
+ | Good decomposition | Bad decomposition |
84
+ |---|---|
85
+ | Session A: auth module, Session B: billing module | Session A: backend, Session B: frontend (likely share types) |
86
+ | Session A: new feature, Session B: unrelated bugfix | Session A: write code, Session B: write tests (coupled) |
87
+ | Session A: parser, Session B: renderer (clear interface) | Session A: first half of file, Session B: second half |
88
+
89
+ ## Key Principles
90
+
91
+ - **No shared files** — if two sessions touch the same file, merge them into one
92
+ - **Fresh context per session** — don't carry state between sessions
93
+ - **Atomic commits** — each session's output should be a coherent, reviewable unit
94
+ - **Verify before integrating** — never merge a session that doesn't pass its own checks
95
+ - **Decomposition is the hard part** — spend time getting boundaries right before starting work
96
+ - **The user reviews before execution** — always present prompts, never skip to building
97
+ ---
98
+
99
+ Here is the task to decompose into sessions:
100
+
101
+ $ARGUMENTS
@@ -227,11 +227,6 @@
227
227
  "all"
228
228
  ]
229
229
  },
230
- "min_usage": {
231
- "default": 0,
232
- "description": "Minimum number of files importing the component (0 = show all)",
233
- "type": "number"
234
- },
235
230
  "include_screens": {
236
231
  "default": false,
237
232
  "description": "Include screen/page components (*Screen, *Page, *View, *Route) that are typically app-level consumers, not reusable primitives",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pharaoh-so/mcp",
3
3
  "mcpName": "so.pharaoh/pharaoh",
4
- "version": "0.3.19",
4
+ "version": "0.3.20",
5
5
  "description": "MCP proxy for Pharaoh — maps codebases into queryable knowledge graphs for AI agents. Enables Claude Code in headless environments (VPS, SSH, CI) via device flow auth.",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",