s9n-devops-agent 1.7.4 → 2.0.1
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/README.md +126 -454
- package/README.v1.md +529 -0
- package/bin/cs-devops-agent +31 -13
- package/docs/FILE_COORDINATION_GUIDE.md +481 -0
- package/docs/MULTI_AGENT_WORKFLOWS.md +692 -0
- package/docs/V2_FINAL_SUMMARY.md +526 -0
- package/docs/V2_QUICK_REFERENCE.md +447 -0
- package/docs/V2_STATUS_REPORT.md +324 -0
- package/package.json +1 -1
- package/src/help-system.js +475 -0
- package/src/instruction-formatter.js +346 -0
- package/src/setup-cs-devops-agent.js +91 -55
- package/src/tutorial-mode.js +550 -0
- package/src/ui-utils.js +509 -0
- package/start-devops-session.sh +71 -31
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# File Coordination Guide
|
|
2
|
+
|
|
3
|
+
**DevOps Agent v2.0**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
File coordination prevents multiple AI agents from editing the same files simultaneously, avoiding conflicts and data loss.
|
|
10
|
+
|
|
11
|
+
### Quick Facts
|
|
12
|
+
|
|
13
|
+
- **Purpose:** Prevent concurrent file modifications
|
|
14
|
+
- **Mechanism:** JSON-based file locking
|
|
15
|
+
- **Scope:** Per-session file declarations
|
|
16
|
+
- **Release:** Automatic on session close
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## How It Works
|
|
21
|
+
|
|
22
|
+
### The Problem
|
|
23
|
+
|
|
24
|
+
Without coordination:
|
|
25
|
+
```
|
|
26
|
+
Agent 1: Edits src/auth.js
|
|
27
|
+
Agent 2: Edits src/auth.js (at the same time)
|
|
28
|
+
Result: Conflicting changes, merge headaches
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
###With Coordination:
|
|
32
|
+
```
|
|
33
|
+
Agent 1: Declares src/auth.js → Gets lock
|
|
34
|
+
Agent 2: Tries to declare src/auth.js → Blocked, gets warning
|
|
35
|
+
Result: Clean, sequential work
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## File Declaration Format
|
|
41
|
+
|
|
42
|
+
### Location
|
|
43
|
+
|
|
44
|
+
Each agent creates a declaration file:
|
|
45
|
+
```
|
|
46
|
+
.file-coordination/active-edits/<agent>-<session-id>.json
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Structure
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"agent": "claude",
|
|
54
|
+
"session": "abc1-23d4",
|
|
55
|
+
"files": [
|
|
56
|
+
"src/auth/login.js",
|
|
57
|
+
"src/auth/token.js",
|
|
58
|
+
"src/utils/validation.js"
|
|
59
|
+
],
|
|
60
|
+
"operation": "edit",
|
|
61
|
+
"reason": "implement-authentication",
|
|
62
|
+
"declaredAt": "2025-10-31T12:00:00.000Z"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Fields Explained
|
|
67
|
+
|
|
68
|
+
| Field | Purpose | Example |
|
|
69
|
+
|-------|---------|---------|
|
|
70
|
+
| `agent` | AI agent type | `claude`, `cursor`, `copilot` |
|
|
71
|
+
| `session` | Session identifier | `abc1-23d4` |
|
|
72
|
+
| `files` | Array of file paths | `["src/auth.js"]` |
|
|
73
|
+
| `operation` | What you're doing | `edit`, `create`, `delete` |
|
|
74
|
+
| `reason` | Why (task name) | `implement-auth` |
|
|
75
|
+
| `declaredAt` | Timestamp (ISO 8601) | `2025-10-31T12:00:00.000Z` |
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Step-by-Step Usage
|
|
80
|
+
|
|
81
|
+
### 1. Before Editing Any File
|
|
82
|
+
|
|
83
|
+
**MANDATORY**: Declare files first!
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Agent creates/updates declaration file
|
|
87
|
+
cat > .file-coordination/active-edits/claude-abc1.json << 'EOF'
|
|
88
|
+
{
|
|
89
|
+
"agent": "claude",
|
|
90
|
+
"session": "abc1-23d4",
|
|
91
|
+
"files": ["src/auth/login.js"],
|
|
92
|
+
"operation": "edit",
|
|
93
|
+
"reason": "add-authentication",
|
|
94
|
+
"declaredAt": "2025-10-31T12:00:00.000Z"
|
|
95
|
+
}
|
|
96
|
+
EOF
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 2. Check for Conflicts
|
|
100
|
+
|
|
101
|
+
The system automatically checks for conflicts. If another agent already locked a file:
|
|
102
|
+
|
|
103
|
+
**Warning displayed:**
|
|
104
|
+
```
|
|
105
|
+
⚠ Conflict detected!
|
|
106
|
+
File: src/auth/login.js
|
|
107
|
+
Locked by: cursor (session: xyz5-67d8)
|
|
108
|
+
Reason: refactor-authentication
|
|
109
|
+
|
|
110
|
+
Action: Ask user which agent should proceed
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 3. Make Your Changes
|
|
114
|
+
|
|
115
|
+
Once files are declared (and no conflicts), edit freely:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Now safe to edit
|
|
119
|
+
vim src/auth/login.js
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### 4. Release Locks (On Session Close)
|
|
123
|
+
|
|
124
|
+
When closing your session:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
s9n-devops-agent close abc1-23d4
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Automatic cleanup:**
|
|
131
|
+
- Removes `.file-coordination/active-edits/claude-abc1.json`
|
|
132
|
+
- Releases all locked files
|
|
133
|
+
- Merges changes to daily branch
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Multi-File Declarations
|
|
138
|
+
|
|
139
|
+
### Adding More Files
|
|
140
|
+
|
|
141
|
+
Update your declaration file to include additional files:
|
|
142
|
+
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"agent": "claude",
|
|
146
|
+
"session": "abc1-23d4",
|
|
147
|
+
"files": [
|
|
148
|
+
"src/auth/login.js",
|
|
149
|
+
"src/auth/token.js", ← Added
|
|
150
|
+
"src/utils/validation.js" ← Added
|
|
151
|
+
],
|
|
152
|
+
"operation": "edit",
|
|
153
|
+
"reason": "implement-authentication",
|
|
154
|
+
"declaredAt": "2025-10-31T12:15:00.000Z"
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Removing Files
|
|
159
|
+
|
|
160
|
+
If you're done with a file, remove it from the array:
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"files": [
|
|
165
|
+
"src/auth/token.js" ← login.js removed, now available
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Conflict Resolution
|
|
173
|
+
|
|
174
|
+
### Scenario: Two Agents Need Same File
|
|
175
|
+
|
|
176
|
+
**Agent 1 (Claude):**
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"agent": "claude",
|
|
180
|
+
"session": "abc1-23d4",
|
|
181
|
+
"files": ["src/auth.js"],
|
|
182
|
+
"declaredAt": "2025-10-31T10:00:00Z"
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Agent 2 (Cursor) tries:**
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"agent": "cursor",
|
|
190
|
+
"session": "xyz5-67d8",
|
|
191
|
+
"files": ["src/auth.js"], ← CONFLICT!
|
|
192
|
+
"declaredAt": "2025-10-31T10:05:00Z"
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Resolution Options
|
|
197
|
+
|
|
198
|
+
#### Option 1: Wait for Agent 1
|
|
199
|
+
```bash
|
|
200
|
+
# Agent 2 waits until Agent 1 finishes and closes session
|
|
201
|
+
# Then declares and proceeds
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Option 2: Coordinate Different Files
|
|
205
|
+
```bash
|
|
206
|
+
# Agent 1: Works on src/auth/login.js
|
|
207
|
+
# Agent 2: Works on src/auth/token.js
|
|
208
|
+
# No overlap, no conflict
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### Option 3: Sequential Work
|
|
212
|
+
```bash
|
|
213
|
+
# Agent 1: Completes work, commits, closes session
|
|
214
|
+
# Agent 2: Starts new session, declares files, proceeds
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Option 4: Override (Dangerous!)
|
|
218
|
+
```bash
|
|
219
|
+
# User manually removes Agent 1's lock (emergency only)
|
|
220
|
+
rm .file-coordination/active-edits/claude-abc1.json
|
|
221
|
+
|
|
222
|
+
# Agent 2 can now declare
|
|
223
|
+
# ⚠️ Risk: Agent 1's uncommitted changes may be lost
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Best Practices
|
|
229
|
+
|
|
230
|
+
### 1. Declare Early, Declare All
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# ✅ Good: Declare all files upfront
|
|
234
|
+
{
|
|
235
|
+
"files": [
|
|
236
|
+
"src/auth/login.js",
|
|
237
|
+
"src/auth/token.js",
|
|
238
|
+
"src/auth/validation.js"
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
# ❌ Bad: Declare one, edit three
|
|
243
|
+
{
|
|
244
|
+
"files": ["src/auth/login.js"]
|
|
245
|
+
}
|
|
246
|
+
# Then editing token.js and validation.js without declaring
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 2. Use Specific Paths
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# ✅ Good: Specific files
|
|
253
|
+
"files": ["src/auth/login.js", "src/auth/token.js"]
|
|
254
|
+
|
|
255
|
+
# ❌ Bad: Wildcards (not supported)
|
|
256
|
+
"files": ["src/auth/*.js"]
|
|
257
|
+
|
|
258
|
+
# ❌ Bad: Directories (declare files, not dirs)
|
|
259
|
+
"files": ["src/auth/"]
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### 3. Update Declarations
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
# If you realize you need another file:
|
|
266
|
+
# 1. Update your declaration JSON
|
|
267
|
+
# 2. Check for conflicts on the new file
|
|
268
|
+
# 3. If clear, proceed
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### 4. Release Promptly
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Don't keep sessions open indefinitely
|
|
275
|
+
# Close when done to release locks for others
|
|
276
|
+
|
|
277
|
+
s9n-devops-agent close abc1-23d4
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Troubleshooting
|
|
283
|
+
|
|
284
|
+
### Problem: "File already locked" error
|
|
285
|
+
|
|
286
|
+
**Cause:** Another agent declared the file first
|
|
287
|
+
|
|
288
|
+
**Solution:**
|
|
289
|
+
1. Check active declarations:
|
|
290
|
+
```bash
|
|
291
|
+
ls -la .file-coordination/active-edits/
|
|
292
|
+
cat .file-coordination/active-edits/*.json
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
2. Identify the locking agent and session
|
|
296
|
+
3. Coordinate with that agent's user
|
|
297
|
+
4. Wait or work on different files
|
|
298
|
+
|
|
299
|
+
### Problem: Stale lock (agent crashed)
|
|
300
|
+
|
|
301
|
+
**Cause:** Session closed improperly, lock file remains
|
|
302
|
+
|
|
303
|
+
**Solution:**
|
|
304
|
+
```bash
|
|
305
|
+
# List all locks
|
|
306
|
+
ls .file-coordination/active-edits/
|
|
307
|
+
|
|
308
|
+
# Check if session is actually active
|
|
309
|
+
s9n-devops-agent list
|
|
310
|
+
|
|
311
|
+
# If session not in list, safe to remove lock
|
|
312
|
+
rm .file-coordination/active-edits/claude-abc1.json
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Problem: Forgot to declare file before editing
|
|
316
|
+
|
|
317
|
+
**Cause:** Edited file without declaring it first
|
|
318
|
+
|
|
319
|
+
**Solution:**
|
|
320
|
+
1. **Immediately declare** the file (retroactively)
|
|
321
|
+
2. Check if anyone else declared it meanwhile
|
|
322
|
+
3. If conflict, coordinate resolution
|
|
323
|
+
4. Commit your changes ASAP
|
|
324
|
+
5. Close session to release lock
|
|
325
|
+
|
|
326
|
+
**Prevention:** Always declare before editing!
|
|
327
|
+
|
|
328
|
+
### Problem: Need to edit same file as another agent
|
|
329
|
+
|
|
330
|
+
**Cause:** Legitimate need for both agents to work on same file
|
|
331
|
+
|
|
332
|
+
**Solutions:**
|
|
333
|
+
1. **Sequential:** Agent 1 finishes → commits → closes → Agent 2 starts
|
|
334
|
+
2. **Split work:** Divide file into sections, each agent works on different functions
|
|
335
|
+
3. **Different files:** Agent 1 works on login.js, Agent 2 on token.js
|
|
336
|
+
4. **Manual merge:** Both work, manually merge changes later (advanced)
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## Advanced Scenarios
|
|
341
|
+
|
|
342
|
+
### Scenario: Partial File Lock
|
|
343
|
+
|
|
344
|
+
**Want:** Lock only specific functions in a large file
|
|
345
|
+
|
|
346
|
+
**Reality:** File coordination locks entire files
|
|
347
|
+
|
|
348
|
+
**Workaround:**
|
|
349
|
+
1. Refactor: Split large file into smaller files
|
|
350
|
+
2. Each agent locks their target files
|
|
351
|
+
3. Cleaner, more manageable
|
|
352
|
+
|
|
353
|
+
### Scenario: Read-Only Access
|
|
354
|
+
|
|
355
|
+
**Want:** Agent 1 writes, Agent 2 reads (no lock needed for reading)
|
|
356
|
+
|
|
357
|
+
**Solution:**
|
|
358
|
+
```json
|
|
359
|
+
{
|
|
360
|
+
"operation": "read", ← Read-only, doesn't lock
|
|
361
|
+
"files": ["src/config.js"]
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
**Note:** Reading doesn't require locks, but declaring helps track dependencies.
|
|
366
|
+
|
|
367
|
+
### Scenario: Emergency Override
|
|
368
|
+
|
|
369
|
+
**When:** Production issue, need immediate access
|
|
370
|
+
|
|
371
|
+
**Steps:**
|
|
372
|
+
1. **Communicate:** Notify other agent's user
|
|
373
|
+
2. **Backup:** Copy current state
|
|
374
|
+
3. **Remove lock:** `rm .file-coordination/active-edits/agent-session.json`
|
|
375
|
+
4. **Declare:** Your agent declares the file
|
|
376
|
+
5. **Work fast:** Minimize overlap window
|
|
377
|
+
6. **Coordinate merge:** Manually merge any parallel changes
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
## Directory Structure
|
|
382
|
+
|
|
383
|
+
```
|
|
384
|
+
.file-coordination/
|
|
385
|
+
├── active-edits/
|
|
386
|
+
│ ├── claude-abc1-23d4.json # Claude's session abc1-23d4
|
|
387
|
+
│ ├── cursor-xyz5-67d8.json # Cursor's session xyz5-67d8
|
|
388
|
+
│ └── copilot-def9-01gh.json # Copilot's session def9-01gh
|
|
389
|
+
└── history/
|
|
390
|
+
├── claude-abc1-23d4-closed.json
|
|
391
|
+
└── cursor-xyz5-67d8-closed.json
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Files Explained
|
|
395
|
+
|
|
396
|
+
- **active-edits/**: Current active file locks
|
|
397
|
+
- **history/**: Archived locks from closed sessions (for audit)
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Integration with Sessions
|
|
402
|
+
|
|
403
|
+
### Session Creation
|
|
404
|
+
|
|
405
|
+
1. Session created: `abc1-23d4`
|
|
406
|
+
2. Worktree created: `local_deploy/worktrees/abc1-23d4/`
|
|
407
|
+
3. Declaration file ready: `.file-coordination/active-edits/claude-abc1.json`
|
|
408
|
+
|
|
409
|
+
### During Session
|
|
410
|
+
|
|
411
|
+
1. Agent declares files in declaration JSON
|
|
412
|
+
2. Makes changes in worktree
|
|
413
|
+
3. Commits with `.devops-commit-abc1.msg`
|
|
414
|
+
4. Auto-push to GitHub
|
|
415
|
+
|
|
416
|
+
### Session Close
|
|
417
|
+
|
|
418
|
+
1. All changes committed and pushed
|
|
419
|
+
2. Declaration file moved to history/
|
|
420
|
+
3. Locks released
|
|
421
|
+
4. Worktree merged to daily branch
|
|
422
|
+
5. Worktree removed
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
## FAQ
|
|
427
|
+
|
|
428
|
+
**Q: Do I need to declare config files?**
|
|
429
|
+
A: Yes, if you're editing them. Read-only doesn't require locks.
|
|
430
|
+
|
|
431
|
+
**Q: Can I declare files retroactively?**
|
|
432
|
+
A: Yes, but risky. Better to declare before editing.
|
|
433
|
+
|
|
434
|
+
**Q: What if two agents declare simultaneously?**
|
|
435
|
+
A: System detects conflict when second agent tries to declare. First declarer wins.
|
|
436
|
+
|
|
437
|
+
**Q: Can I lock an entire directory?**
|
|
438
|
+
A: No. Declare individual files. Use wildcards in your local script, but declaration must list specific files.
|
|
439
|
+
|
|
440
|
+
**Q: How long do locks last?**
|
|
441
|
+
A: Until session closes. Close sessions promptly!
|
|
442
|
+
|
|
443
|
+
**Q: Can I transfer a lock to another agent?**
|
|
444
|
+
A: No. Close current session (releases lock), then new agent creates session and declares.
|
|
445
|
+
|
|
446
|
+
---
|
|
447
|
+
|
|
448
|
+
## Summary
|
|
449
|
+
|
|
450
|
+
### Key Takeaways
|
|
451
|
+
|
|
452
|
+
1. **Always declare files before editing**
|
|
453
|
+
2. **Check for conflicts** (.file-coordination/active-edits/)
|
|
454
|
+
3. **Update declarations** when adding files
|
|
455
|
+
4. **Release locks** by closing sessions promptly
|
|
456
|
+
5. **Coordinate** with other agents when conflicts arise
|
|
457
|
+
|
|
458
|
+
### File Coordination Flow
|
|
459
|
+
|
|
460
|
+
```
|
|
461
|
+
1. Start session
|
|
462
|
+
↓
|
|
463
|
+
2. Declare files (.file-coordination/active-edits/<agent>-<session>.json)
|
|
464
|
+
↓
|
|
465
|
+
3. Check conflicts (system alerts if any)
|
|
466
|
+
↓
|
|
467
|
+
4. Edit files (safe, locks held)
|
|
468
|
+
↓
|
|
469
|
+
5. Commit changes (.devops-commit-<session>.msg)
|
|
470
|
+
↓
|
|
471
|
+
6. Close session (releases locks, merges)
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
**Need Help?** Run `s9n-devops-agent help-topics` and select "File Coordination"
|
|
477
|
+
|
|
478
|
+
**Related Guides:**
|
|
479
|
+
- Session Management Guide
|
|
480
|
+
- Multi-Agent Workflows
|
|
481
|
+
- House Rules Guide
|