jev-cognitive-mcp 0.4.4__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 jev-cognitive-mcp Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: jev-cognitive-mcp
3
+ Version: 0.4.4
4
+ Summary: Advisory 3+1 Cognitive Hierarchy Toolkit & Model Context Protocol (MCP) Server for Agentic Coding: Pre-Tool Risk Screening, Dynamic Task Routing, Candidate Ranking, and Evidence Review.
5
+ Author: jev-cognitive-mcp maintainers
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/17671454333/jev-cognitive-mcp
8
+ Project-URL: Repository, https://github.com/17671454333/jev-cognitive-mcp
9
+ Project-URL: Issues, https://github.com/17671454333/jev-cognitive-mcp/issues
10
+ Project-URL: Changelog, https://github.com/17671454333/jev-cognitive-mcp/releases
11
+ Keywords: mcp,model-context-protocol,ai-agents,codex,security-guardrails,model-router,system1-system2,llm-verification
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # jev-cognitive-mcp
31
+
32
+ **English** · [简体中文](README.zh-CN.md)
33
+
34
+ [![CI](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml)
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)
36
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
37
+ [![MCP Protocol](https://img.shields.io/badge/MCP-2024--11--05-purple.svg)](jev_kit/mcp_server.py)
38
+
39
+ **Advisory 3+1 Cognitive Hierarchy Toolkit & Model Context Protocol (MCP) Server for Coding Agents (OpenAI Codex CLI, Claude Code, Cursor, Antigravity).**
40
+
41
+ `jev-cognitive-mcp` provides deterministic Layer-0 DLP/destructive command pre-screening, 5-factor Meta-Controller escalation arbitration, and optional System-1 probabilistic triage (`guard`, `route`, `verify`, `rerank`) over stdio MCP. All verdicts and routing signals are **advisory**—the host agent remains responsible for enforcing command blocking, sandboxing, and human-in-the-loop approval gates.
42
+
43
+ ---
44
+
45
+ ## Architecture: The 3+1 Cognitive Hierarchy
46
+
47
+ ```mermaid
48
+ flowchart LR
49
+ A["Incoming Agent Action / Task"] --> L0["Layer 0: Deterministic Reflex<br/>(0 network / 0 token cost)<br/>DLP regex & destructive pattern screen"]
50
+ L0 -->|Blocked / Matched| OUT0["Immediate Advisory Verdict"]
51
+ L0 -->|Needs Semantic Triage| S1["System 1: Probabilistic Intuition (JEV)<br/>(Requires external JevBridge)<br/>Guard / Route / Rerank / Verify"]
52
+ S1 --> MC{"Meta-Controller<br/>5-Factor Arbitration"}
53
+ MC -->|High Confidence & Two-Way Door| OUT1["Advisory Fast Path"]
54
+ MC -->|Low Confidence / High Risk| S2["System 2: Host Frontier LLM<br/>(Codex / o3 / Sonnet Thinking)"]
55
+ MC -->|One-Way Door & High Risk| HG["Explicit Human Gate Required"]
56
+ ```
57
+
58
+ | Layer | Role | Execution Mode | Responsibility |
59
+ |---|---|---|---|
60
+ | **Layer 0 (Reflex)** | Deterministic Code | Local offline (`0 tokens`, no network call) | Pre-egress regex DLP credential screening (`sk-*`, `sk-ant-*`, `ghp_*`, `glpat-*`, `AKIA*`, `SG.*`, `pypi-*`, `hf_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM keys), destructive shell pattern matching (`rm -rf /`, `rm -rf -- /`, `Remove-Item -Recurse -Force`, `mkfs`, `wipefs -a`, `shred -u /`, `DROP DATABASE`, `curl \| bash`), strict schema validation |
61
+ | **System 1 (Intuition)** | Probabilistic JEV | External `JevBridge` single-attempt call | Multi-head `noul` (boolean probability), `choice` (categorical distribution), and `score` (0..4 ordinal rubric) evaluations |
62
+ | **System 2 (Reasoning)** | Host Frontier LLM | Host agent runtime | Complex causal reasoning, multi-file architecture design, subtle debugging |
63
+ | **Meta-Controller** | Control Plane | Local offline (`0 tokens`, no network call) | Arbitrates escalation using 5 quantitative signals: **Confidence**, **Risk**, **Reversibility**, **Expected Value**, and **Cost Pressure** |
64
+
65
+ ---
66
+
67
+ ## Core Modules & MCP Tools
68
+
69
+ 1. **`jev_guard` (`jev_kit.guard`) — Advisory Pre-Tool Command Risk Screen**
70
+ - Evaluates shell commands before execution and returns an advisory action (`ALLOW`, `INSPECT`, `ESCALATE_HUMAN`, or `BLOCK`).
71
+ - **Layer 0 (`reflex_only=true` or pre-screen)**: Blocks literal credential egress (`SENSITIVE_INPUT_REJECTED`) and known destructive shell/PowerShell patterns locally with zero network calls.
72
+ - **System 1 (when `reflex_only=false`)**: Evaluates `is_destructive`, `is_rce_or_exfil`, and `is_secret_leak` probabilities via `JevBridge`.
73
+ 2. **`jev_arbitrate` (`jev_kit.controller`) — Offline 5-Factor Meta-Controller**
74
+ - Purely deterministic calculation of expected escalation utility from `(confidence, risk, reversible, expected_value, cost_pressure)`. Recommends `human_gate` on irreversible high-risk actions. Works completely offline.
75
+ 3. **`jev_route` (`jev_kit.router`) — Advisory Task & Model Tier Router**
76
+ - Classifies incoming coding prompts into `FAST` (`codex-mini-latest`, `gpt-4o-mini`), `STANDARD` (`gpt-4.1`, `gpt-4o`), or `DEEP_REASONING` (`o3`, `codex-1`) tiers while estimating architectural scope.
77
+ 4. **`jev_verify` (`jev_kit.verifier`) — Caller-Supplied Completion & Acceptance Review**
78
+ - Reviews caller-supplied `task_spec`, `implemented_changes` summary, and `test_results` logs to return `PASS`, `ADVISORY`, or `NEEDS_REVISION`. Does **not** inspect git repositories or run test suites directly.
79
+ 5. **`jev_rerank` (`jev_kit.reranker`) — Bounded Semantic Candidate Reranker**
80
+ - Ranks up to 96 caller-supplied code snippets or issue candidates in deterministic batches of 12 while preserving full provenance and failing closed on partial batch errors.
81
+
82
+ ---
83
+
84
+ ## Offline Deterministic Mode vs. External `JevBridge` Requirement
85
+
86
+ - **Works 100% Offline (Zero External Dependencies)**:
87
+ - `jev_arbitrate` (5-factor Meta-Controller)
88
+ - `jev_guard` with `reflex_only=true` (`jev-kit guard "<cmd>" --reflex-only`)
89
+ - `jev-kit init-codex` (configuration generator for OpenAI Codex CLI and MCP clients)
90
+ - Pre-egress credential DLP screening inside `call_jev()` (blocks sensitive tokens before any bridge lookup)
91
+ - **Requires External `JevBridge` Runtime**:
92
+ - `jev_guard` (when `reflex_only=false` and Layer 0 does not match), `jev_route`, `jev_verify`, and `jev_rerank` invoke `jev_cli.py` from the local `JevBridge` runtime directory.
93
+ - Set `JEV_BRIDGE_DIR=/path/to/JevBridge/runtime` (defaults to `%LOCALAPPDATA%\JevBridge\runtime` on Windows or `~/.local/share/JevBridge/runtime` on Linux/macOS). If the bridge runtime is not installed, these tools fail closed with `JevIntegrationError(code="BRIDGE_MISSING")`.
94
+
95
+ ---
96
+
97
+ ## Quick Start
98
+
99
+ ### 1. Installation
100
+
101
+ ```bash
102
+ git clone https://github.com/17671454333/jev-cognitive-mcp.git
103
+ cd jev-cognitive-mcp
104
+ pip install -e ".[dev]"
105
+ ```
106
+
107
+ ### 2. Wire into OpenAI Codex CLI (`~/.codex/config.toml`)
108
+
109
+ Generate the exact TOML snippet with `jev-kit init-codex --format toml` and add it to `~/.codex/config.toml`:
110
+
111
+ ```toml
112
+ [mcp_servers.jev_cognitive]
113
+ command = "jev-mcp"
114
+ args = []
115
+ ```
116
+
117
+ ### 3. Wire into JSON MCP Clients (Claude Code, Cursor, Antigravity)
118
+
119
+ Generate with `jev-kit init-codex --format json`:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "jev-cognitive": {
125
+ "command": "jev-mcp",
126
+ "args": []
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### 4. CLI Usage & Verification
133
+
134
+ ```bash
135
+ # Generate OpenAI Codex CLI config.toml snippet
136
+ jev-kit init-codex --format toml
137
+
138
+ # Layer-0 deterministic reflex screen (offline, 0 tokens)
139
+ jev-kit guard "rm -rf -- /" --reflex-only
140
+
141
+ # 5-factor Meta-Controller arbitration (offline, 0 tokens)
142
+ jev-kit arbitrate --confidence 0.62 --risk 0.75 --irreversible --value 0.85
143
+
144
+ # Run deterministic unit test suite
145
+ python -m unittest discover -s tests -v
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Security & Reliability Boundaries
151
+
152
+ - **Pre-Egress Credential DLP Chokepoint**: Both `local_reflex_screen()` and `call_jev()` screen serialized inputs for literal secrets (`sk-*`, `ghp_*`, `glpat-*`, `AKIA*`, `sntrys_*`, `s.*`, `PMAK-*`, `glsa_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM private keys, and URL userinfo credentials) and raise `SENSITIVE_INPUT_REJECTED` before `_invoke_bridge()` can be called.
153
+ - **Zero Direct Credential Arguments**: `call_jev()` rejects explicit `api_key`, `token`, or `secret` keyword arguments (`DIRECT_CREDENTIALS_DISABLED`).
154
+ - **Advisory Boundary**: Outputs from `jev-cognitive-mcp` are advisory structured signals; host agents must enforce execution blocking and human approval gates.
155
+ - **No Silent Fallbacks**: Timeouts, missing bridge runtimes (`BRIDGE_MISSING`), or malformed responses raise `JevIntegrationError` with explicit `billing_uncertain` tracking rather than defaulting to `ALLOW` or `PASS`.
156
+
157
+ ## License
158
+
159
+ Released under the [MIT License](LICENSE).
160
+
161
+
162
+ ## Zero-Popup Chrome M144+ Live CDP Guard (`jev_chrome_guard`)
163
+
164
+ Modern Chrome (M144+) exposes `%LOCALAPPDATA%\Google\Chrome\User Data\DevToolsActivePort` via `chrome://inspect/#remote-debugging`, triggering a native modal prompt on every transient WebSocket handshake. `jev_chrome_guard` provides:
165
+ - **Zero-Popup `DevToolsActivePort` Discovery**: Parses live port and browser WebSocket UUID across Windows, macOS, and Linux without opening transient WebSockets.
166
+ - **Layer-0 CDP DLP & SSRF Pre-Screen**: Blocks accidental `.env` / SSH key / `.kube/config` / `terraform.tfstate` / Chrome `Local State` file uploads in `DOM.setFileInputFiles`, blocks `document.cookie` / `cookieStore.getAll()`, `localStorage`/`sessionStorage`/`indexedDB` network exfiltration, `navigator.clipboard.readText()`, and `navigator.credentials.get()` harvesting in `Runtime.evaluate`, blocks bulk `DOMStorage`/`IndexedDB`/cookie dumps, MITM `Fetch.enable` / `Network.setCookie` overrides, sensitive `Browser.setDownloadBehavior` path traversal, and `Cookie`/`Proxy-Authorization` header overrides, blocks `file://` browser profile vault reads and cloud metadata SSRF (`169.254.169.254`, `[fd00:ec2::254]`, `100.100.100.200`) in `Page.navigate`, and enforces `userGesture: true` on safe evaluations to prevent popup blockers.
167
+
168
+ ---
169
+
170
+ ## Open-Core Pro & Commercial Ecosystem
171
+
172
+ | Capability | Community Core (`jev-cognitive-mcp` · MIT) | Studio Pro Suite (Commercial / Sponsors) |
173
+ | :--- | :--- | :--- |
174
+ | **Layer-0 Shell & CDP Guardrails** | ✅ Included (75-case JSONL benchmark, 0 tokens) | ✅ + Custom Enterprise Policy Packs |
175
+ | **5-Factor Meta-Controller & Autopilot** | ✅ Included (`jev_arbitrate`, `jev_autopilot`) | ✅ + Multi-Key Quota Balancer |
176
+ | **Chrome M144+ Zero-Popup CDP Guard** | ✅ Endpoint Discovery + Layer-0 CDP Screen | ✅ + Persistent Multi-Tab Daemon & Windows UIA Auto-Consent |
177
+ | **8-Platform Matrix Auto-Publisher** | — | 🚀 **Pro Exclusive**: One-click zero-login publishing to YouTube, TikTok, Bilibili, Xiaohongshu, Douyin, WeChat Channels & Kuaishou |
178
+ | **AI Short-Drama & WebGame Studio** | See [`open-short-drama-studio`](https://github.com/17671454333/open-short-drama-studio) | 🚀 **Pro Exclusive**: Cross-shot face-locking, Seedance 85%-credit-saver pipeline, CapCut draft exporter & 6-target WebGame packager |
@@ -0,0 +1,149 @@
1
+ # jev-cognitive-mcp
2
+
3
+ **English** · [简体中文](README.zh-CN.md)
4
+
5
+ [![CI](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)
7
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
8
+ [![MCP Protocol](https://img.shields.io/badge/MCP-2024--11--05-purple.svg)](jev_kit/mcp_server.py)
9
+
10
+ **Advisory 3+1 Cognitive Hierarchy Toolkit & Model Context Protocol (MCP) Server for Coding Agents (OpenAI Codex CLI, Claude Code, Cursor, Antigravity).**
11
+
12
+ `jev-cognitive-mcp` provides deterministic Layer-0 DLP/destructive command pre-screening, 5-factor Meta-Controller escalation arbitration, and optional System-1 probabilistic triage (`guard`, `route`, `verify`, `rerank`) over stdio MCP. All verdicts and routing signals are **advisory**—the host agent remains responsible for enforcing command blocking, sandboxing, and human-in-the-loop approval gates.
13
+
14
+ ---
15
+
16
+ ## Architecture: The 3+1 Cognitive Hierarchy
17
+
18
+ ```mermaid
19
+ flowchart LR
20
+ A["Incoming Agent Action / Task"] --> L0["Layer 0: Deterministic Reflex<br/>(0 network / 0 token cost)<br/>DLP regex & destructive pattern screen"]
21
+ L0 -->|Blocked / Matched| OUT0["Immediate Advisory Verdict"]
22
+ L0 -->|Needs Semantic Triage| S1["System 1: Probabilistic Intuition (JEV)<br/>(Requires external JevBridge)<br/>Guard / Route / Rerank / Verify"]
23
+ S1 --> MC{"Meta-Controller<br/>5-Factor Arbitration"}
24
+ MC -->|High Confidence & Two-Way Door| OUT1["Advisory Fast Path"]
25
+ MC -->|Low Confidence / High Risk| S2["System 2: Host Frontier LLM<br/>(Codex / o3 / Sonnet Thinking)"]
26
+ MC -->|One-Way Door & High Risk| HG["Explicit Human Gate Required"]
27
+ ```
28
+
29
+ | Layer | Role | Execution Mode | Responsibility |
30
+ |---|---|---|---|
31
+ | **Layer 0 (Reflex)** | Deterministic Code | Local offline (`0 tokens`, no network call) | Pre-egress regex DLP credential screening (`sk-*`, `sk-ant-*`, `ghp_*`, `glpat-*`, `AKIA*`, `SG.*`, `pypi-*`, `hf_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM keys), destructive shell pattern matching (`rm -rf /`, `rm -rf -- /`, `Remove-Item -Recurse -Force`, `mkfs`, `wipefs -a`, `shred -u /`, `DROP DATABASE`, `curl \| bash`), strict schema validation |
32
+ | **System 1 (Intuition)** | Probabilistic JEV | External `JevBridge` single-attempt call | Multi-head `noul` (boolean probability), `choice` (categorical distribution), and `score` (0..4 ordinal rubric) evaluations |
33
+ | **System 2 (Reasoning)** | Host Frontier LLM | Host agent runtime | Complex causal reasoning, multi-file architecture design, subtle debugging |
34
+ | **Meta-Controller** | Control Plane | Local offline (`0 tokens`, no network call) | Arbitrates escalation using 5 quantitative signals: **Confidence**, **Risk**, **Reversibility**, **Expected Value**, and **Cost Pressure** |
35
+
36
+ ---
37
+
38
+ ## Core Modules & MCP Tools
39
+
40
+ 1. **`jev_guard` (`jev_kit.guard`) — Advisory Pre-Tool Command Risk Screen**
41
+ - Evaluates shell commands before execution and returns an advisory action (`ALLOW`, `INSPECT`, `ESCALATE_HUMAN`, or `BLOCK`).
42
+ - **Layer 0 (`reflex_only=true` or pre-screen)**: Blocks literal credential egress (`SENSITIVE_INPUT_REJECTED`) and known destructive shell/PowerShell patterns locally with zero network calls.
43
+ - **System 1 (when `reflex_only=false`)**: Evaluates `is_destructive`, `is_rce_or_exfil`, and `is_secret_leak` probabilities via `JevBridge`.
44
+ 2. **`jev_arbitrate` (`jev_kit.controller`) — Offline 5-Factor Meta-Controller**
45
+ - Purely deterministic calculation of expected escalation utility from `(confidence, risk, reversible, expected_value, cost_pressure)`. Recommends `human_gate` on irreversible high-risk actions. Works completely offline.
46
+ 3. **`jev_route` (`jev_kit.router`) — Advisory Task & Model Tier Router**
47
+ - Classifies incoming coding prompts into `FAST` (`codex-mini-latest`, `gpt-4o-mini`), `STANDARD` (`gpt-4.1`, `gpt-4o`), or `DEEP_REASONING` (`o3`, `codex-1`) tiers while estimating architectural scope.
48
+ 4. **`jev_verify` (`jev_kit.verifier`) — Caller-Supplied Completion & Acceptance Review**
49
+ - Reviews caller-supplied `task_spec`, `implemented_changes` summary, and `test_results` logs to return `PASS`, `ADVISORY`, or `NEEDS_REVISION`. Does **not** inspect git repositories or run test suites directly.
50
+ 5. **`jev_rerank` (`jev_kit.reranker`) — Bounded Semantic Candidate Reranker**
51
+ - Ranks up to 96 caller-supplied code snippets or issue candidates in deterministic batches of 12 while preserving full provenance and failing closed on partial batch errors.
52
+
53
+ ---
54
+
55
+ ## Offline Deterministic Mode vs. External `JevBridge` Requirement
56
+
57
+ - **Works 100% Offline (Zero External Dependencies)**:
58
+ - `jev_arbitrate` (5-factor Meta-Controller)
59
+ - `jev_guard` with `reflex_only=true` (`jev-kit guard "<cmd>" --reflex-only`)
60
+ - `jev-kit init-codex` (configuration generator for OpenAI Codex CLI and MCP clients)
61
+ - Pre-egress credential DLP screening inside `call_jev()` (blocks sensitive tokens before any bridge lookup)
62
+ - **Requires External `JevBridge` Runtime**:
63
+ - `jev_guard` (when `reflex_only=false` and Layer 0 does not match), `jev_route`, `jev_verify`, and `jev_rerank` invoke `jev_cli.py` from the local `JevBridge` runtime directory.
64
+ - Set `JEV_BRIDGE_DIR=/path/to/JevBridge/runtime` (defaults to `%LOCALAPPDATA%\JevBridge\runtime` on Windows or `~/.local/share/JevBridge/runtime` on Linux/macOS). If the bridge runtime is not installed, these tools fail closed with `JevIntegrationError(code="BRIDGE_MISSING")`.
65
+
66
+ ---
67
+
68
+ ## Quick Start
69
+
70
+ ### 1. Installation
71
+
72
+ ```bash
73
+ git clone https://github.com/17671454333/jev-cognitive-mcp.git
74
+ cd jev-cognitive-mcp
75
+ pip install -e ".[dev]"
76
+ ```
77
+
78
+ ### 2. Wire into OpenAI Codex CLI (`~/.codex/config.toml`)
79
+
80
+ Generate the exact TOML snippet with `jev-kit init-codex --format toml` and add it to `~/.codex/config.toml`:
81
+
82
+ ```toml
83
+ [mcp_servers.jev_cognitive]
84
+ command = "jev-mcp"
85
+ args = []
86
+ ```
87
+
88
+ ### 3. Wire into JSON MCP Clients (Claude Code, Cursor, Antigravity)
89
+
90
+ Generate with `jev-kit init-codex --format json`:
91
+
92
+ ```json
93
+ {
94
+ "mcpServers": {
95
+ "jev-cognitive": {
96
+ "command": "jev-mcp",
97
+ "args": []
98
+ }
99
+ }
100
+ }
101
+ ```
102
+
103
+ ### 4. CLI Usage & Verification
104
+
105
+ ```bash
106
+ # Generate OpenAI Codex CLI config.toml snippet
107
+ jev-kit init-codex --format toml
108
+
109
+ # Layer-0 deterministic reflex screen (offline, 0 tokens)
110
+ jev-kit guard "rm -rf -- /" --reflex-only
111
+
112
+ # 5-factor Meta-Controller arbitration (offline, 0 tokens)
113
+ jev-kit arbitrate --confidence 0.62 --risk 0.75 --irreversible --value 0.85
114
+
115
+ # Run deterministic unit test suite
116
+ python -m unittest discover -s tests -v
117
+ ```
118
+
119
+ ---
120
+
121
+ ## Security & Reliability Boundaries
122
+
123
+ - **Pre-Egress Credential DLP Chokepoint**: Both `local_reflex_screen()` and `call_jev()` screen serialized inputs for literal secrets (`sk-*`, `ghp_*`, `glpat-*`, `AKIA*`, `sntrys_*`, `s.*`, `PMAK-*`, `glsa_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM private keys, and URL userinfo credentials) and raise `SENSITIVE_INPUT_REJECTED` before `_invoke_bridge()` can be called.
124
+ - **Zero Direct Credential Arguments**: `call_jev()` rejects explicit `api_key`, `token`, or `secret` keyword arguments (`DIRECT_CREDENTIALS_DISABLED`).
125
+ - **Advisory Boundary**: Outputs from `jev-cognitive-mcp` are advisory structured signals; host agents must enforce execution blocking and human approval gates.
126
+ - **No Silent Fallbacks**: Timeouts, missing bridge runtimes (`BRIDGE_MISSING`), or malformed responses raise `JevIntegrationError` with explicit `billing_uncertain` tracking rather than defaulting to `ALLOW` or `PASS`.
127
+
128
+ ## License
129
+
130
+ Released under the [MIT License](LICENSE).
131
+
132
+
133
+ ## Zero-Popup Chrome M144+ Live CDP Guard (`jev_chrome_guard`)
134
+
135
+ Modern Chrome (M144+) exposes `%LOCALAPPDATA%\Google\Chrome\User Data\DevToolsActivePort` via `chrome://inspect/#remote-debugging`, triggering a native modal prompt on every transient WebSocket handshake. `jev_chrome_guard` provides:
136
+ - **Zero-Popup `DevToolsActivePort` Discovery**: Parses live port and browser WebSocket UUID across Windows, macOS, and Linux without opening transient WebSockets.
137
+ - **Layer-0 CDP DLP & SSRF Pre-Screen**: Blocks accidental `.env` / SSH key / `.kube/config` / `terraform.tfstate` / Chrome `Local State` file uploads in `DOM.setFileInputFiles`, blocks `document.cookie` / `cookieStore.getAll()`, `localStorage`/`sessionStorage`/`indexedDB` network exfiltration, `navigator.clipboard.readText()`, and `navigator.credentials.get()` harvesting in `Runtime.evaluate`, blocks bulk `DOMStorage`/`IndexedDB`/cookie dumps, MITM `Fetch.enable` / `Network.setCookie` overrides, sensitive `Browser.setDownloadBehavior` path traversal, and `Cookie`/`Proxy-Authorization` header overrides, blocks `file://` browser profile vault reads and cloud metadata SSRF (`169.254.169.254`, `[fd00:ec2::254]`, `100.100.100.200`) in `Page.navigate`, and enforces `userGesture: true` on safe evaluations to prevent popup blockers.
138
+
139
+ ---
140
+
141
+ ## Open-Core Pro & Commercial Ecosystem
142
+
143
+ | Capability | Community Core (`jev-cognitive-mcp` · MIT) | Studio Pro Suite (Commercial / Sponsors) |
144
+ | :--- | :--- | :--- |
145
+ | **Layer-0 Shell & CDP Guardrails** | ✅ Included (75-case JSONL benchmark, 0 tokens) | ✅ + Custom Enterprise Policy Packs |
146
+ | **5-Factor Meta-Controller & Autopilot** | ✅ Included (`jev_arbitrate`, `jev_autopilot`) | ✅ + Multi-Key Quota Balancer |
147
+ | **Chrome M144+ Zero-Popup CDP Guard** | ✅ Endpoint Discovery + Layer-0 CDP Screen | ✅ + Persistent Multi-Tab Daemon & Windows UIA Auto-Consent |
148
+ | **8-Platform Matrix Auto-Publisher** | — | 🚀 **Pro Exclusive**: One-click zero-login publishing to YouTube, TikTok, Bilibili, Xiaohongshu, Douyin, WeChat Channels & Kuaishou |
149
+ | **AI Short-Drama & WebGame Studio** | See [`open-short-drama-studio`](https://github.com/17671454333/open-short-drama-studio) | 🚀 **Pro Exclusive**: Cross-shot face-locking, Seedance 85%-credit-saver pipeline, CapCut draft exporter & 6-target WebGame packager |
@@ -0,0 +1,178 @@
1
+ Metadata-Version: 2.4
2
+ Name: jev-cognitive-mcp
3
+ Version: 0.4.4
4
+ Summary: Advisory 3+1 Cognitive Hierarchy Toolkit & Model Context Protocol (MCP) Server for Agentic Coding: Pre-Tool Risk Screening, Dynamic Task Routing, Candidate Ranking, and Evidence Review.
5
+ Author: jev-cognitive-mcp maintainers
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/17671454333/jev-cognitive-mcp
8
+ Project-URL: Repository, https://github.com/17671454333/jev-cognitive-mcp
9
+ Project-URL: Issues, https://github.com/17671454333/jev-cognitive-mcp/issues
10
+ Project-URL: Changelog, https://github.com/17671454333/jev-cognitive-mcp/releases
11
+ Keywords: mcp,model-context-protocol,ai-agents,codex,security-guardrails,model-router,system1-system2,llm-verification
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Quality Assurance
20
+ Classifier: Topic :: Security
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.4.0; extra == "dev"
27
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
28
+ Dynamic: license-file
29
+
30
+ # jev-cognitive-mcp
31
+
32
+ **English** · [简体中文](README.zh-CN.md)
33
+
34
+ [![CI](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/17671454333/jev-cognitive-mcp/actions/workflows/ci.yml)
35
+ [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)
36
+ [![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue.svg)](pyproject.toml)
37
+ [![MCP Protocol](https://img.shields.io/badge/MCP-2024--11--05-purple.svg)](jev_kit/mcp_server.py)
38
+
39
+ **Advisory 3+1 Cognitive Hierarchy Toolkit & Model Context Protocol (MCP) Server for Coding Agents (OpenAI Codex CLI, Claude Code, Cursor, Antigravity).**
40
+
41
+ `jev-cognitive-mcp` provides deterministic Layer-0 DLP/destructive command pre-screening, 5-factor Meta-Controller escalation arbitration, and optional System-1 probabilistic triage (`guard`, `route`, `verify`, `rerank`) over stdio MCP. All verdicts and routing signals are **advisory**—the host agent remains responsible for enforcing command blocking, sandboxing, and human-in-the-loop approval gates.
42
+
43
+ ---
44
+
45
+ ## Architecture: The 3+1 Cognitive Hierarchy
46
+
47
+ ```mermaid
48
+ flowchart LR
49
+ A["Incoming Agent Action / Task"] --> L0["Layer 0: Deterministic Reflex<br/>(0 network / 0 token cost)<br/>DLP regex & destructive pattern screen"]
50
+ L0 -->|Blocked / Matched| OUT0["Immediate Advisory Verdict"]
51
+ L0 -->|Needs Semantic Triage| S1["System 1: Probabilistic Intuition (JEV)<br/>(Requires external JevBridge)<br/>Guard / Route / Rerank / Verify"]
52
+ S1 --> MC{"Meta-Controller<br/>5-Factor Arbitration"}
53
+ MC -->|High Confidence & Two-Way Door| OUT1["Advisory Fast Path"]
54
+ MC -->|Low Confidence / High Risk| S2["System 2: Host Frontier LLM<br/>(Codex / o3 / Sonnet Thinking)"]
55
+ MC -->|One-Way Door & High Risk| HG["Explicit Human Gate Required"]
56
+ ```
57
+
58
+ | Layer | Role | Execution Mode | Responsibility |
59
+ |---|---|---|---|
60
+ | **Layer 0 (Reflex)** | Deterministic Code | Local offline (`0 tokens`, no network call) | Pre-egress regex DLP credential screening (`sk-*`, `sk-ant-*`, `ghp_*`, `glpat-*`, `AKIA*`, `SG.*`, `pypi-*`, `hf_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM keys), destructive shell pattern matching (`rm -rf /`, `rm -rf -- /`, `Remove-Item -Recurse -Force`, `mkfs`, `wipefs -a`, `shred -u /`, `DROP DATABASE`, `curl \| bash`), strict schema validation |
61
+ | **System 1 (Intuition)** | Probabilistic JEV | External `JevBridge` single-attempt call | Multi-head `noul` (boolean probability), `choice` (categorical distribution), and `score` (0..4 ordinal rubric) evaluations |
62
+ | **System 2 (Reasoning)** | Host Frontier LLM | Host agent runtime | Complex causal reasoning, multi-file architecture design, subtle debugging |
63
+ | **Meta-Controller** | Control Plane | Local offline (`0 tokens`, no network call) | Arbitrates escalation using 5 quantitative signals: **Confidence**, **Risk**, **Reversibility**, **Expected Value**, and **Cost Pressure** |
64
+
65
+ ---
66
+
67
+ ## Core Modules & MCP Tools
68
+
69
+ 1. **`jev_guard` (`jev_kit.guard`) — Advisory Pre-Tool Command Risk Screen**
70
+ - Evaluates shell commands before execution and returns an advisory action (`ALLOW`, `INSPECT`, `ESCALATE_HUMAN`, or `BLOCK`).
71
+ - **Layer 0 (`reflex_only=true` or pre-screen)**: Blocks literal credential egress (`SENSITIVE_INPUT_REJECTED`) and known destructive shell/PowerShell patterns locally with zero network calls.
72
+ - **System 1 (when `reflex_only=false`)**: Evaluates `is_destructive`, `is_rce_or_exfil`, and `is_secret_leak` probabilities via `JevBridge`.
73
+ 2. **`jev_arbitrate` (`jev_kit.controller`) — Offline 5-Factor Meta-Controller**
74
+ - Purely deterministic calculation of expected escalation utility from `(confidence, risk, reversible, expected_value, cost_pressure)`. Recommends `human_gate` on irreversible high-risk actions. Works completely offline.
75
+ 3. **`jev_route` (`jev_kit.router`) — Advisory Task & Model Tier Router**
76
+ - Classifies incoming coding prompts into `FAST` (`codex-mini-latest`, `gpt-4o-mini`), `STANDARD` (`gpt-4.1`, `gpt-4o`), or `DEEP_REASONING` (`o3`, `codex-1`) tiers while estimating architectural scope.
77
+ 4. **`jev_verify` (`jev_kit.verifier`) — Caller-Supplied Completion & Acceptance Review**
78
+ - Reviews caller-supplied `task_spec`, `implemented_changes` summary, and `test_results` logs to return `PASS`, `ADVISORY`, or `NEEDS_REVISION`. Does **not** inspect git repositories or run test suites directly.
79
+ 5. **`jev_rerank` (`jev_kit.reranker`) — Bounded Semantic Candidate Reranker**
80
+ - Ranks up to 96 caller-supplied code snippets or issue candidates in deterministic batches of 12 while preserving full provenance and failing closed on partial batch errors.
81
+
82
+ ---
83
+
84
+ ## Offline Deterministic Mode vs. External `JevBridge` Requirement
85
+
86
+ - **Works 100% Offline (Zero External Dependencies)**:
87
+ - `jev_arbitrate` (5-factor Meta-Controller)
88
+ - `jev_guard` with `reflex_only=true` (`jev-kit guard "<cmd>" --reflex-only`)
89
+ - `jev-kit init-codex` (configuration generator for OpenAI Codex CLI and MCP clients)
90
+ - Pre-egress credential DLP screening inside `call_jev()` (blocks sensitive tokens before any bridge lookup)
91
+ - **Requires External `JevBridge` Runtime**:
92
+ - `jev_guard` (when `reflex_only=false` and Layer 0 does not match), `jev_route`, `jev_verify`, and `jev_rerank` invoke `jev_cli.py` from the local `JevBridge` runtime directory.
93
+ - Set `JEV_BRIDGE_DIR=/path/to/JevBridge/runtime` (defaults to `%LOCALAPPDATA%\JevBridge\runtime` on Windows or `~/.local/share/JevBridge/runtime` on Linux/macOS). If the bridge runtime is not installed, these tools fail closed with `JevIntegrationError(code="BRIDGE_MISSING")`.
94
+
95
+ ---
96
+
97
+ ## Quick Start
98
+
99
+ ### 1. Installation
100
+
101
+ ```bash
102
+ git clone https://github.com/17671454333/jev-cognitive-mcp.git
103
+ cd jev-cognitive-mcp
104
+ pip install -e ".[dev]"
105
+ ```
106
+
107
+ ### 2. Wire into OpenAI Codex CLI (`~/.codex/config.toml`)
108
+
109
+ Generate the exact TOML snippet with `jev-kit init-codex --format toml` and add it to `~/.codex/config.toml`:
110
+
111
+ ```toml
112
+ [mcp_servers.jev_cognitive]
113
+ command = "jev-mcp"
114
+ args = []
115
+ ```
116
+
117
+ ### 3. Wire into JSON MCP Clients (Claude Code, Cursor, Antigravity)
118
+
119
+ Generate with `jev-kit init-codex --format json`:
120
+
121
+ ```json
122
+ {
123
+ "mcpServers": {
124
+ "jev-cognitive": {
125
+ "command": "jev-mcp",
126
+ "args": []
127
+ }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ### 4. CLI Usage & Verification
133
+
134
+ ```bash
135
+ # Generate OpenAI Codex CLI config.toml snippet
136
+ jev-kit init-codex --format toml
137
+
138
+ # Layer-0 deterministic reflex screen (offline, 0 tokens)
139
+ jev-kit guard "rm -rf -- /" --reflex-only
140
+
141
+ # 5-factor Meta-Controller arbitration (offline, 0 tokens)
142
+ jev-kit arbitrate --confidence 0.62 --risk 0.75 --irreversible --value 0.85
143
+
144
+ # Run deterministic unit test suite
145
+ python -m unittest discover -s tests -v
146
+ ```
147
+
148
+ ---
149
+
150
+ ## Security & Reliability Boundaries
151
+
152
+ - **Pre-Egress Credential DLP Chokepoint**: Both `local_reflex_screen()` and `call_jev()` screen serialized inputs for literal secrets (`sk-*`, `ghp_*`, `glpat-*`, `AKIA*`, `sntrys_*`, `s.*`, `PMAK-*`, `glsa_*`, `Bearer`, `password=`, `secret=`, `api_key=`, `token=`, PEM private keys, and URL userinfo credentials) and raise `SENSITIVE_INPUT_REJECTED` before `_invoke_bridge()` can be called.
153
+ - **Zero Direct Credential Arguments**: `call_jev()` rejects explicit `api_key`, `token`, or `secret` keyword arguments (`DIRECT_CREDENTIALS_DISABLED`).
154
+ - **Advisory Boundary**: Outputs from `jev-cognitive-mcp` are advisory structured signals; host agents must enforce execution blocking and human approval gates.
155
+ - **No Silent Fallbacks**: Timeouts, missing bridge runtimes (`BRIDGE_MISSING`), or malformed responses raise `JevIntegrationError` with explicit `billing_uncertain` tracking rather than defaulting to `ALLOW` or `PASS`.
156
+
157
+ ## License
158
+
159
+ Released under the [MIT License](LICENSE).
160
+
161
+
162
+ ## Zero-Popup Chrome M144+ Live CDP Guard (`jev_chrome_guard`)
163
+
164
+ Modern Chrome (M144+) exposes `%LOCALAPPDATA%\Google\Chrome\User Data\DevToolsActivePort` via `chrome://inspect/#remote-debugging`, triggering a native modal prompt on every transient WebSocket handshake. `jev_chrome_guard` provides:
165
+ - **Zero-Popup `DevToolsActivePort` Discovery**: Parses live port and browser WebSocket UUID across Windows, macOS, and Linux without opening transient WebSockets.
166
+ - **Layer-0 CDP DLP & SSRF Pre-Screen**: Blocks accidental `.env` / SSH key / `.kube/config` / `terraform.tfstate` / Chrome `Local State` file uploads in `DOM.setFileInputFiles`, blocks `document.cookie` / `cookieStore.getAll()`, `localStorage`/`sessionStorage`/`indexedDB` network exfiltration, `navigator.clipboard.readText()`, and `navigator.credentials.get()` harvesting in `Runtime.evaluate`, blocks bulk `DOMStorage`/`IndexedDB`/cookie dumps, MITM `Fetch.enable` / `Network.setCookie` overrides, sensitive `Browser.setDownloadBehavior` path traversal, and `Cookie`/`Proxy-Authorization` header overrides, blocks `file://` browser profile vault reads and cloud metadata SSRF (`169.254.169.254`, `[fd00:ec2::254]`, `100.100.100.200`) in `Page.navigate`, and enforces `userGesture: true` on safe evaluations to prevent popup blockers.
167
+
168
+ ---
169
+
170
+ ## Open-Core Pro & Commercial Ecosystem
171
+
172
+ | Capability | Community Core (`jev-cognitive-mcp` · MIT) | Studio Pro Suite (Commercial / Sponsors) |
173
+ | :--- | :--- | :--- |
174
+ | **Layer-0 Shell & CDP Guardrails** | ✅ Included (75-case JSONL benchmark, 0 tokens) | ✅ + Custom Enterprise Policy Packs |
175
+ | **5-Factor Meta-Controller & Autopilot** | ✅ Included (`jev_arbitrate`, `jev_autopilot`) | ✅ + Multi-Key Quota Balancer |
176
+ | **Chrome M144+ Zero-Popup CDP Guard** | ✅ Endpoint Discovery + Layer-0 CDP Screen | ✅ + Persistent Multi-Tab Daemon & Windows UIA Auto-Consent |
177
+ | **8-Platform Matrix Auto-Publisher** | — | 🚀 **Pro Exclusive**: One-click zero-login publishing to YouTube, TikTok, Bilibili, Xiaohongshu, Douyin, WeChat Channels & Kuaishou |
178
+ | **AI Short-Drama & WebGame Studio** | See [`open-short-drama-studio`](https://github.com/17671454333/open-short-drama-studio) | 🚀 **Pro Exclusive**: Cross-shot face-locking, Seedance 85%-credit-saver pipeline, CapCut draft exporter & 6-target WebGame packager |
@@ -0,0 +1,21 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ jev_cognitive_mcp.egg-info/PKG-INFO
5
+ jev_cognitive_mcp.egg-info/SOURCES.txt
6
+ jev_cognitive_mcp.egg-info/dependency_links.txt
7
+ jev_cognitive_mcp.egg-info/entry_points.txt
8
+ jev_cognitive_mcp.egg-info/requires.txt
9
+ jev_cognitive_mcp.egg-info/top_level.txt
10
+ jev_kit/__init__.py
11
+ jev_kit/__main__.py
12
+ jev_kit/chrome_live.py
13
+ jev_kit/controller.py
14
+ jev_kit/core.py
15
+ jev_kit/guard.py
16
+ jev_kit/mcp_server.py
17
+ jev_kit/reranker.py
18
+ jev_kit/router.py
19
+ jev_kit/verifier.py
20
+ jev_kit/data/layer0_corpus.jsonl
21
+ tests/test_jev_kit.py
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ jev-kit = jev_kit.__main__:main
3
+ jev-mcp = jev_kit.mcp_server:run_stdio_server
@@ -0,0 +1,4 @@
1
+
2
+ [dev]
3
+ pytest>=7.4.0
4
+ pytest-cov>=4.1.0