mevvcrew 0.0.0-stage → 0.1.58
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/LICENSE +21 -0
- package/README.md +154 -2
- package/SECURITY.md +59 -0
- package/adapters/antigravity.cjs +18 -0
- package/adapters/claude.cjs +104 -0
- package/adapters/codex.cjs +45 -0
- package/adapters/cursor.cjs +17 -0
- package/adapters/gemini.cjs +17 -0
- package/adapters/generic.cjs +22 -0
- package/adapters/grok.cjs +58 -0
- package/adapters/ide-config.cjs +100 -0
- package/adapters/index.cjs +69 -0
- package/adapters/json-config.cjs +42 -0
- package/adapters/kimi.cjs +16 -0
- package/adapters/n8n.cjs +154 -0
- package/adapters/opencode.cjs +31 -0
- package/adapters/vscode.cjs +19 -0
- package/adapters/windsurf.cjs +23 -0
- package/adapters/zed.cjs +23 -0
- package/cli.cjs +583 -0
- package/lib/accounts.cjs +94 -0
- package/lib/acp.cjs +284 -0
- package/lib/adapters-check.cjs +162 -0
- package/lib/agent-hooks.cjs +993 -0
- package/lib/approval-wait.cjs +146 -0
- package/lib/browser-mcp-install.cjs +434 -0
- package/lib/browser-mcp.cjs +1294 -0
- package/lib/cli-registry.cjs +478 -0
- package/lib/codemap.cjs +244 -0
- package/lib/codex-toml.cjs +251 -0
- package/lib/connect.cjs +568 -0
- package/lib/connector-pack.cjs +110 -0
- package/lib/connectors.cjs +254 -0
- package/lib/conversation-mirror.cjs +469 -0
- package/lib/detect.cjs +24 -0
- package/lib/device-flow.cjs +42 -0
- package/lib/e2e-send.cjs +103 -0
- package/lib/e2e.cjs +131 -0
- package/lib/failover.cjs +296 -0
- package/lib/files.cjs +115 -0
- package/lib/folder-gate.cjs +40 -0
- package/lib/grok-policy.cjs +93 -0
- package/lib/handoff.cjs +569 -0
- package/lib/headless.cjs +92 -0
- package/lib/herdr.cjs +89 -0
- package/lib/history.cjs +159 -0
- package/lib/http.cjs +39 -0
- package/lib/json-text.cjs +329 -0
- package/lib/keychain.cjs +222 -0
- package/lib/launch.cjs +214 -0
- package/lib/local-profiles.cjs +148 -0
- package/lib/mcp.cjs +75 -0
- package/lib/messages.cjs +734 -0
- package/lib/minisign.cjs +79 -0
- package/lib/order.cjs +98 -0
- package/lib/permission-audit.cjs +147 -0
- package/lib/permission-bridge.cjs +686 -0
- package/lib/permission-clients.cjs +124 -0
- package/lib/project-match.cjs +271 -0
- package/lib/providers.cjs +316 -0
- package/lib/pulse.cjs +117 -0
- package/lib/qa-worker.cjs +612 -0
- package/lib/remote-daemon.cjs +579 -0
- package/lib/remote-session.cjs +1372 -0
- package/lib/run.cjs +29 -0
- package/lib/runner.cjs +731 -0
- package/lib/service.cjs +359 -0
- package/lib/session.cjs +566 -0
- package/lib/ship-autopilot.cjs +2481 -0
- package/lib/ship-runner.cjs +1157 -0
- package/lib/skill-keys.cjs +11 -0
- package/lib/skill-pack.cjs +261 -0
- package/lib/skills.cjs +448 -0
- package/lib/state.cjs +113 -0
- package/lib/structured.cjs +468 -0
- package/lib/tunnel.cjs +954 -0
- package/lib/update.cjs +318 -0
- package/lib/usage-providers.cjs +404 -0
- package/lib/usage.cjs +248 -0
- package/lib/vendor.cjs +22 -0
- package/lib/workspaces.cjs +779 -0
- package/lib/wrapper.cjs +55 -0
- package/macos/mevvCrew.app/Contents/CodeResources +0 -0
- package/macos/mevvCrew.app/Contents/Info.plist +34 -0
- package/macos/mevvCrew.app/Contents/MacOS/mevvCrew +0 -0
- package/macos/mevvCrew.app/Contents/Resources/AppIcon.icns +0 -0
- package/macos/mevvCrew.app/Contents/_CodeSignature/CodeResources +128 -0
- package/package.json +58 -4
- package/vendor/bin/crew +1058 -0
- package/vendor/client/crew-client.cjs +51 -0
- package/vendor/client/project-gate.cjs +22 -0
- package/vendor/client/tool-match.cjs +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mevvsoft / Mev E-Ticaret Limited Şirketi
|
|
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.
|
package/README.md
CHANGED
|
@@ -1,3 +1,155 @@
|
|
|
1
|
-
#
|
|
1
|
+
# mevvcrew (`crew`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Local-first CLI, MCP bridge & privacy daemon for controlling 17+ AI coding agents from web, iOS, and Apple Watch — zero cloud microVMs.
|
|
4
|
+
|
|
5
|
+
Zero runtime npm dependencies. Node.js `>= 22`. MIT licensed.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 60-Second Quickstart
|
|
10
|
+
|
|
11
|
+
### 1. Install & pair this computer
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g github:mevvsoft/mevvcrew-cli
|
|
15
|
+
crew init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Or run without a global install:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npx github:mevvsoft/mevvcrew-cli init
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
*(You can also install from your signed installer link on [crew.mevvsoft.com/connect](https://crew.mevvsoft.com/connect).)*
|
|
25
|
+
|
|
26
|
+
`crew init` (alias for `crew connect`) detects installed AI CLIs/IDEs, runs OAuth Device Flow (or instant `--pair <code>` from your Crew board), stores tokens in your OS keychain, and wires MCP/hook integrations.
|
|
27
|
+
|
|
28
|
+
### 2. Link a repository folder
|
|
29
|
+
|
|
30
|
+
Unlinked directories are invisible to Crew by default. Explicitly link any repo you want to control remotely:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd /path/to/your-repo
|
|
34
|
+
crew project link my-project
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Verify the Folder Privacy Wall for any directory:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
crew mirror check .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3. Start the daemon & receive your first approval / Decision Card
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
crew permission-bridge enable all
|
|
47
|
+
crew daemon start
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
When an agent inside a linked project requests a sensitive command, file edit, or MCP action, Crew routes a permission / Decision Card to your web board, iOS app, or Apple Watch. You can also wait on any decision card from scripts or hooks:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
crew approval wait <approval-id> --timeout 600
|
|
54
|
+
# Prints decision JSON to stdout. Exit codes: 0 approved, 2 rejected, 3 timeout.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Architecture & Privacy Guarantees
|
|
60
|
+
|
|
61
|
+
`mevvcrew` runs entirely on your machine. Your agents execute locally against your own repos, tools, and credentials — no cloud containers or remote code sandboxes.
|
|
62
|
+
|
|
63
|
+
- **Folder Privacy Wall (0 bytes from unlinked folders):** Every hook, permission bridge, and session mirror evaluates `lib/folder-gate.cjs` and `lib/project-match.cjs` locally against a cached project index. Directories that do not match a linked Crew project emit **0 bytes** — no path, no git remote, no tool name, no prompt, and no HTTP call.
|
|
64
|
+
- **Local Secret Redaction:** Before any mirrored text leaves your device, `lib/conversation-mirror.cjs` scrubs PEM private keys, API keys (`sk-*`, `ghp_*`, `glpat-*`, `AIza*`, `AKIA*`, `xai-*`, `xox*`, `whsec_*`, `polar_oat_*`, `mc_*`), `Bearer` tokens, and inline `password`/`secret`/`api_key` values.
|
|
65
|
+
- **No Unapproved Source Code Uploads:** Permission prompts transmit minimal tool metadata by default. Session mirroring only activates on explicitly linked projects and supports optional client-side end-to-end encryption (`crew e2e on`, X25519 + AES-256-GCM).
|
|
66
|
+
- **OS Keychain Only:** Auth tokens stay in macOS Keychain, Linux Secret Service (`secret-tool`), or Windows Credential Manager — never written to `device.json` or passed in process `argv`.
|
|
67
|
+
|
|
68
|
+
### Exact Local Files & Endpoints Inspected
|
|
69
|
+
|
|
70
|
+
| Surface | Path / Endpoint | Purpose |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| Local state & cache | `~/.mevvcrew/device.json`, `~/.mevvcrew/projects*.json`, `~/.mevvcrew/workspaces.json` | Connected board metadata, cached project slugs/repo keys, linked workspace map (never tokens) |
|
|
73
|
+
| Daemon runtime | `~/.mevvcrew/daemon.pid`, `~/.mevvcrew/daemon.log`, `~/Library/LaunchAgents/com.mevvsoft.crew.daemon.plist` | Persistent sub-second remote control daemon |
|
|
74
|
+
| OS Keychain | Service `mevvcrew` | Per-agent bearer tokens and optional E2E device keys |
|
|
75
|
+
| CLI/IDE configs | Each agent's documented MCP / hooks config (backed up as `*.mevvcrew-backup` before edits) | Wires `crew mcp-bridge`, `crew mcp-headers`, or native permission hooks |
|
|
76
|
+
| Outbound API | `https://crew.mevvsoft.com` (or custom `--server URL`) | `/api/device/*`, `/mcp`, `/api/approvals/*`, `/api/session/*`, `/api/e2e/*`, `/tunnels/*` |
|
|
77
|
+
|
|
78
|
+
See [SECURITY.md](./SECURITY.md) for the full threat model and vulnerability disclosure policy.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Supported 17+ AI Coding CLIs & IDEs
|
|
83
|
+
|
|
84
|
+
Declarative registry in `lib/cli-registry.cjs`, `adapters/`, and `lib/permission-clients.cjs`:
|
|
85
|
+
|
|
86
|
+
| # | Agent / IDE | Binary | Protocol / Transport | Permission Bridge / Hook |
|
|
87
|
+
|---|---|---|---|---|
|
|
88
|
+
| 1 | **Claude Code** | `claude` | `claude-stream` + HTTP MCP (`headersHelper`) | Native `PermissionRequest` hook (`~/.claude/settings.json`) |
|
|
89
|
+
| 2 | **Antigravity** | `agy` | ACP (`agy acp`) + stdio `mcp-bridge` | `PreToolUse` hook (`~/.gemini/config/hooks.json`) & ACP |
|
|
90
|
+
| 3 | **OpenAI Codex CLI** | `codex` | `codex-jsonl` + HTTP MCP (`http_headers_helper`) | Native `PermissionRequest` hook (`~/.codex/config.toml`) |
|
|
91
|
+
| 4 | **Gemini CLI** | `gemini` | ACP (`gemini --acp`) + HTTP MCP | `BeforeTool` hook (`~/.gemini/settings.json`) & ACP |
|
|
92
|
+
| 5 | **Cursor** | `cursor-agent` / `agent` | ACP (`agent acp`) + stdio `mcp-bridge` | `beforeShellExecution` / `beforeMCPExecution` (`~/.cursor/hooks.json`) & ACP |
|
|
93
|
+
| 6 | **Devin CLI** | `devin` | `generic-cli` + stdio `mcp-bridge` | `PreToolUse` hook (`~/.config/devin/config.json`) |
|
|
94
|
+
| 7 | **Windsurf (Cascade)** | `windsurf` | `generic-cli` + stdio `mcp-bridge` | `pre_run_command` / `pre_write_code` (`~/.codeium/windsurf/hooks.json`) |
|
|
95
|
+
| 8 | **Zed** | `zed` | `acp-bridge` + stdio `mcp-bridge` | Agent server wiring (`~/.config/zed/settings.json`) |
|
|
96
|
+
| 9 | **Kimi Code** | `kimi` | ACP (`kimi acp`) + HTTP MCP | `PreToolUse` hook (`~/.kimi/config.json`) & ACP |
|
|
97
|
+
| 10 | **Z.ai (GLM)** | `zai` / `glm` | `generic-cli` | `PreToolUse` hook (`~/.zai/hooks.json`) |
|
|
98
|
+
| 11 | **Crush** | `crush` | `generic-cli` + stdio `mcp-bridge` | `PreToolUse` hook (`~/.config/crush/crush.json`) |
|
|
99
|
+
| 12 | **Aider** | `aider` | `generic-cli` | Pre-exec approval gate (`gateBeforeExec`) |
|
|
100
|
+
| 13 | **OpenCode** | `opencode` | `generic-cli` / ACP + stdio `mcp-bridge` | Native plugin (`~/.config/opencode/plugins/mevvcrew.js`) |
|
|
101
|
+
| 14 | **Qwen Code** | `qwen` | `generic-cli` / ACP + stdio `mcp-bridge` | Native `PermissionRequest` hook (`~/.qwen/settings.json`) |
|
|
102
|
+
| 15 | **Grok Build** | `grok` | ACP (`grok agent stdio`) + stdio `mcp-bridge` | Safe `ask` policy + `PreToolUse` hook (`~/.grok/`) & ACP |
|
|
103
|
+
| 16 | **GitHub Copilot CLI** | `copilot` | `generic-cli` / ACP + stdio `mcp-bridge` | `PreToolUse` hook (`~/.copilot/hooks.json`) & ACP |
|
|
104
|
+
| 17 | **Goose** | `goose` | `generic-cli` / ACP + stdio `mcp-bridge` | `PreToolUse` hook (`~/.config/goose/hooks.json`) & ACP |
|
|
105
|
+
|
|
106
|
+
Additional adapters & launch targets included: **VS Code (Copilot)**, **Cline CLI**, **Kilo Code**, **Kiro CLI**, **OpenHands CLI**, **Mistral Vibe**, **n8n**, and custom `adapters.json` / `generic` MCP clients.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Key Commands
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Setup & diagnostics
|
|
114
|
+
crew init [--server URL] [--tools claude,codex,...] [--pair CODE] # Pair device & wire CLIs/IDEs (alias: crew connect)
|
|
115
|
+
crew doctor # Check connection status, adapter probes & permission audit
|
|
116
|
+
crew status # Show connected boards, agents, and daemon state
|
|
117
|
+
crew disconnect # Cleanly undo all config edits & remove keychain tokens
|
|
118
|
+
|
|
119
|
+
# Permissions, guard & decision cards
|
|
120
|
+
crew guard [--hold 90] # PreToolUse hook: evaluate policy & hold risky tool calls for approval
|
|
121
|
+
crew approval wait <id> [--timeout 600] # Sub-second long-poll for a Decision Card (exit 0/2/3)
|
|
122
|
+
crew permission-bridge enable [all|<client>] # Wire universal permission bridge across installed CLIs/IDEs
|
|
123
|
+
crew permission audit # Verify every connected CLI asks instead of auto-approving
|
|
124
|
+
|
|
125
|
+
# Remote daemon & project privacy wall
|
|
126
|
+
crew daemon start | stop | status | install | uninstall # Persistent sub-second long-poll remote control daemon
|
|
127
|
+
crew project link <slug> [folder] # Link a folder to a Crew project (.crew/project)
|
|
128
|
+
crew project unlink [folder] # Remove folder link (re-closes privacy wall)
|
|
129
|
+
crew mirror check [folder] # Inspect which project (if any) a folder resolves to
|
|
130
|
+
|
|
131
|
+
# MCP, E2E, browser & preview tunnels
|
|
132
|
+
crew mcp-bridge <agent> # Local stdio <-> HTTP MCP bridge (keychain-backed)
|
|
133
|
+
crew browser-mcp install [all|<client>] # Crew-gated browser automation MCP server
|
|
134
|
+
crew e2e on | pair | rotate | status | off # End-to-end encryption keys & viewer pairing
|
|
135
|
+
crew tunnel open --project <slug> --port 3000 # Loopback-only (127.0.0.1) preview tunnel
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Run `crew --help` for the complete command reference (`launch`, `continue`, `history`, `accounts`, `usage`, `order`, `skill`, `connector`, `codemap`, `qa`, `ship`, and task commands).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Contributing
|
|
143
|
+
|
|
144
|
+
1. Fork the repository and create a feature branch.
|
|
145
|
+
2. Keep runtime dependencies at **zero** (Node.js `>= 22` built-ins only).
|
|
146
|
+
3. Run the test suite:
|
|
147
|
+
```bash
|
|
148
|
+
npm test
|
|
149
|
+
```
|
|
150
|
+
4. Never commit tokens, credentials, or personal paths — verify with `npm pack --dry-run`.
|
|
151
|
+
5. Open a pull request with tests covering your changes.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
[MIT](./LICENSE) © 2026 Mevvsoft / Mev E-Ticaret Limited Şirketi.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Security & Privacy Policy
|
|
2
|
+
|
|
3
|
+
`mevvcrew` is designed to be auditable from top to bottom: zero runtime npm dependencies, Node.js `>= 22` built-ins only, and strict local-first privacy boundaries.
|
|
4
|
+
|
|
5
|
+
## Local-First Privacy Architecture
|
|
6
|
+
|
|
7
|
+
### 1. Folder Privacy Wall (0 Bytes Sent from Unlinked Directories)
|
|
8
|
+
|
|
9
|
+
Every hook, permission bridge, and conversation mirror passes through a local project gate before any network call is allowed:
|
|
10
|
+
|
|
11
|
+
- **Implementation:** `lib/folder-gate.cjs`, `lib/project-match.cjs`, `lib/session.cjs`, `lib/conversation-mirror.cjs`.
|
|
12
|
+
- **How matching works:** The CLI matches the current working directory strictly on your machine against a cached project index (`~/.mevvcrew/projects/*.json`) in this order:
|
|
13
|
+
1. Explicit `CREW_PROJECT` env var (only if present in the cached index).
|
|
14
|
+
2. Git repository remote host/path key (worktree-aware via `git rev-parse --git-common-dir`).
|
|
15
|
+
3. An explicit `.crew/project` file created by `crew project link <slug>`.
|
|
16
|
+
4. Exact repository/folder slug match against the cached index.
|
|
17
|
+
- **Unlinked directories send 0 bytes:** If a folder or git repository does not match a linked Crew project (for example, an employer or private repository on the same machine), hooks exit immediately with **zero HTTP requests** — no folder path, no git remote URL, no repo name, no tool name, and no prompt text leaves the machine.
|
|
18
|
+
- **Permission questions never fall back:** Tool permission prompts only route to Crew when the active directory matches a linked project; unlinked folders always prompt locally in your terminal/IDE.
|
|
19
|
+
|
|
20
|
+
### 2. Local Secret Scrubbing Before Upload
|
|
21
|
+
|
|
22
|
+
Before any mirrored conversation text, summary, or hand-off note leaves the machine (`lib/conversation-mirror.cjs`, `lib/handoff.cjs`, `lib/codemap.cjs`), a local redaction pass strips common secret formats:
|
|
23
|
+
|
|
24
|
+
- PEM private key blocks (`-----BEGIN ... PRIVATE KEY-----`)
|
|
25
|
+
- API keys & tokens (`sk-*`, `sk-proj-*`, `sk-ant-*`, `sk_live_*`, `sk_test_*`, `ghp_*`, `gho_*`, `github_pat_*`, `glpat-*`, `polar_oat_*`, `AIza*`, `AKIA*`, `xai-*`, `xox*`, `whsec_*`, `mc_*`)
|
|
26
|
+
- `Authorization: Bearer <token>` headers
|
|
27
|
+
- Inline key-value assignments matching `password`, `passwd`, `secret`, `api_key`, `access_token`, and `auth_token`
|
|
28
|
+
|
|
29
|
+
### 3. OS Keychain & Token Isolation
|
|
30
|
+
|
|
31
|
+
- Agent and device tokens (`mc_*`) are stored exclusively in the operating system keychain (`lib/keychain.cjs`):
|
|
32
|
+
- **macOS:** Keychain (`security`)
|
|
33
|
+
- **Linux:** Secret Service (`secret-tool`)
|
|
34
|
+
- **Windows:** Credential Manager (`CredWrite`/`CredRead`)
|
|
35
|
+
- Tokens are passed over stdin pipes — never in CLI arguments (`argv`), never in config files, and never printed to a terminal (`crew mcp-headers` and `crew mcp-token` refuse interactive TTYs).
|
|
36
|
+
- `lib/state.cjs` enforces a defense-in-depth `TOKENISH` check that refuses to write any token-shaped string into `~/.mevvcrew/device.json`.
|
|
37
|
+
|
|
38
|
+
### 4. Optional End-to-End Encryption
|
|
39
|
+
|
|
40
|
+
- `crew e2e on` enables client-side E2E encryption (`lib/e2e.cjs`, `lib/e2e-send.cjs`) using Node.js native `crypto`: X25519 key agreement, HKDF-SHA256, AES-256-GCM session envelopes, and Ed25519-signed viewer grants verified by 6-digit safety codes.
|
|
41
|
+
- Private E2E keys remain in the OS keychain; the server never receives plaintext or private keys.
|
|
42
|
+
|
|
43
|
+
### 5. Supply-Chain & Local Network Boundaries
|
|
44
|
+
|
|
45
|
+
- **Zero runtime dependencies:** Only Node.js standard library modules are loaded at runtime.
|
|
46
|
+
- **Loopback-only preview tunnels (`lib/tunnel.cjs`):** Proxies strictly to `127.0.0.1:<localPort>` and strips sensitive headers (`authorization`, `cookie`, `x-tunnel-token`).
|
|
47
|
+
- **Signed skill packs (`lib/skill-keys.cjs`, `lib/minisign.cjs`):** Verified locally against pinned Minisign public keys before installation.
|
|
48
|
+
- **Checksum-verified updates (`lib/update.cjs`):** SHA-256 verified prior to extracting or activating a runtime update.
|
|
49
|
+
- **Signed & notarized macOS pulse helper (`macos/mevvCrew.app`):** Apple Developer ID signed and notarized so macOS Login Items displays verified publisher identity (`tools/macos-helper/SIGNED`).
|
|
50
|
+
|
|
51
|
+
## Reporting a Vulnerability
|
|
52
|
+
|
|
53
|
+
If you discover a security vulnerability or privacy bypass in `mevvcrew`:
|
|
54
|
+
|
|
55
|
+
- **Email:** `iletisim@mevvsoft.com`
|
|
56
|
+
- **Please include:** affected version (`crew --version`), OS and Node.js version, minimal reproduction steps, and expected vs. actual impact.
|
|
57
|
+
- **Do not** open a public GitHub issue for undisclosed security vulnerabilities.
|
|
58
|
+
|
|
59
|
+
We aim to acknowledge reports within **48 hours** and coordinate a fix and disclosure timeline with the reporter.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Antigravity (spec 5.17, AGT-08): the app (2.x) and its CLI `agy` read the same global MCP file,
|
|
3
|
+
* ~/.gemini/config/mcp_config.json (https://antigravity.google/docs/mcp; measured on Antigravity 2.28.2 and agy 1.5.15,
|
|
4
|
+
* 23.11.2026: `agy mcp list` lists what crew wrote). Its remote entries take literal headers only, so it gets a stdio
|
|
5
|
+
* server that runs `crew mcp-bridge <agent>` (the bridge reads the token from the keychain). No token in the file. */
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { ideAdapter } = require('./ide-config.cjs');
|
|
8
|
+
|
|
9
|
+
module.exports = ideAdapter({
|
|
10
|
+
id: 'antigravity',
|
|
11
|
+
name: 'Antigravity',
|
|
12
|
+
bins: ['agy'],
|
|
13
|
+
apps: ['Antigravity.app'],
|
|
14
|
+
dirs: (ctx) => [path.join(ctx.home, '.gemini', 'antigravity')],
|
|
15
|
+
file: (ctx) => path.join(ctx.home, '.gemini', 'config', 'mcp_config.json'),
|
|
16
|
+
pointer: ['mcpServers', 'mevvcrew'],
|
|
17
|
+
doc: 'https://antigravity.google/docs/mcp',
|
|
18
|
+
});
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Claude Code (spec 5.17). A user-scope `mevvcrew` HTTP MCP server whose header comes from `headersHelper`
|
|
3
|
+
* (`crew mcp-headers <agent>` reads the keychain). Measured 18.11.2026 on Claude Code 2.1.327: both
|
|
4
|
+
* `${MEVVCREW_TOKEN}` header expansion and headersHelper sent the header in `claude mcp list` and at `claude -p`
|
|
5
|
+
* start-up. The helper is used anyway: with it the token is never in the session's environment, so the commands the
|
|
6
|
+
* session runs cannot read it.
|
|
7
|
+
* Profile: --claude-config-dir, else CLAUDE_CONFIG_DIR, else ~/.claude-personal, else ~/.claude only after an
|
|
8
|
+
* explicit yes (default no). A directory in ~/.config/mevvcrew/claude-profile-denylist is never written. */
|
|
9
|
+
const fs = require('node:fs');
|
|
10
|
+
const path = require('node:path');
|
|
11
|
+
const files = require('../lib/files.cjs');
|
|
12
|
+
const { which } = require('../lib/detect.cjs');
|
|
13
|
+
|
|
14
|
+
const NAME = 'mevvcrew';
|
|
15
|
+
|
|
16
|
+
function expand(home, p) {
|
|
17
|
+
const s = String(p || '').trim();
|
|
18
|
+
if (s === '~') return home;
|
|
19
|
+
if (s.startsWith('~/') || s.startsWith('~\\')) return path.join(home, s.slice(2));
|
|
20
|
+
return path.resolve(s);
|
|
21
|
+
}
|
|
22
|
+
function real(p) { try { return fs.realpathSync(p); } catch { return path.resolve(p); } }
|
|
23
|
+
function denylistFile(ctx) { return path.join(ctx.home, '.config', 'mevvcrew', 'claude-profile-denylist'); }
|
|
24
|
+
function denylist(ctx) {
|
|
25
|
+
const t = files.readText(denylistFile(ctx));
|
|
26
|
+
if (!t) return new Set();
|
|
27
|
+
return new Set(t.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith('#')).map((l) => real(expand(ctx.home, l))));
|
|
28
|
+
}
|
|
29
|
+
const denied = (ctx, dir) => denylist(ctx).has(real(dir));
|
|
30
|
+
|
|
31
|
+
// -> {dir, isDefault, config} or {skip: reason}
|
|
32
|
+
async function resolveProfile(ctx) {
|
|
33
|
+
const home = ctx.home;
|
|
34
|
+
const def = path.join(home, '.claude');
|
|
35
|
+
const pick = (dir, isDefault) => ({ dir, isDefault, config: isDefault ? path.join(home, '.claude.json') : path.join(dir, '.claude.json') });
|
|
36
|
+
if (ctx.opts['claude-config-dir']) {
|
|
37
|
+
const dir = expand(home, ctx.opts['claude-config-dir']);
|
|
38
|
+
if (denied(ctx, dir)) return { skip: ctx.m('claude_denied', { dir }) };
|
|
39
|
+
return pick(dir, real(dir) === real(def));
|
|
40
|
+
}
|
|
41
|
+
if (ctx.env.CLAUDE_CONFIG_DIR) {
|
|
42
|
+
const dir = expand(home, ctx.env.CLAUDE_CONFIG_DIR);
|
|
43
|
+
if (!denied(ctx, dir)) return pick(dir, false);
|
|
44
|
+
}
|
|
45
|
+
const personal = path.join(home, '.claude-personal');
|
|
46
|
+
if (fs.existsSync(personal) && !denied(ctx, personal)) return pick(personal, false);
|
|
47
|
+
if ((fs.existsSync(def) || fs.existsSync(path.join(home, '.claude.json'))) && !denied(ctx, def)) {
|
|
48
|
+
if (await ctx.ask(ctx.m('claude_default_q'))) return pick(def, true);
|
|
49
|
+
return { skip: ctx.m('claude_default_no') };
|
|
50
|
+
}
|
|
51
|
+
return { skip: ctx.m('claude_no_profile') };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function envFor(ctx, profile) {
|
|
55
|
+
const env = { ...ctx.env };
|
|
56
|
+
if (profile.isDefault) delete env.CLAUDE_CONFIG_DIR; else env.CLAUDE_CONFIG_DIR = profile.dir;
|
|
57
|
+
return env;
|
|
58
|
+
}
|
|
59
|
+
function current(profile, name = NAME) {
|
|
60
|
+
try { return files.getAt(files.readJson(profile.config), ['mcpServers', name]); } catch { return undefined; }
|
|
61
|
+
}
|
|
62
|
+
const ours = (entry) => !!(entry && typeof entry.headersHelper === 'string' && / mcp-headers /.test(entry.headersHelper + ' '));
|
|
63
|
+
|
|
64
|
+
module.exports = {
|
|
65
|
+
id: 'claude',
|
|
66
|
+
bins: ['claude'],
|
|
67
|
+
headless: true,
|
|
68
|
+
detect: (ctx) => !!which('claude', { env: ctx.env, platform: ctx.platform }),
|
|
69
|
+
resolveProfile,
|
|
70
|
+
denylistFile,
|
|
71
|
+
denied,
|
|
72
|
+
real,
|
|
73
|
+
expand,
|
|
74
|
+
|
|
75
|
+
async install(ctx, agent) {
|
|
76
|
+
const profile = await resolveProfile(ctx);
|
|
77
|
+
if (profile.skip) return { skipped: profile.skip };
|
|
78
|
+
const name = ctx.serverName || NAME;
|
|
79
|
+
const entry = { type: 'http', url: ctx.mcpUrl, headersHelper: ctx.helperCmd(agent.name) };
|
|
80
|
+
const existing = current(profile, name);
|
|
81
|
+
if (existing && !ours(existing)) {
|
|
82
|
+
return { skipped: ctx.m('claude_exists', { dir: profile.dir }), print: `claude mcp add-json -s user ${name} '${JSON.stringify(entry)}'` };
|
|
83
|
+
}
|
|
84
|
+
const env = envFor(ctx, profile);
|
|
85
|
+
if (existing) await ctx.run('claude', ['mcp', 'remove', '-s', 'user', name], { env });
|
|
86
|
+
const r = await ctx.run('claude', ['mcp', 'add-json', '-s', 'user', name, JSON.stringify(entry)], { env });
|
|
87
|
+
if (r.code !== 0 || !ours(current(profile, name))) return { skipped: ctx.m('claude_failed', { code: r.code }) };
|
|
88
|
+
return { method: 'headersHelper', records: [{ kind: 'claude-mcp', name, dir: profile.dir, isDefault: profile.isDefault, config: profile.config }] };
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Removes the entry only while it is still ours. Without the claude binary the JSON key is removed directly.
|
|
92
|
+
async remove(ctx, record) {
|
|
93
|
+
const name = record.name || NAME;
|
|
94
|
+
if (!ours(current(record, name))) return false;
|
|
95
|
+
if (which('claude', { env: ctx.env, platform: ctx.platform })) {
|
|
96
|
+
const r = await ctx.run('claude', ['mcp', 'remove', '-s', 'user', name], { env: envFor(ctx, record) });
|
|
97
|
+
if (r.code === 0 && !current(record, name)) return true;
|
|
98
|
+
}
|
|
99
|
+
return files.jsonDelete({ file: record.config, pointer: ['mcpServers', name] }, ours);
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Unattended run (Task 20 runner); permission prompts stay on, no skip-permissions flag ever.
|
|
103
|
+
headlessCommand(ctx, { prompt }) { return { cmd: 'claude', args: ['-p'], stdin: prompt }; },
|
|
104
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Codex CLI (spec 5.17): a marked block in ~/.codex/config.toml (CODEX_HOME respected) with [mcp_servers.mevvcrew],
|
|
3
|
+
* url and http_headers_helper = "crew mcp-headers <agent>". Measured 18.11.2026 on codex-cli 0.155.1: both
|
|
4
|
+
* http_headers_helper (a command string with arguments) and bearer_token_env_var sent the header in `codex exec`;
|
|
5
|
+
* the helper needs no shell wrapper and keeps the token out of the environment. A [mcp_servers.mevvcrew] table
|
|
6
|
+
* written by hand (outside the markers) is never touched: the block is printed instead. */
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const files = require('../lib/files.cjs');
|
|
9
|
+
const { which } = require('../lib/detect.cjs');
|
|
10
|
+
|
|
11
|
+
const BLOCK = 'mevvcrew';
|
|
12
|
+
const tomlString = (s) => `"${String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
13
|
+
const fileOf = (ctx) => path.join(ctx.env.CODEX_HOME ? path.resolve(ctx.env.CODEX_HOME) : path.join(ctx.home, '.codex'), 'config.toml');
|
|
14
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
15
|
+
const handWritten = (text, name = BLOCK) => new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*(?:${escapeRe(name)}|"${escapeRe(name)}"|'${escapeRe(name)}')\\s*\\]`, 'm').test(files.withoutBlock(text || '', name));
|
|
16
|
+
|
|
17
|
+
function body(ctx, agent, name = BLOCK) {
|
|
18
|
+
return `# Written by crew connect (mevvCrew). crew disconnect removes this block. No token is stored here.
|
|
19
|
+
[mcp_servers.${name}]
|
|
20
|
+
url = ${tomlString(ctx.mcpUrl)}
|
|
21
|
+
http_headers_helper = ${tomlString(ctx.helperCmd(agent.name))}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
id: 'codex',
|
|
26
|
+
bins: ['codex'],
|
|
27
|
+
headless: true,
|
|
28
|
+
detect: (ctx) => !!which('codex', { env: ctx.env, platform: ctx.platform }),
|
|
29
|
+
fileOf,
|
|
30
|
+
|
|
31
|
+
async install(ctx, agent) {
|
|
32
|
+
const file = fileOf(ctx);
|
|
33
|
+
const name = ctx.serverName || BLOCK;
|
|
34
|
+
const b = body(ctx, agent, name);
|
|
35
|
+
if (handWritten(files.readText(file), name)) return { skipped: ctx.m('codex_exists', { file }), print: b };
|
|
36
|
+
return { method: 'http_headers_helper', records: [files.upsertBlock(file, name, b)] };
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
async remove(ctx, record) { return files.removeBlock(record); },
|
|
40
|
+
|
|
41
|
+
// Task 20 runner: the prompt on stdin, sandboxed to the work dir, the last message to a file.
|
|
42
|
+
headlessCommand(ctx, { dir, outFile, prompt }) {
|
|
43
|
+
return { cmd: 'codex', args: ['exec', '-C', dir, '--sandbox', 'workspace-write', '--skip-git-repo-check', '--ephemeral', '-o', outFile, '-'], stdin: prompt };
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Cursor (AGT-08): the editor and its CLI (cursor-agent) read the global ~/.cursor/mcp.json, `mcpServers.<name>` with
|
|
3
|
+
* command, args and env for a stdio server (https://cursor.com/docs/context/mcp). crew writes a stdio server that runs
|
|
4
|
+
* `crew mcp-bridge <agent>`; the token stays in the keychain. */
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { ideAdapter } = require('./ide-config.cjs');
|
|
7
|
+
|
|
8
|
+
module.exports = ideAdapter({
|
|
9
|
+
id: 'cursor',
|
|
10
|
+
name: 'Cursor',
|
|
11
|
+
bins: ['cursor', 'cursor-agent'],
|
|
12
|
+
apps: ['Cursor.app'],
|
|
13
|
+
dirs: (ctx) => [path.join(ctx.home, '.cursor')],
|
|
14
|
+
file: (ctx) => path.join(ctx.home, '.cursor', 'mcp.json'),
|
|
15
|
+
pointer: ['mcpServers', 'mevvcrew'],
|
|
16
|
+
doc: 'https://cursor.com/docs/context/mcp',
|
|
17
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Gemini CLI (spec 5.17): ~/.gemini/settings.json `mcpServers.mevvcrew = {httpUrl, headers}`; the header holds only
|
|
3
|
+
* ${MEVVCREW_TOKEN} (Gemini CLI expands $VAR and ${VAR}), the shell wrapper fills it for the `gemini` command.
|
|
4
|
+
* Interactive use only: unattended runs stay off until Gemini's approval behaviour is measured. */
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
const { jsonAdapter } = require('./json-config.cjs');
|
|
7
|
+
|
|
8
|
+
module.exports = jsonAdapter({
|
|
9
|
+
id: 'gemini',
|
|
10
|
+
bins: ['gemini'],
|
|
11
|
+
method: 'env+wrapper',
|
|
12
|
+
file: (ctx) => path.join(ctx.home, '.gemini', 'settings.json'),
|
|
13
|
+
pointer: ['mcpServers', 'mevvcrew'],
|
|
14
|
+
value: (ctx) => ({ httpUrl: ctx.mcpUrl, headers: { Authorization: 'Bearer ${MEVVCREW_TOKEN}' } }),
|
|
15
|
+
isOurs: (v, ctx) => !!v && v.httpUrl === ctx.mcpUrl,
|
|
16
|
+
wrap: 'gemini',
|
|
17
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Any other MCP client (spec 5.17): nothing is written. crew connect prints the server URL, the header helper and
|
|
3
|
+
* the stdio bridge command; the user pastes what their client supports. Never detected, only by --tools generic. */
|
|
4
|
+
module.exports = {
|
|
5
|
+
id: 'generic',
|
|
6
|
+
bins: [],
|
|
7
|
+
headless: false,
|
|
8
|
+
detect: () => false,
|
|
9
|
+
async install(ctx, agent) {
|
|
10
|
+
const bridge = ctx.bridgeEntry(agent.name);
|
|
11
|
+
return {
|
|
12
|
+
method: 'printed',
|
|
13
|
+
records: [],
|
|
14
|
+
print: [
|
|
15
|
+
`URL: ${ctx.mcpUrl}`,
|
|
16
|
+
`Header: Authorization (JSON from: ${ctx.helperCmd(agent.name)})`,
|
|
17
|
+
`stdio: ${[bridge.command, ...bridge.args].join(' ')}`,
|
|
18
|
+
].join('\n'),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
async remove() { return true; },
|
|
22
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Grok Build (xAI's official coding agent CLI, `grok`; AGT-08). Its user config is $GROK_HOME/config.toml (default
|
|
3
|
+
* ~/.grok/config.toml), a stdio MCP server is `[mcp_servers.<name>]` with command and args
|
|
4
|
+
* (https://docs.x.ai/build/features/mcp-servers, https://docs.x.ai/build/settings/reference). crew writes a marked
|
|
5
|
+
* block whose server runs `crew mcp-bridge <agent>`: the token stays in the keychain, nothing secret is in the file.
|
|
6
|
+
* Grok also loads the mevvcrew entry of ~/.claude.json, ~/.cursor/mcp.json and ~/.codex/config.toml; a config.toml
|
|
7
|
+
* server of the same name comes first, so Grok talks to Crew as its own agent (measured 23.11.2026 on 1.0.92 with
|
|
8
|
+
* `grok inspect --json`: without this block it took Cursor's entry). A [mcp_servers.mevvcrew] table written by hand
|
|
9
|
+
* (outside the markers) is never touched: the block is printed instead. */
|
|
10
|
+
const path = require('node:path');
|
|
11
|
+
const files = require('../lib/files.cjs');
|
|
12
|
+
const { which } = require('../lib/detect.cjs');
|
|
13
|
+
|
|
14
|
+
const BLOCK = 'mevvcrew';
|
|
15
|
+
const tomlString = (s) => `"${String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
16
|
+
const grokHome = (ctx) => (ctx.env.GROK_HOME ? path.resolve(ctx.env.GROK_HOME) : path.join(ctx.home, '.grok'));
|
|
17
|
+
const fileOf = (ctx) => path.join(grokHome(ctx), 'config.toml');
|
|
18
|
+
const escapeRe = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
19
|
+
const handWritten = (text, name = BLOCK) => {
|
|
20
|
+
const t = files.withoutBlock(text || '', name);
|
|
21
|
+
const k = escapeRe(name);
|
|
22
|
+
// [mcp_servers.mevvcrew], or mevvcrew = {...} inside an [mcp_servers] table.
|
|
23
|
+
return new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\.\\s*(?:${k}|"${k}"|'${k}')\\s*\\]`, 'm').test(t)
|
|
24
|
+
|| new RegExp(`^\\s*\\[\\s*mcp_servers\\s*\\]\\s*$[\\s\\S]*?^\\s*(?:${k}|"${k}"|'${k}')\\s*=`, 'm').test(t)
|
|
25
|
+
|| new RegExp(`^\\s*mcp_servers\\s*\\.\\s*${k}\\s*[.=]`, 'm').test(t);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function body(ctx, agent, name = BLOCK) {
|
|
29
|
+
const b = ctx.bridgeEntry(agent.name);
|
|
30
|
+
return `# Written by crew connect (mevvCrew). crew disconnect removes this block. No token is stored here.
|
|
31
|
+
[mcp_servers.${name}]
|
|
32
|
+
command = ${tomlString(b.command)}
|
|
33
|
+
args = [${b.args.map(tomlString).join(', ')}]`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = {
|
|
37
|
+
id: 'grok',
|
|
38
|
+
bins: ['grok'],
|
|
39
|
+
headless: false,
|
|
40
|
+
detect: (ctx) => !!which('grok', { env: ctx.env, platform: ctx.platform }),
|
|
41
|
+
fileOf,
|
|
42
|
+
|
|
43
|
+
// The Crew server, then the safe permission policy (lib/grok-policy.cjs): Grok would otherwise follow ~/.claude's
|
|
44
|
+
// auto mode and allow rules and never ask through Crew.
|
|
45
|
+
async install(ctx, agent) {
|
|
46
|
+
const file = fileOf(ctx);
|
|
47
|
+
const name = ctx.serverName || BLOCK;
|
|
48
|
+
const b = body(ctx, agent, name);
|
|
49
|
+
if (handWritten(files.readText(file), name)) return { skipped: ctx.m('grok_exists', { file }), print: b };
|
|
50
|
+
const records = [{ ...files.upsertBlock(file, name, b), adapter: 'grok' }];
|
|
51
|
+
const p = require('../lib/grok-policy.cjs').write(ctx);
|
|
52
|
+
if (p.record) records.push(p.record);
|
|
53
|
+
const note = p.record ? ctx.m('grok_policy_on', { file }) : p.conflict ? ctx.m('grok_policy_conflict', { file }) : ctx.m('grok_policy_off_kept');
|
|
54
|
+
return { method: 'mcp-bridge', records, note, ...(p.conflict ? { print: p.print } : {}) };
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
async remove(ctx, record) { return files.removeBlock(record); },
|
|
58
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* Agentic IDEs and their CLIs (roadmap AGT-08): Antigravity, Cursor, VS Code (GitHub Copilot agent mode), Windsurf
|
|
3
|
+
* and Zed. Each reads one MCP settings file that may hold comments and trailing commas (JSONC). crew writes one
|
|
4
|
+
* member, `mevvcrew`, with a stdio server that runs `crew mcp-bridge <agent>` (the token is read from the keychain by
|
|
5
|
+
* the bridge, never written to the file). The edit is text-preserving (lib/json-text.cjs): every other byte of the
|
|
6
|
+
* file stays as it was, the file is copied to <file>.mevvcrew-backup before the first change, and crew disconnect
|
|
7
|
+
* takes out exactly what crew put in. A member someone wrote by hand is never overwritten: the value is printed.
|
|
8
|
+
* Detection looks at the file system only (nothing is run): a CLI on PATH, the app bundle (macOS) or the IDE's own
|
|
9
|
+
* settings folder. */
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const path = require('node:path');
|
|
12
|
+
const files = require('../lib/files.cjs');
|
|
13
|
+
const jt = require('../lib/json-text.cjs');
|
|
14
|
+
const { which } = require('../lib/detect.cjs');
|
|
15
|
+
|
|
16
|
+
// Where macOS apps live; CREW_APP_DIRS (path list) replaces them, so a test never sees this computer's apps.
|
|
17
|
+
const appDirs = (ctx) => ctx.appDirs
|
|
18
|
+
|| (ctx.env && ctx.env.CREW_APP_DIRS !== undefined ? String(ctx.env.CREW_APP_DIRS).split(path.delimiter).filter(Boolean) : ['/Applications', path.join(ctx.home, 'Applications')]);
|
|
19
|
+
// The per-user settings root of an Electron app: macOS Application Support, Windows %APPDATA%, else ~/.config.
|
|
20
|
+
function appData(ctx) {
|
|
21
|
+
if (ctx.platform === 'darwin') return path.join(ctx.home, 'Library', 'Application Support');
|
|
22
|
+
if (ctx.platform === 'win32') return ctx.env.APPDATA ? path.resolve(ctx.env.APPDATA) : path.join(ctx.home, 'AppData', 'Roaming');
|
|
23
|
+
return ctx.env.XDG_CONFIG_HOME ? path.resolve(ctx.env.XDG_CONFIG_HOME) : path.join(ctx.home, '.config');
|
|
24
|
+
}
|
|
25
|
+
const isDir = (p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } };
|
|
26
|
+
|
|
27
|
+
// The stdio server every IDE adapter writes (spec.value may reshape it).
|
|
28
|
+
const bridgeValue = (ctx, agent) => ctx.bridgeEntry(agent.name);
|
|
29
|
+
const isBridge = (v) => !!v && typeof v === 'object' && Array.isArray(v.args) && v.args.includes('mcp-bridge');
|
|
30
|
+
|
|
31
|
+
// spec: {id, name, bins, apps, dirs(ctx), file(ctx), pointer, value(ctx, agent)?, isOurs(v)?, doc}
|
|
32
|
+
function ideAdapter(spec) {
|
|
33
|
+
const value = spec.value || bridgeValue;
|
|
34
|
+
const isOurs = spec.isOurs || isBridge;
|
|
35
|
+
const a = {
|
|
36
|
+
id: spec.id,
|
|
37
|
+
name: spec.name,
|
|
38
|
+
bins: spec.bins,
|
|
39
|
+
apps: spec.apps || [],
|
|
40
|
+
ide: true,
|
|
41
|
+
doc: spec.doc,
|
|
42
|
+
headless: false,
|
|
43
|
+
declarative: false,
|
|
44
|
+
file: (ctx) => spec.file(ctx),
|
|
45
|
+
pointer: spec.pointer,
|
|
46
|
+
// Which of the three signs was seen: 'bin', 'app', 'dir' or null.
|
|
47
|
+
seen(ctx) {
|
|
48
|
+
if (spec.bins.some((b) => which(b, { env: ctx.env, platform: ctx.platform }))) return 'bin';
|
|
49
|
+
if (ctx.platform === 'darwin' && a.apps.some((app) => appDirs(ctx).some((d) => isDir(path.join(d, app))))) return 'app';
|
|
50
|
+
if ((spec.dirs ? spec.dirs(ctx) : []).some(isDir)) return 'dir';
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
detect: (ctx) => !!a.seen(ctx),
|
|
54
|
+
async install(ctx, agent) {
|
|
55
|
+
const file = spec.file(ctx);
|
|
56
|
+
const ptr = ctx.serverName && spec.pointer.at(-1) === 'mevvcrew' ? [...spec.pointer.slice(0, -1), ctx.serverName] : spec.pointer;
|
|
57
|
+
const want = value(ctx, agent);
|
|
58
|
+
const text = files.readText(file);
|
|
59
|
+
if (!jt.readable(text)) return { skipped: ctx.m('json_unreadable', { file }) };
|
|
60
|
+
const existing = jt.valueAt(text, ptr);
|
|
61
|
+
if (existing !== undefined && !isOurs(existing, ctx)) {
|
|
62
|
+
return { skipped: ctx.m('json_exists', { file, key: ptr.join('.') }), print: JSON.stringify(want, null, 2) };
|
|
63
|
+
}
|
|
64
|
+
// Our own member from an earlier connect (another version's helper path) is taken out first, then written again.
|
|
65
|
+
let base = text;
|
|
66
|
+
if (existing !== undefined) {
|
|
67
|
+
const r = jt.removeMember(base, ptr, { prune: ptr.length, match: (v) => isOurs(v, ctx) });
|
|
68
|
+
if (r) base = r.text;
|
|
69
|
+
}
|
|
70
|
+
const set = jt.setMissing(base, ptr, want);
|
|
71
|
+
let backup = null;
|
|
72
|
+
if (text !== null) {
|
|
73
|
+
backup = `${file}.mevvcrew-backup`;
|
|
74
|
+
if (!fs.existsSync(backup)) fs.copyFileSync(file, backup);
|
|
75
|
+
}
|
|
76
|
+
files.writeText(file, set.text);
|
|
77
|
+
const record = {
|
|
78
|
+
kind: 'json', text: true, adapter: spec.id, file, pointer: ptr, created: text === null,
|
|
79
|
+
blank: text !== null && !text.trim(), prune: ptr.length - set.created, backup,
|
|
80
|
+
};
|
|
81
|
+
return { method: 'mcp-bridge', records: [record] };
|
|
82
|
+
},
|
|
83
|
+
async remove(ctx, record) {
|
|
84
|
+
if (record.kind === 'block') return files.removeBlock(record);
|
|
85
|
+
const text = files.readText(record.file);
|
|
86
|
+
if (text === null) return false;
|
|
87
|
+
if (!record.text) return files.jsonDelete(record, (v) => isOurs(v, ctx));
|
|
88
|
+
const r = jt.removeMember(text, record.pointer, { prune: Math.max(1, record.prune || 1), match: (v) => isOurs(v, ctx) });
|
|
89
|
+
if (!r) return false;
|
|
90
|
+
const empty = (() => { try { const v = jt.plain(r.text, jt.parse(r.text)); return v && typeof v === 'object' && !Object.keys(v).length; } catch { return false; } })();
|
|
91
|
+
if (empty && record.created) fs.unlinkSync(record.file);
|
|
92
|
+
else files.writeText(record.file, empty && record.blank ? '' : r.text);
|
|
93
|
+
if (record.backup) { try { fs.unlinkSync(record.backup); } catch { /* already gone */ } }
|
|
94
|
+
return true;
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
return a;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = { ideAdapter, appData, appDirs, isBridge };
|