session-collab-mcp 0.4.7 → 0.5.2
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 +254 -0
- package/migrations/0004_symbols.sql +18 -0
- package/migrations/0005_references.sql +19 -0
- package/migrations/0006_composite_indexes.sql +14 -0
- package/package.json +10 -1
- package/src/cli.ts +3 -0
- package/src/constants.ts +154 -19
- package/src/db/__tests__/queries.test.ts +799 -0
- package/src/db/__tests__/test-helper.ts +216 -0
- package/src/db/queries.ts +376 -43
- package/src/db/sqlite-adapter.ts +6 -6
- package/src/db/types.ts +60 -0
- package/src/mcp/schemas.ts +200 -0
- package/src/mcp/server.ts +16 -1
- package/src/mcp/tools/claim.ts +231 -83
- package/src/mcp/tools/decision.ts +26 -13
- package/src/mcp/tools/lsp.ts +686 -0
- package/src/mcp/tools/message.ts +28 -14
- package/src/mcp/tools/session.ts +82 -42
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
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
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Session Collab MCP
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/session-collab-mcp)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A Model Context Protocol (MCP) server for Claude Code that prevents conflicts when multiple sessions work on the same codebase simultaneously.
|
|
7
|
+
|
|
8
|
+
## Problem
|
|
9
|
+
|
|
10
|
+
When using parallel Claude Code sessions or the parallel-dev workflow:
|
|
11
|
+
|
|
12
|
+
- Session A is refactoring some code
|
|
13
|
+
- Session B doesn't know and thinks the code "has issues" - deletes or reverts it
|
|
14
|
+
- Session A's work disappears
|
|
15
|
+
|
|
16
|
+
**Root cause**: No synchronization mechanism for "work intent" between sessions.
|
|
17
|
+
|
|
18
|
+
## Solution
|
|
19
|
+
|
|
20
|
+
Session Collab MCP provides a **Work-in-Progress (WIP) Registry** that allows sessions to:
|
|
21
|
+
|
|
22
|
+
1. **Declare** - Announce which files you're about to modify
|
|
23
|
+
2. **Check** - Verify no other session is working on the same files
|
|
24
|
+
3. **Communicate** - Send messages between sessions
|
|
25
|
+
4. **Release** - Free files when done
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
### Zero-Config Setup
|
|
30
|
+
|
|
31
|
+
Add to your `~/.claude.json`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"mcpServers": {
|
|
36
|
+
"session-collab": {
|
|
37
|
+
"command": "npx",
|
|
38
|
+
"args": ["-y", "session-collab-mcp@latest"]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
That's it! The MCP server includes built-in instructions that Claude follows automatically.
|
|
45
|
+
|
|
46
|
+
### Manual Installation
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install -g session-collab-mcp
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
### Automatic Session Management
|
|
55
|
+
|
|
56
|
+
Once installed, Claude will:
|
|
57
|
+
|
|
58
|
+
1. Register a session when conversation starts
|
|
59
|
+
2. Check for conflicts before editing files
|
|
60
|
+
3. Warn you if another session is working on the same files
|
|
61
|
+
4. Clean up when the conversation ends
|
|
62
|
+
|
|
63
|
+
### Symbol-Level Claims
|
|
64
|
+
|
|
65
|
+
Fine-grained conflict detection at the function/class level:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
Session A claims: validateToken() in auth.ts
|
|
69
|
+
Session B wants: refreshToken() in auth.ts
|
|
70
|
+
Result: No conflict! Different symbols in same file.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### LSP Integration
|
|
74
|
+
|
|
75
|
+
Works with Claude Code's LSP tools for:
|
|
76
|
+
|
|
77
|
+
- Accurate symbol validation (no typos in claims)
|
|
78
|
+
- Impact analysis (know which files reference your changes)
|
|
79
|
+
- Smart prioritization (focus on low-impact changes first)
|
|
80
|
+
|
|
81
|
+
### Conflict Handling Modes
|
|
82
|
+
|
|
83
|
+
Configure behavior with `collab_config`:
|
|
84
|
+
|
|
85
|
+
| Mode | Behavior |
|
|
86
|
+
|------|----------|
|
|
87
|
+
| `strict` | Always ask user, never bypass |
|
|
88
|
+
| `smart` (default) | Auto-proceed with safe content, ask for blocked |
|
|
89
|
+
| `bypass` | Proceed despite conflicts (warn only) |
|
|
90
|
+
|
|
91
|
+
## MCP Tools Reference
|
|
92
|
+
|
|
93
|
+
### Session Management
|
|
94
|
+
|
|
95
|
+
| Tool | Purpose |
|
|
96
|
+
|------|---------|
|
|
97
|
+
| `collab_session_start` | Register a new session |
|
|
98
|
+
| `collab_session_end` | End session and release all claims |
|
|
99
|
+
| `collab_session_list` | List active sessions |
|
|
100
|
+
| `collab_session_heartbeat` | Update session heartbeat |
|
|
101
|
+
| `collab_status_update` | Share current work status |
|
|
102
|
+
| `collab_config` | Configure conflict handling mode |
|
|
103
|
+
|
|
104
|
+
### Claims (File/Symbol Locking)
|
|
105
|
+
|
|
106
|
+
| Tool | Purpose |
|
|
107
|
+
|------|---------|
|
|
108
|
+
| `collab_claim` | Reserve files or symbols before modifying |
|
|
109
|
+
| `collab_check` | Check if files/symbols are claimed by others |
|
|
110
|
+
| `collab_release` | Release claimed files/symbols |
|
|
111
|
+
| `collab_claims_list` | List all WIP claims |
|
|
112
|
+
|
|
113
|
+
### Inter-Session Communication
|
|
114
|
+
|
|
115
|
+
| Tool | Purpose |
|
|
116
|
+
|------|---------|
|
|
117
|
+
| `collab_message_send` | Send message to other sessions |
|
|
118
|
+
| `collab_message_list` | Read messages |
|
|
119
|
+
|
|
120
|
+
### Architectural Decisions
|
|
121
|
+
|
|
122
|
+
| Tool | Purpose |
|
|
123
|
+
|------|---------|
|
|
124
|
+
| `collab_decision_add` | Record design decisions |
|
|
125
|
+
| `collab_decision_list` | View recorded decisions |
|
|
126
|
+
|
|
127
|
+
### LSP Integration (Advanced)
|
|
128
|
+
|
|
129
|
+
| Tool | Purpose |
|
|
130
|
+
|------|---------|
|
|
131
|
+
| `collab_analyze_symbols` | Analyze LSP symbols for conflict detection |
|
|
132
|
+
| `collab_validate_symbols` | Validate symbol names before claiming |
|
|
133
|
+
| `collab_store_references` | Store LSP reference data for impact tracking |
|
|
134
|
+
| `collab_impact_analysis` | Analyze impact of modifying a symbol |
|
|
135
|
+
|
|
136
|
+
## Usage Examples
|
|
137
|
+
|
|
138
|
+
### Basic Workflow
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
# Session A starts working
|
|
142
|
+
collab_session_start(project_root="/my/project", name="feature-auth")
|
|
143
|
+
collab_claim(files=["src/auth.ts"], intent="Adding JWT support")
|
|
144
|
+
|
|
145
|
+
# Session B checks before editing
|
|
146
|
+
collab_check(files=["src/auth.ts"])
|
|
147
|
+
# Result: "src/auth.ts is being worked on by 'feature-auth' - Adding JWT support"
|
|
148
|
+
|
|
149
|
+
# Session A finishes
|
|
150
|
+
collab_release(claim_id="...", status="completed", summary="Added JWT validation")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Symbol-Level Claims
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
# Claim specific functions only
|
|
157
|
+
collab_claim(
|
|
158
|
+
symbols=[{file: "src/auth.ts", symbols: ["validateToken", "refreshToken"]}],
|
|
159
|
+
intent="Refactoring token validation"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Other sessions can still work on other functions in the same file
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Impact Analysis
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
# Before modifying a widely-used function
|
|
169
|
+
collab_impact_analysis(file="src/utils.ts", symbol="formatDate")
|
|
170
|
+
# Result: {
|
|
171
|
+
# risk_level: "high",
|
|
172
|
+
# reference_count: 15,
|
|
173
|
+
# affected_files: ["src/api/...", "src/components/..."],
|
|
174
|
+
# message: "HIGH RISK: This symbol is referenced in 15 locations"
|
|
175
|
+
# }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Data Storage
|
|
179
|
+
|
|
180
|
+
All data is stored locally in `~/.claude/session-collab/collab.db` (SQLite).
|
|
181
|
+
|
|
182
|
+
- No remote server required
|
|
183
|
+
- No API token needed
|
|
184
|
+
- Works offline
|
|
185
|
+
- Uses WAL mode for multi-process safety
|
|
186
|
+
|
|
187
|
+
## Development
|
|
188
|
+
|
|
189
|
+
### Prerequisites
|
|
190
|
+
|
|
191
|
+
- Node.js 18+
|
|
192
|
+
- npm or yarn
|
|
193
|
+
|
|
194
|
+
### Setup
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm install
|
|
198
|
+
npm run build
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Scripts
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
npm run build # Build with tsup
|
|
205
|
+
npm run start # Start the MCP server
|
|
206
|
+
npm run start:dev # Start in development mode
|
|
207
|
+
npm run typecheck # Run TypeScript type checking
|
|
208
|
+
npm run lint # Run ESLint
|
|
209
|
+
npm run test # Run tests with Vitest
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Project Structure
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
session-collab-mcp/
|
|
216
|
+
├── bin/ # Executable entry point
|
|
217
|
+
├── migrations/ # SQLite migration files
|
|
218
|
+
│ ├── 0001_init.sql # Core tables
|
|
219
|
+
│ ├── 0002_auth.sql # Auth tables
|
|
220
|
+
│ ├── 0002_session_status.sql # Session status
|
|
221
|
+
│ ├── 0003_config.sql # Session config
|
|
222
|
+
│ ├── 0004_symbols.sql # Symbol-level claims
|
|
223
|
+
│ └── 0005_references.sql # Reference tracking
|
|
224
|
+
├── src/
|
|
225
|
+
│ ├── cli.ts # CLI entry point
|
|
226
|
+
│ ├── constants.ts # Version and constants
|
|
227
|
+
│ ├── db/ # Database layer
|
|
228
|
+
│ │ ├── queries.ts # SQL queries
|
|
229
|
+
│ │ └── sqlite-adapter.ts
|
|
230
|
+
│ ├── mcp/ # MCP protocol implementation
|
|
231
|
+
│ │ ├── protocol.ts # JSON-RPC handling
|
|
232
|
+
│ │ ├── server.ts # Main MCP server
|
|
233
|
+
│ │ └── tools/ # Tool implementations
|
|
234
|
+
│ │ ├── session.ts # Session management
|
|
235
|
+
│ │ ├── claim.ts # File/symbol claims
|
|
236
|
+
│ │ ├── message.ts # Inter-session messaging
|
|
237
|
+
│ │ ├── decision.ts# Decision logging
|
|
238
|
+
│ │ └── lsp.ts # LSP integration
|
|
239
|
+
│ └── utils/
|
|
240
|
+
└── package.json
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Changelog
|
|
244
|
+
|
|
245
|
+
### v0.5.0
|
|
246
|
+
|
|
247
|
+
- Add reference tracking and impact analysis (Phase 3)
|
|
248
|
+
- Add symbol-level claims and LSP integration
|
|
249
|
+
- Fix SQLite WAL sync for multi-process MCP servers
|
|
250
|
+
- Add `collab_config` tool for conflict handling modes
|
|
251
|
+
|
|
252
|
+
## License
|
|
253
|
+
|
|
254
|
+
MIT
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
-- Symbol-level claim tracking for fine-grained conflict detection
|
|
2
|
+
-- Allows claiming specific functions/classes instead of entire files
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS claim_symbols (
|
|
5
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6
|
+
claim_id TEXT NOT NULL,
|
|
7
|
+
file_path TEXT NOT NULL,
|
|
8
|
+
symbol_name TEXT NOT NULL,
|
|
9
|
+
symbol_type TEXT DEFAULT 'function' CHECK (symbol_type IN ('function', 'class', 'method', 'variable', 'block', 'other')),
|
|
10
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
11
|
+
FOREIGN KEY (claim_id) REFERENCES claims(id) ON DELETE CASCADE,
|
|
12
|
+
UNIQUE(claim_id, file_path, symbol_name)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE INDEX IF NOT EXISTS idx_claim_symbols_path ON claim_symbols(file_path);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS idx_claim_symbols_name ON claim_symbols(symbol_name);
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_claim_symbols_claim ON claim_symbols(claim_id);
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_claim_symbols_lookup ON claim_symbols(file_path, symbol_name);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
-- Symbol reference tracking for impact analysis
|
|
2
|
+
-- Stores which symbols are referenced by which files
|
|
3
|
+
|
|
4
|
+
CREATE TABLE IF NOT EXISTS symbol_references (
|
|
5
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
6
|
+
source_file TEXT NOT NULL,
|
|
7
|
+
source_symbol TEXT NOT NULL,
|
|
8
|
+
ref_file TEXT NOT NULL,
|
|
9
|
+
ref_line INTEGER,
|
|
10
|
+
ref_context TEXT,
|
|
11
|
+
session_id TEXT NOT NULL,
|
|
12
|
+
created_at TEXT DEFAULT (datetime('now')),
|
|
13
|
+
FOREIGN KEY (session_id) REFERENCES sessions(id) ON DELETE CASCADE,
|
|
14
|
+
UNIQUE(source_file, source_symbol, ref_file, ref_line)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX IF NOT EXISTS idx_symbol_refs_source ON symbol_references(source_file, source_symbol);
|
|
18
|
+
CREATE INDEX IF NOT EXISTS idx_symbol_refs_ref_file ON symbol_references(ref_file);
|
|
19
|
+
CREATE INDEX IF NOT EXISTS idx_symbol_refs_session ON symbol_references(session_id);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Add composite indexes for common query patterns
|
|
2
|
+
-- These indexes optimize queries that filter on multiple columns
|
|
3
|
+
|
|
4
|
+
-- Sessions: frequently query active sessions with heartbeat check
|
|
5
|
+
-- Used in cleanupStaleSessions and session list queries
|
|
6
|
+
CREATE INDEX IF NOT EXISTS idx_sessions_status_heartbeat ON sessions(status, last_heartbeat);
|
|
7
|
+
|
|
8
|
+
-- Claims: frequently query active claims for a session
|
|
9
|
+
-- Used in checkConflicts and listClaims
|
|
10
|
+
CREATE INDEX IF NOT EXISTS idx_claims_status_session ON claims(status, session_id);
|
|
11
|
+
|
|
12
|
+
-- Claim files: composite for efficient conflict checking
|
|
13
|
+
-- Used in checkConflicts with JOIN on claims
|
|
14
|
+
CREATE INDEX IF NOT EXISTS idx_claim_files_path_claim ON claim_files(file_path, claim_id);
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "session-collab-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "MCP server for Claude Code session collaboration - prevents conflicts between parallel sessions",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mcp",
|
|
8
|
+
"claude",
|
|
9
|
+
"claude-code",
|
|
10
|
+
"collaboration",
|
|
11
|
+
"session",
|
|
12
|
+
"conflict-prevention"
|
|
13
|
+
],
|
|
5
14
|
"type": "module",
|
|
6
15
|
"bin": {
|
|
7
16
|
"session-collab-mcp": "./bin/session-collab-mcp"
|
package/src/cli.ts
CHANGED
|
@@ -19,6 +19,9 @@ function loadMigrations(): string[] {
|
|
|
19
19
|
readFileSync(join(migrationsDir, '0001_init.sql'), 'utf-8'),
|
|
20
20
|
readFileSync(join(migrationsDir, '0002_auth.sql'), 'utf-8'),
|
|
21
21
|
readFileSync(join(migrationsDir, '0003_config.sql'), 'utf-8'),
|
|
22
|
+
readFileSync(join(migrationsDir, '0004_symbols.sql'), 'utf-8'),
|
|
23
|
+
readFileSync(join(migrationsDir, '0005_references.sql'), 'utf-8'),
|
|
24
|
+
readFileSync(join(migrationsDir, '0006_composite_indexes.sql'), 'utf-8'),
|
|
22
25
|
];
|
|
23
26
|
}
|
|
24
27
|
|
package/src/constants.ts
CHANGED
|
@@ -32,44 +32,179 @@ This MCP server coordinates multiple Claude Code sessions working on the same co
|
|
|
32
32
|
|
|
33
33
|
2. **Before editing any file**: Call \`collab_check\` with the file path to verify no conflicts
|
|
34
34
|
|
|
35
|
-
3. **
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
c) **Request release**: Ask owner to release if claim seems stale
|
|
40
|
-
- NEVER auto-release another session's claim without explicit user permission
|
|
35
|
+
3. **Follow the \`recommendation\` from collab_check automatically**:
|
|
36
|
+
- \`proceed_all\`: All files/symbols safe. Edit them without asking user.
|
|
37
|
+
- \`proceed_safe_only\`: Some content blocked. Edit ONLY safe files/symbols, skip blocked. No need to ask user.
|
|
38
|
+
- \`abort\`: All content blocked. Inform user and suggest coordination.
|
|
41
39
|
|
|
42
|
-
4. **For significant changes**: Call \`collab_claim\` before starting work
|
|
40
|
+
4. **For significant changes**: Call \`collab_claim\` before starting work
|
|
43
41
|
|
|
44
|
-
5. **When done
|
|
42
|
+
5. **When done**: Call \`collab_release\` with YOUR session_id to free them
|
|
45
43
|
|
|
46
44
|
6. **On conversation end**: Call \`collab_session_end\` to clean up
|
|
47
45
|
|
|
46
|
+
## Symbol-Level Claims (Fine-Grained)
|
|
47
|
+
|
|
48
|
+
Use symbol-level claims when modifying specific functions/classes, allowing other sessions to work on different parts of the same file.
|
|
49
|
+
|
|
50
|
+
**Claim specific symbols:**
|
|
51
|
+
\`\`\`json
|
|
52
|
+
{
|
|
53
|
+
"symbols": [
|
|
54
|
+
{ "file": "src/auth.ts", "symbols": ["validateToken", "refreshToken"] }
|
|
55
|
+
],
|
|
56
|
+
"intent": "Refactoring token validation"
|
|
57
|
+
}
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
**Check specific symbols:**
|
|
61
|
+
\`\`\`json
|
|
62
|
+
{
|
|
63
|
+
"files": ["src/auth.ts"],
|
|
64
|
+
"symbols": [
|
|
65
|
+
{ "file": "src/auth.ts", "symbols": ["validateToken"] }
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
\`\`\`
|
|
69
|
+
|
|
70
|
+
**Conflict levels:**
|
|
71
|
+
- \`file\`: Whole file is claimed (no symbols specified)
|
|
72
|
+
- \`symbol\`: Only specific functions/classes are claimed
|
|
73
|
+
|
|
74
|
+
**Example scenario:**
|
|
75
|
+
- Session A claims \`validateToken\` in auth.ts
|
|
76
|
+
- Session B wants to modify \`refreshToken\` in auth.ts
|
|
77
|
+
- → No conflict! Session B can proceed.
|
|
78
|
+
|
|
79
|
+
## Auto-Decision Rules
|
|
80
|
+
|
|
81
|
+
When \`collab_check\` returns:
|
|
82
|
+
- \`can_edit: true\` → Proceed with safe content automatically
|
|
83
|
+
- \`can_edit: false\` → Stop and inform user about blocked content
|
|
84
|
+
|
|
85
|
+
For symbol-level checks, use \`symbol_status.safe\` and \`symbol_status.blocked\`.
|
|
86
|
+
|
|
48
87
|
## Permission Rules
|
|
49
88
|
|
|
50
89
|
- You can ONLY release claims that belong to YOUR session
|
|
51
90
|
- To release another session's claim, you must ask the user and they must explicitly confirm
|
|
52
91
|
- Use \`force=true\` in \`collab_release\` only after user explicitly confirms
|
|
53
|
-
- When user chooses "coordinate", send a message first and suggest waiting
|
|
54
92
|
|
|
55
93
|
## Conflict Handling Modes
|
|
56
94
|
|
|
57
95
|
Configure your session behavior with \`collab_config\`:
|
|
58
96
|
|
|
59
97
|
- **"strict"**: Always ask user, never bypass or auto-release
|
|
60
|
-
- **"smart"** (default):
|
|
98
|
+
- **"smart"** (default): Auto-proceed with safe content, ask for blocked
|
|
61
99
|
- **"bypass"**: Proceed despite conflicts (just warn, don't block)
|
|
62
100
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
## LSP Integration (Advanced)
|
|
102
|
+
|
|
103
|
+
For precise symbol validation and impact analysis, use LSP tools:
|
|
104
|
+
|
|
105
|
+
### Workflow with LSP
|
|
106
|
+
|
|
107
|
+
1. **Get symbols from LSP**: Use \`LSP.documentSymbol\` to get actual symbols in a file
|
|
108
|
+
2. **Validate before claiming**: Use \`collab_validate_symbols\` to verify symbol names
|
|
109
|
+
3. **Analyze conflicts with context**: Use \`collab_analyze_symbols\` for enhanced conflict detection
|
|
110
|
+
|
|
111
|
+
### collab_validate_symbols
|
|
112
|
+
|
|
113
|
+
Validate symbol names exist before claiming:
|
|
114
|
+
|
|
115
|
+
\`\`\`
|
|
116
|
+
1. Claude: LSP.documentSymbol("src/auth.ts")
|
|
117
|
+
2. Claude: collab_validate_symbols({
|
|
118
|
+
file: "src/auth.ts",
|
|
119
|
+
symbols: ["validateToken", "refreshTokne"], // typo!
|
|
120
|
+
lsp_symbols: [/* LSP output */]
|
|
121
|
+
})
|
|
122
|
+
3. Response: { invalid_symbols: ["refreshTokne"], suggestions: { "refreshTokne": ["refreshToken"] } }
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
### collab_analyze_symbols
|
|
126
|
+
|
|
127
|
+
Enhanced conflict detection with LSP data:
|
|
128
|
+
|
|
129
|
+
\`\`\`
|
|
130
|
+
1. Claude: LSP.documentSymbol("src/auth.ts")
|
|
131
|
+
2. Claude: LSP.findReferences("validateToken")
|
|
132
|
+
3. Claude: collab_analyze_symbols({
|
|
133
|
+
session_id: "...",
|
|
134
|
+
files: [{ file: "src/auth.ts", symbols: [/* LSP symbols */] }],
|
|
135
|
+
references: [{ symbol: "validateToken", file: "src/auth.ts", references: [...] }]
|
|
136
|
+
})
|
|
137
|
+
4. Response: {
|
|
138
|
+
can_edit: true,
|
|
139
|
+
recommendation: "proceed_safe_only",
|
|
140
|
+
symbols: [
|
|
141
|
+
{ name: "validateToken", conflict_status: "blocked", impact: { references_count: 5, affected_files: [...] } },
|
|
142
|
+
{ name: "refreshToken", conflict_status: "safe" }
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
\`\`\`
|
|
146
|
+
|
|
147
|
+
### Benefits of LSP Integration
|
|
148
|
+
|
|
149
|
+
- **Accurate symbol names**: No typos in claims
|
|
150
|
+
- **Impact awareness**: Know which files will be affected by changes
|
|
151
|
+
- **Smart prioritization**: Focus on low-impact changes first
|
|
152
|
+
|
|
153
|
+
## Reference Tracking & Impact Analysis
|
|
154
|
+
|
|
155
|
+
Store and query symbol references for smart conflict detection:
|
|
156
|
+
|
|
157
|
+
### collab_store_references
|
|
158
|
+
|
|
159
|
+
Persist LSP reference data for future impact queries:
|
|
160
|
+
|
|
161
|
+
\`\`\`
|
|
162
|
+
1. Claude: LSP.findReferences("validateToken")
|
|
163
|
+
2. Claude: collab_store_references({
|
|
164
|
+
session_id: "...",
|
|
165
|
+
references: [{
|
|
166
|
+
source_file: "src/auth.ts",
|
|
167
|
+
source_symbol: "validateToken",
|
|
168
|
+
references: [
|
|
169
|
+
{ file: "src/api/users.ts", line: 15 },
|
|
170
|
+
{ file: "src/api/orders.ts", line: 23 }
|
|
171
|
+
]
|
|
172
|
+
}]
|
|
173
|
+
})
|
|
174
|
+
\`\`\`
|
|
175
|
+
|
|
176
|
+
### collab_impact_analysis
|
|
177
|
+
|
|
178
|
+
Check if modifying a symbol would affect files claimed by others:
|
|
179
|
+
|
|
180
|
+
\`\`\`
|
|
181
|
+
Claude: collab_impact_analysis({
|
|
182
|
+
session_id: "...",
|
|
183
|
+
file: "src/auth.ts",
|
|
184
|
+
symbol: "validateToken"
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
Response: {
|
|
188
|
+
risk_level: "high",
|
|
189
|
+
reference_count: 3,
|
|
190
|
+
affected_files: ["src/api/users.ts", "src/api/orders.ts"],
|
|
191
|
+
affected_claims: [{ session_name: "other-session", intent: "..." }],
|
|
192
|
+
message: "HIGH RISK: 1 active claim on referencing files"
|
|
193
|
+
}
|
|
194
|
+
\`\`\`
|
|
195
|
+
|
|
196
|
+
### Risk Levels
|
|
197
|
+
|
|
198
|
+
- **high**: Other sessions have claims on files that reference this symbol
|
|
199
|
+
- **medium**: Many references (>10) but no active claims conflict
|
|
200
|
+
- **low**: Few references, no conflicts
|
|
68
201
|
|
|
69
202
|
## Best Practices
|
|
70
203
|
|
|
71
|
-
-
|
|
72
|
-
- Use
|
|
73
|
-
-
|
|
74
|
-
-
|
|
204
|
+
- **Prefer symbol-level claims** for focused changes (single function/class)
|
|
205
|
+
- **Use file-level claims** for large refactors affecting many symbols
|
|
206
|
+
- **Use LSP validation** when unsure about symbol names
|
|
207
|
+
- **Check references** before modifying widely-used symbols
|
|
208
|
+
- Claim early, release when done
|
|
209
|
+
- Use descriptive intents (e.g., "Refactoring validateToken for JWT support")
|
|
75
210
|
`.trim();
|