@opencoop/opencode-plugin 1.0.0

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.
Files changed (44) hide show
  1. package/LICENSE +178 -0
  2. package/README.fa.md +221 -0
  3. package/README.md +245 -0
  4. package/dist/auth/auth-manager.d.ts +45 -0
  5. package/dist/auth/auth-manager.js +157 -0
  6. package/dist/auth/auth-manager.js.map +1 -0
  7. package/dist/auth/session-manager.d.ts +14 -0
  8. package/dist/auth/session-manager.js +50 -0
  9. package/dist/auth/session-manager.js.map +1 -0
  10. package/dist/filesystem/change-tracker.d.ts +18 -0
  11. package/dist/filesystem/change-tracker.js +96 -0
  12. package/dist/filesystem/change-tracker.js.map +1 -0
  13. package/dist/filesystem/file-manager.d.ts +39 -0
  14. package/dist/filesystem/file-manager.js +189 -0
  15. package/dist/filesystem/file-manager.js.map +1 -0
  16. package/dist/filesystem/lock-manager.d.ts +15 -0
  17. package/dist/filesystem/lock-manager.js +120 -0
  18. package/dist/filesystem/lock-manager.js.map +1 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.js +36 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/server/mcp-server.d.ts +20 -0
  23. package/dist/server/mcp-server.js +392 -0
  24. package/dist/server/mcp-server.js.map +1 -0
  25. package/dist/types/index.d.ts +80 -0
  26. package/dist/types/index.js +2 -0
  27. package/dist/types/index.js.map +1 -0
  28. package/dist/utils/config.d.ts +3 -0
  29. package/dist/utils/config.js +38 -0
  30. package/dist/utils/config.js.map +1 -0
  31. package/dist/utils/database.d.ts +12 -0
  32. package/dist/utils/database.js +110 -0
  33. package/dist/utils/database.js.map +1 -0
  34. package/dist/utils/logger.d.ts +2 -0
  35. package/dist/utils/logger.js +11 -0
  36. package/dist/utils/logger.js.map +1 -0
  37. package/dist/web/public/assets/app.js +446 -0
  38. package/dist/web/public/assets/style.css +639 -0
  39. package/dist/web/public/index.html +190 -0
  40. package/dist/web/public/invite.html +132 -0
  41. package/dist/web/server.d.ts +3 -0
  42. package/dist/web/server.js +150 -0
  43. package/dist/web/server.js.map +1 -0
  44. package/package.json +47 -0
package/LICENSE ADDED
@@ -0,0 +1,178 @@
1
+ OpenCOOP License Agreement
2
+ ==========================
3
+
4
+ Copyright (c) 2026 Hamid Pajand <HamidPajand@gmail.com>
5
+
6
+ This software is licensed under the OpenCOOP Non-Commercial License.
7
+
8
+ 1. DEFINITIONS
9
+ --------------
10
+
11
+ "Software" refers to the OpenCOOP software, including all source code,
12
+ documentation, and associated files.
13
+
14
+ "Commercial Use" means any use of the Software primarily intended for
15
+ or directed toward commercial advantage or monetary compensation.
16
+
17
+ "Non-Commercial Use" means use for personal, educational, research,
18
+ or open-source purposes not primarily intended for commercial advantage.
19
+
20
+ 2. PERMITTED USES (Non-Commercial)
21
+ -----------------------------------
22
+
23
+ You are free to:
24
+
25
+ a) Use, copy, modify, and distribute the Software for Non-Commercial
26
+ purposes without restriction.
27
+
28
+ b) Create derivative works based on the Software for Non-Commercial
29
+ purposes.
30
+
31
+ c) Use the Software in educational institutions, research projects,
32
+ or personal projects.
33
+
34
+ d) Fork and modify the Software for learning and experimentation.
35
+
36
+ 3. COMMERCIAL USE RESTRICTIONS
37
+ -------------------------------
38
+
39
+ Commercial use of the Software is strictly prohibited without explicit
40
+ written permission from the copyright holder.
41
+
42
+ This includes, but is not limited to:
43
+
44
+ a) Selling the Software or any derivative work.
45
+
46
+ b) Using the Software as part of a commercial product or service.
47
+
48
+ c) Using the Software to generate revenue, whether directly or indirectly.
49
+
50
+ d) Offering the Software as a paid service or subscription.
51
+
52
+ e) Including the Software in commercial consulting or development services.
53
+
54
+ 4. COMMERCIAL LICENSING
55
+ ------------------------
56
+
57
+ To obtain a commercial license, you must:
58
+
59
+ a) Contact the copyright holder at: HamidPajand@gmail.com
60
+
61
+ b) Obtain explicit written permission before any commercial use.
62
+
63
+ c) Pay any applicable licensing fees as agreed upon.
64
+
65
+ 5. ATTRIBUTION
66
+ --------------
67
+
68
+ You must retain the following in all copies or substantial portions
69
+ of the Software:
70
+
71
+ a) The original copyright notice.
72
+
73
+ b) This license notice.
74
+
75
+ c) A link to the original repository:
76
+ https://github.com/Pajand/opencoop
77
+
78
+ 6. DISCLAIMER OF WARRANTIES
79
+ ---------------------------
80
+
81
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
82
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
83
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
84
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
85
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
86
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
87
+ DEALINGS IN THE SOFTWARE.
88
+
89
+ 7. TERMINATION
90
+ --------------
91
+
92
+ This license terminates automatically if you breach any of its terms.
93
+ Upon termination, you must cease all use of the Software and destroy
94
+ all copies in your possession.
95
+
96
+ 8. GOVERNING LAW
97
+ -----------------
98
+
99
+ This agreement shall be governed by and construed in accordance with
100
+ the laws of the Islamic Republic of Iran, without regard to its conflict
101
+ of laws principles.
102
+
103
+ 9. CONTACT
104
+ ----------
105
+
106
+ For commercial licensing inquiries, please contact:
107
+
108
+ Hamid Pajand
109
+ Email: HamidPajand@gmail.com
110
+ GitHub: https://github.com/Pajand
111
+
112
+ ---
113
+
114
+ _FULL LICENSE TEXT (English):_
115
+
116
+ OpenCOOP Non-Commercial License
117
+
118
+ Copyright (c) 2026 Hamid Pajand
119
+
120
+ Permission is hereby granted, free of charge, to any person obtaining a
121
+ copy of this software and associated documentation files (the "Software"),
122
+ to deal in the Software without restriction, including without limitation
123
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
124
+ and/or sell copies of the Software, subject to the following conditions:
125
+
126
+ 1. The above copyright notice and this permission notice shall be included
127
+ in all copies or substantial portions of the Software.
128
+
129
+ 2. Commercial use of the Software or any derivative work thereof is
130
+ prohibited without prior written permission from the copyright holder.
131
+ Commercial use includes but is not limited to: selling, using as part
132
+ of a commercial product or service, generating revenue, or offering
133
+ as a paid service.
134
+
135
+ 3. Non-commercial use, including personal, educational, research, and
136
+ open-source purposes, is permitted without restriction.
137
+
138
+ 4. Any commercial use requires an explicit written license from:
139
+ Hamid Pajand <HamidPajand@gmail.com>
140
+
141
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
142
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
143
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
144
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
145
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
146
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
147
+ OTHER DEALINGS IN THE SOFTWARE.
148
+
149
+ ---
150
+
151
+ _FULL LICENSE TEXT (Persian/فارسی):_
152
+
153
+ لایسنس غیرتجاری اوپن‌کوپ
154
+
155
+ حق چاپ (c) ۲۰۲۶ حمید پژند
156
+
157
+ بدین وسیله به هر شخصی که نسخه‌ای از این نرم‌افزار و فایل‌های مستندات مرتبط («نرم‌افزار») را دریافت کند، اجازه داده می‌شود بدون محدودیت، از جمله بدون محدودیت به حقوق استفاده، کپی، تغییر، ادغام، انتشار، توزیع، صدور مجوز و/یا فروش نسخه‌هایی از نرم‌افزار، مشروط به شرایط زیر:
158
+
159
+ 1. اخطار حق چاپ بالا و این اجازه‌نامه باید در تمام نسخه‌ها یا بخش‌های اساسی نرم‌افزار درج شود.
160
+
161
+ 2. استفاده تجاری از نرم‌افزار یا هر اثر مشتقی از آن بدون اجازه کتبی قبلی از صاحب حق چاپ ممنوع است. استفاده تجاری شامل موارد زیر می‌شود: فروش، استفاده به عنوان بخشی از یک محصول یا خدمات تجاری، ایجاد درآمد، یا ارائه به عنوان خدمات پولی.
162
+
163
+ 3. استفاده غیرتجاری، از جمله اهداف شخصی، آموزشی، تحقیقاتی و متن‌باز، بدون محدودیت مجاز است.
164
+
165
+ 4. هرگونه استفاده تجاری نیاز به اجازه‌نامه کتبی صریح از:
166
+ حمید پژند <HamidPajand@gmail.com>
167
+ دارد.
168
+
169
+ نرم‌افزار «همان‌طور که هست» ارائه می‌شود، بدون هیچ گونه ضمانتی، صریح یا ضمنی، از جمله اما نه محدود به ضمانت‌های قابلیت بازاریابی، تناسب برای یک هدف خاص و عدم نقض. در هیچ موردی نویسندگان یا صاحبان حق چاپ در قبال هیچ ادعا، خسارت یا مسئولیت دیگری، خواه در اقدام قراردادی، شبه‌جرم یا غیره، ناشی از یا در ارتباط با نرم‌افزار یا استفاده یا سایر معاملات در نرم‌افزار مسئول نیستند.
170
+
171
+ ---
172
+
173
+ AUTHOR / نویسنده:
174
+
175
+ Hamid Pajand / حمید پژند
176
+ Email / ایمیل: HamidPajand@gmail.com
177
+ GitHub: https://github.com/Pajand
178
+ Repository / ریپازیتوری: https://github.com/Pajand/opencoop
package/README.fa.md ADDED
@@ -0,0 +1,221 @@
1
+ <div align="center">
2
+
3
+ [![English](https://img.shields.io/badge/🌐-English-green?style=flat-square)](README.md)
4
+
5
+ # اوپن‌کوپ
6
+
7
+ ![OpenCOOP](https://img.shields.io/badge/OpenCOOP-v1.0.0-blue)
8
+ ![License](https://img.shields.io/badge/License-Non--Commercial-blue)
9
+ ![OpenCode](https://img.shields.io/badge/OpenCode-Plugin-purple)
10
+ ![MCP](https://img.shields.io/badge/MCP-Streamable%20HTTP-orange)
11
+ ![Node](https://img.shields.io/badge/Node.js-18+-black)
12
+
13
+ **پلاگین اوپن‌کد برای همکاری تیمی بلادرنگ از طریق سرور MCP مشترک**
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## اوپن‌کوپ چیست؟
20
+
21
+ اوپن‌کوپ یک **پلاگین اوپن‌کد** است که به چندین توسعه‌دهنده اجازه می‌دهد به طور همزمان روی یک پروژه مشترک کار کنند. هر توسعه‌دهنده اوپن‌کد خود را با هوش مصنوعی خود اجرا می‌کند، اما همه به **سرور MCP مشترک** متصل می‌شوند — به طوری که هوش مصنوعی هر شخص دسترسی مستقیم خواندن/نوشتن به پوشه پروژه مشترک دارد.
22
+
23
+ ```
24
+ توسعه‌دهنده A (از راه دور) توسعه‌دهنده B (از راه دور)
25
+ │ │
26
+ ▼ ▼
27
+ اوپن‌کد + هوش مصنوعی اوپن‌کد + هوش مصنوعی
28
+ │ │
29
+ └──────────────┬───────────────┘
30
+
31
+
32
+ ┌────────────────────────┐
33
+ │ سرور اوپن‌کوپ MCP │
34
+ │ (پورت 31313) │
35
+ └────────────┬───────────┘
36
+
37
+
38
+ ┌────────────────────────┐
39
+ │ پوشه پروژه مشترک │
40
+ └────────────────────────┘
41
+ ```
42
+
43
+ ## ویژگی‌های کلیدی
44
+
45
+ | ویژگی | توضیحات |
46
+ |-------|---------|
47
+ | 🔗 **سرور MCP مشترک** | چندین نمونه اوپن‌کد یک پروژه را به اشتراک می‌گذارند |
48
+ | 👥 **همکاری بلادرنگ** | ببینید چه کسی چه چیزی را ویرایش می‌کند |
49
+ | 📝 **ردیابی تغییرات** | هر تغییر فایل با نسبت کاربر ثبت می‌شود |
50
+ | 🔒 **قفل فایل** | از تداخل جلوگیری می‌کند |
51
+ | 🌐 **داشبورد وب** | رابط کاربری زیبا برای پیکربندی و نظارت |
52
+ | 🔑 **سیستم دعوت** | دعوت امن اعضا با توکن |
53
+ | 🛡️ **امنیت سندباکس** | محافظت در برابر عبور مسیر و اعتبارسنجی ورودی |
54
+ | 📊 **آمار** | مشاهده تغییرات به ازای هر کاربر و فعالیت اخیر |
55
+
56
+ ## نصب
57
+
58
+ ### روش ۱: نصب از npm (توصیه شده)
59
+
60
+ ```bash
61
+ npm install -g @opencoop/opencode-plugin
62
+ ```
63
+
64
+ سپس در فایل `~/.config/opencode/opencode.json` اضافه کنید:
65
+
66
+ ```json
67
+ {
68
+ "plugin": ["@opencoop/opencode-plugin"],
69
+ "mcp": {
70
+ "opencoop": {
71
+ "type": "remote",
72
+ "url": "http://localhost:31313/mcp",
73
+ "enabled": true
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### روش ۲: نصب از GitHub
80
+
81
+ ```bash
82
+ git clone https://github.com/Pajand/opencoop.git
83
+ cd opencoop
84
+ npm install
85
+ npm run build
86
+ npm link
87
+ ```
88
+
89
+ سپس در `~/.config/opencode/opencode.json`:
90
+
91
+ ```json
92
+ {
93
+ "plugin": ["opencoop"],
94
+ "mcp": {
95
+ "opencoop": {
96
+ "type": "remote",
97
+ "url": "http://localhost:31313/mcp",
98
+ "enabled": true
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## شروع سریع
105
+
106
+ 1. **پلاگین را نصب کنید** (بالا)
107
+ 2. **اوپن‌کد را مجدداً راه‌اندازی کنید**
108
+ 3. **مرورگر را باز کنید**: `http://localhost:31313`
109
+ 4. **حالت HOST یا REMOTE را انتخاب کنید**
110
+ 5. **پروژه را پیکربندی کنید**
111
+
112
+ ## حالت‌های استفاده
113
+
114
+ ### حالت HOST (مالک پروژه)
115
+
116
+ 1. حالت **HOST** را در رابط وب انتخاب کنید
117
+ 2. **پوشه پروژه** را انتخاب کنید
118
+ 3. روی **ایجاد لینک دعوت** کلیک کنید
119
+ 4. **لینک را با اعضای تیم به اشتراک بگذارید**
120
+
121
+ ### حالت REMOTE (عضو تیم)
122
+
123
+ 1. **پلاگین را روی ماشین خود نصب کنید**
124
+ 2. به `opencode.json` اضافه کنید
125
+ 3. **اوپن‌کد را مجدداً راه‌اندازی کنید**
126
+ 4. `http://localhost:31313` را باز کنید
127
+ 5. حالت **REMOTE** را انتخاب کنید
128
+ 6. **لینک میزبان را Paste کنید**
129
+ 7. روی **اتصال** کلیک کنید
130
+
131
+ ## ابزارهای MCP
132
+
133
+ پس از اتصال، هوش مصنوعی شما به این ابزارها دسترسی دارد:
134
+
135
+ | ابزار | توضیحات |
136
+ |-------|---------|
137
+ | `read_file` | خواندن محتوای فایل از پروژه مشترک |
138
+ | `write_file` | ایجاد یا بازنویسی فایل‌ها |
139
+ | `edit_file` | ویرایش هدفمند با جستجو و جایگزینی |
140
+ | `list_files` | فهرست کردن محتوای پوشه |
141
+ | `search_files` | جستجوی فایل‌ها با الگوی glob |
142
+ | `grep_content` | جستجوی محتوای فایل با regex |
143
+ | `directory_tree` | دریافت نمای ساختار پوشه |
144
+ | `lock_file` | دریافت قفل انحصاری قبل از ویرایش |
145
+ | `unlock_file` | آزاد کردن قفل پس از ویرایش |
146
+ | `view_changes` | مشاهده تغییرات اخیر اعضای تیم |
147
+ | `view_stats` | مشاهده آمار پروژه |
148
+ | `who_is_online` | مشاهده کاربران آنلاین |
149
+ | `invite_member` | ایجاد لینک دعوت برای اعضای جدید |
150
+ | `list_members` | فهرست تمام اعضای تیم |
151
+ | `revoke_access` | لغو دسترسی یک عضو |
152
+
153
+ ## راهنمای عامل هوش مصنوعی
154
+
155
+ **اگر شما یک عامل هوش مصنوعی هستید که این متن را می‌خوانید، مراحل زیر را دقیقاً دنبال کنید:**
156
+
157
+ ### مرحله ۱: نصب
158
+
159
+ ```bash
160
+ # بررسی نصب بودن اوپن‌کد
161
+ which opencode || echo "OpenCode نصب نیست - کاربر باید ابتدا آن را نصب کند"
162
+
163
+ # نصب اوپن‌کوپ به صورت سراسری
164
+ npm install -g @opencoop/opencode-plugin
165
+ ```
166
+
167
+ ### مرحله ۲: پیکربندی
168
+
169
+ ```bash
170
+ # خواندن پیکربندی فعلی اوپن‌کد
171
+ cat ~/.config/opencode/opencode.json 2>/dev/null || echo "{}"
172
+ ```
173
+
174
+ پلاگین را به `opencode.json` اضافه کنید:
175
+
176
+ ```json
177
+ {
178
+ "plugin": ["@opencoop/opencode-plugin"],
179
+ "mcp": {
180
+ "opencoop": {
181
+ "type": "remote",
182
+ "url": "http://localhost:31313/mcp",
183
+ "enabled": true
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### مرحله ۳: تأیید نصب
190
+
191
+ ```bash
192
+ # بررسی نصب صحیح پلاگین
193
+ npm list -g @opencoop/opencode-plugin
194
+ ```
195
+
196
+ ### مرحله ۴: دسترسی به رابط وب
197
+
198
+ ```
199
+ آدرس: http://localhost:31313
200
+ ```
201
+
202
+ - **حالت HOST**: پوشه را انتخاب کنید، لینک دعوت ایجاد کنید
203
+ - **حالت REMOTE**: لینک میزبان را Paste کنید
204
+
205
+ ### نکات مهم برای عوامل هوش مصنوعی
206
+
207
+ 1. **ویرایش نکنید** پیکربندی سرور MCP را به صورت دستی
208
+ 2. **اجرا نکنید** سرور را به عنوان فرآیند جداگانه
209
+ 3. پلاگین **خودکار شروع می‌شود** هنگام شروع اوپن‌کد
210
+ 4. تمام پیکربندی از طریق **رابط وب** انجام می‌شود
211
+ 5. سرور روی **پورت 31313** اجرا می‌شود
212
+
213
+ ## مجوز
214
+
215
+ لایسنس غیرتجاری اوپن‌کوپ - استفاده رایگان غیرتجاری، استفاده تجاری نیاز به اجازه دارد.
216
+
217
+ جزئیات در فایل [LICENSE](LICENSE)
218
+
219
+ ## نویسنده
220
+
221
+ **حمید پژند** - [GitHub](https://github.com/Pajand) - [ایمیل](mailto:HamidPajand@gmail.com)
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ <div align="center">
2
+
3
+ [![فارسی](https://img.shields.io/badge/🌐-فارسی-blue?style=flat-square)](README.fa.md)
4
+
5
+ # OpenCOOP
6
+
7
+ ![OpenCOOP](https://img.shields.io/badge/OpenCOOP-v1.0.0-blue)
8
+ ![License](https://img.shields.io/badge/License-Non--Commercial-blue)
9
+ ![OpenCode](https://img.shields.io/badge/OpenCode-Plugin-purple)
10
+ ![MCP](https://img.shields.io/badge/MCP-Streamable%20HTTP-orange)
11
+ ![Node](https://img.shields.io/badge/Node.js-18+-black)
12
+
13
+ **OpenCode plugin for real-time team collaboration via shared MCP server**
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## What is OpenCOOP?
20
+
21
+ OpenCOOP is an **OpenCode plugin** that enables multiple developers to collaborate on the same project simultaneously. Each developer runs their own OpenCode with their own AI, but they all connect to the **same MCP server** — giving every person's AI direct read/write access to a shared project folder.
22
+
23
+ ```
24
+ Developer A (Remote) Developer B (Remote)
25
+ │ │
26
+ ▼ ▼
27
+ OpenCode + AI OpenCode + AI
28
+ │ │
29
+ └──────────────┬───────────────┘
30
+
31
+
32
+ ┌────────────────────────┐
33
+ │ OpenCOOP MCP Server │
34
+ │ (Port 31313) │
35
+ └────────────┬───────────┘
36
+
37
+
38
+ ┌────────────────────────┐
39
+ │ Shared Project Folder │
40
+ └────────────────────────┘
41
+ ```
42
+
43
+ ## Key Features
44
+
45
+ | Feature | Description |
46
+ |---------|-------------|
47
+ | 🔗 **Shared MCP Server** | Multiple OpenCode instances share the same project |
48
+ | 👥 **Real-time Collaboration** | See who is editing what in real-time |
49
+ | 📝 **Change Tracking** | Every file modification is logged with user attribution |
50
+ | 🔒 **File Locking** | Prevents conflicts when multiple users edit the same file |
51
+ | 🌐 **Web Dashboard** | Beautiful UI for configuration and monitoring |
52
+ | 🔑 **Invite System** | Secure token-based team member invitations |
53
+ | 🛡️ **Sandbox Security** | Path traversal protection and input validation |
54
+ | 📊 **Statistics** | View changes per user, recent activity, and more |
55
+
56
+ ## Installation
57
+
58
+ ### Option 1: Install via npm (Recommended)
59
+
60
+ ```bash
61
+ npm install -g @opencoop/opencode-plugin
62
+ ```
63
+
64
+ Then add to your `~/.config/opencode/opencode.json`:
65
+
66
+ ```json
67
+ {
68
+ "plugin": ["@opencoop/opencode-plugin"],
69
+ "mcp": {
70
+ "opencoop": {
71
+ "type": "remote",
72
+ "url": "http://localhost:31313/mcp",
73
+ "enabled": true
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### Option 2: Install from GitHub
80
+
81
+ ```bash
82
+ git clone https://github.com/Pajand/opencoop.git
83
+ cd opencoop
84
+ npm install
85
+ npm run build
86
+ npm link
87
+ ```
88
+
89
+ Then add to your `~/.config/opencode/opencode.json`:
90
+
91
+ ```json
92
+ {
93
+ "plugin": ["opencoop"],
94
+ "mcp": {
95
+ "opencoop": {
96
+ "type": "remote",
97
+ "url": "http://localhost:31313/mcp",
98
+ "enabled": true
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Quick Start
105
+
106
+ 1. **Install** the plugin (see above)
107
+ 2. **Restart** OpenCode
108
+ 3. **Open** `http://localhost:31313` in your browser
109
+ 4. **Select** HOST or REMOTE mode
110
+ 5. **Configure** your project
111
+
112
+ ## Usage Modes
113
+
114
+ ### HOST Mode (Project Owner)
115
+
116
+ 1. Select **HOST** mode in the web UI
117
+ 2. Choose your **project folder**
118
+ 3. Click **Generate Invite Link**
119
+ 4. **Share** the link with team members
120
+
121
+ ### REMOTE Mode (Team Member)
122
+
123
+ 1. **Install** the plugin on your machine
124
+ 2. Add to your `opencode.json`
125
+ 3. **Restart** OpenCode
126
+ 4. Open `http://localhost:31313`
127
+ 5. Select **REMOTE** mode
128
+ 6. **Paste** the host's invite link
129
+ 7. Click **Connect**
130
+
131
+ ## MCP Tools
132
+
133
+ Once connected, your AI has access to these tools:
134
+
135
+ | Tool | Description |
136
+ |------|-------------|
137
+ | `read_file` | Read file contents from the shared project |
138
+ | `write_file` | Create or overwrite files |
139
+ | `edit_file` | Make targeted edits using search & replace |
140
+ | `list_files` | List directory contents |
141
+ | `search_files` | Search files by glob pattern |
142
+ | `grep_content` | Search file contents with regex |
143
+ | `directory_tree` | Get folder structure overview |
144
+ | `lock_file` | Acquire exclusive lock before editing |
145
+ | `unlock_file` | Release lock after editing |
146
+ | `view_changes` | View recent changes by team members |
147
+ | `view_stats` | View project statistics |
148
+ | `who_is_online` | See who is currently connected |
149
+ | `invite_member` | Generate invite link for new members |
150
+ | `list_members` | List all team members |
151
+ | `revoke_access` | Revoke a member's access |
152
+
153
+ ## AI Agent Instructions
154
+
155
+ **If you are an AI agent reading this, follow these exact steps to install and configure OpenCOOP:**
156
+
157
+ ### Step 1: Install
158
+
159
+ ```bash
160
+ # Check if OpenCode is installed
161
+ which opencode || echo "OpenCode not found - user needs to install it first"
162
+
163
+ # Install OpenCOOP globally
164
+ npm install -g @opencoop/opencode-plugin
165
+ ```
166
+
167
+ ### Step 2: Configure
168
+
169
+ ```bash
170
+ # Read current opencode config
171
+ cat ~/.config/opencode/opencode.json 2>/dev/null || echo "{}"
172
+ ```
173
+
174
+ Add the plugin to `opencode.json`:
175
+
176
+ ```json
177
+ {
178
+ "plugin": ["@opencoop/opencode-plugin"],
179
+ "mcp": {
180
+ "opencoop": {
181
+ "type": "remote",
182
+ "url": "http://localhost:31313/mcp",
183
+ "enabled": true
184
+ }
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### Step 3: Verify Installation
190
+
191
+ ```bash
192
+ # Check if plugin is installed correctly
193
+ npm list -g @opencoop/opencode-plugin
194
+ ```
195
+
196
+ ### Step 4: Access Web UI
197
+
198
+ ```
199
+ URL: http://localhost:31313
200
+ ```
201
+
202
+ - **HOST mode**: Select folder, generate invite link
203
+ - **REMOTE mode**: Paste host's invite link
204
+
205
+ ### Important Notes for AI Agents
206
+
207
+ 1. **Do NOT** manually edit MCP server configuration
208
+ 2. **Do NOT** run the server as a separate process
209
+ 3. The plugin **auto-starts** when OpenCode starts
210
+ 4. All configuration is done through the **web UI**
211
+ 5. The server runs on **port 31313** by default
212
+
213
+ ## Architecture
214
+
215
+ ```
216
+ ┌─────────────────────────────────────────────────────────┐
217
+ │ OpenCode Instances │
218
+ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
219
+ │ │ Member A │ │ Member B │ │ Member C │ │
220
+ │ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
221
+ │ │ │ │ │
222
+ │ └──────────────┼──────────────┘ │
223
+ │ │ │
224
+ │ ▼ │
225
+ │ ┌─────────────────────────────────────────────────┐ │
226
+ │ │ OpenCOOP MCP Server │ │
227
+ │ │ (Port 31313) │ │
228
+ │ └─────────────────────────────────────────────────┘ │
229
+ │ │ │
230
+ │ ▼ │
231
+ │ ┌─────────────────────────────────────────────────┐ │
232
+ │ │ Shared Project Folder │ │
233
+ │ └─────────────────────────────────────────────────┘ │
234
+ └─────────────────────────────────────────────────────────┘
235
+ ```
236
+
237
+ ## License
238
+
239
+ OpenCOOP Non-Commercial License - Free for non-commercial use, commercial use requires permission.
240
+
241
+ See [LICENSE](LICENSE) file for details.
242
+
243
+ ## Author
244
+
245
+ **Hamid Pajand** - [GitHub](https://github.com/Pajand) - [Email](mailto:HamidPajand@gmail.com)
@@ -0,0 +1,45 @@
1
+ import { TeamMember } from "../types/index.js";
2
+ export declare class AuthManager {
3
+ private jwtSecret;
4
+ constructor(jwtSecret: string);
5
+ initialize(): Promise<void>;
6
+ validateToken(token: string): Promise<{
7
+ valid: boolean;
8
+ userId?: string;
9
+ workspaceId?: string;
10
+ permissions?: string[];
11
+ }>;
12
+ generateInviteLink(params: {
13
+ workspaceId: string;
14
+ email: string;
15
+ permissions: string[];
16
+ expiresInDays: number;
17
+ createdBy: string;
18
+ }): Promise<{
19
+ link: string;
20
+ token: string;
21
+ expiresAt: Date;
22
+ }>;
23
+ validateInviteLink(token: string): Promise<{
24
+ valid: boolean;
25
+ workspaceId?: string;
26
+ permissions?: string[];
27
+ reason?: string;
28
+ }>;
29
+ acceptInvite(token: string, userId: string): Promise<void>;
30
+ getTeamMembers(workspaceId: string): Promise<TeamMember[]>;
31
+ revokeAccess(workspaceId: string, userId: string, ownerId: string): Promise<void>;
32
+ createWorkspace(params: {
33
+ name: string;
34
+ path: string;
35
+ ownerId: string;
36
+ mode: "host" | "remote";
37
+ hostUrl?: string;
38
+ }): Promise<string>;
39
+ getWorkspace(workspaceId: string): Promise<any>;
40
+ updateWorkspace(workspaceId: string, updates: {
41
+ mode?: string;
42
+ hostUrl?: string;
43
+ workspacePath?: string;
44
+ }): Promise<void>;
45
+ }