create-byan-agent 1.1.3 → 1.2.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/CHANGELOG.md +273 -202
- package/LICENSE +21 -21
- package/README.md +1251 -421
- package/bin/create-byan-agent-backup.js +220 -220
- package/bin/create-byan-agent-fixed.js +301 -301
- package/bin/create-byan-agent.js +155 -322
- package/lib/errors.js +61 -0
- package/lib/exit-codes.js +54 -0
- package/lib/platforms/claude-code.js +113 -0
- package/lib/platforms/codex.js +92 -0
- package/lib/platforms/copilot-cli.js +123 -0
- package/lib/platforms/index.js +14 -0
- package/lib/platforms/vscode.js +51 -0
- package/lib/utils/config-loader.js +79 -0
- package/lib/utils/file-utils.js +104 -0
- package/lib/utils/git-detector.js +35 -0
- package/lib/utils/logger.js +64 -0
- package/lib/utils/node-detector.js +58 -0
- package/lib/utils/os-detector.js +74 -0
- package/lib/utils/yaml-utils.js +87 -0
- package/lib/yanstaller/backuper.js +308 -0
- package/lib/yanstaller/detector.js +141 -0
- package/lib/yanstaller/index.js +93 -0
- package/lib/yanstaller/installer.js +225 -0
- package/lib/yanstaller/interviewer.js +250 -0
- package/lib/yanstaller/recommender.js +298 -0
- package/lib/yanstaller/troubleshooter.js +498 -0
- package/lib/yanstaller/validator.js +578 -0
- package/lib/yanstaller/wizard.js +211 -0
- package/package.json +61 -55
- package/templates/.github/agents/bmad-agent-bmad-master.md +15 -15
- package/templates/.github/agents/bmad-agent-bmb-agent-builder.md +15 -15
- package/templates/.github/agents/bmad-agent-bmb-module-builder.md +15 -15
- package/templates/.github/agents/bmad-agent-bmb-workflow-builder.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-analyst.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-architect.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-dev.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-pm.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-quick-flow-solo-dev.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-quinn.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-sm.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-tech-writer.md +15 -15
- package/templates/.github/agents/bmad-agent-bmm-ux-designer.md +15 -15
- package/templates/.github/agents/bmad-agent-byan-test.md +32 -0
- package/templates/.github/agents/bmad-agent-byan.md +224 -224
- package/templates/.github/agents/bmad-agent-carmack.md +18 -0
- package/templates/.github/agents/bmad-agent-cis-brainstorming-coach.md +15 -15
- package/templates/.github/agents/bmad-agent-cis-creative-problem-solver.md +15 -15
- package/templates/.github/agents/bmad-agent-cis-design-thinking-coach.md +15 -15
- package/templates/.github/agents/bmad-agent-cis-innovation-strategist.md +15 -15
- package/templates/.github/agents/bmad-agent-cis-presentation-master.md +15 -15
- package/templates/.github/agents/bmad-agent-cis-storyteller.md +15 -15
- package/templates/.github/agents/bmad-agent-marc.md +48 -48
- package/templates/.github/agents/bmad-agent-patnote.md +48 -0
- package/templates/.github/agents/bmad-agent-rachid.md +47 -47
- package/templates/.github/agents/bmad-agent-tea-tea.md +15 -15
- package/templates/.github/agents/bmad-agent-test-dynamic.md +21 -0
- package/templates/.github/agents/expert-merise-agile.md +1 -0
- package/templates/.github/agents/franck.md +379 -0
- package/templates/_bmad/bmb/agents/agent-builder.md +59 -59
- package/templates/_bmad/bmb/agents/byan-test.md +116 -116
- package/templates/_bmad/bmb/agents/byan.md +215 -215
- package/templates/_bmad/bmb/agents/marc.md +303 -303
- package/templates/_bmad/bmb/agents/module-builder.md +60 -60
- package/templates/_bmad/bmb/agents/patnote.md +495 -495
- package/templates/_bmad/bmb/agents/rachid.md +184 -184
- package/templates/_bmad/bmb/agents/workflow-builder.md +61 -61
- package/templates/_bmad/bmb/workflows/byan/data/mantras.yaml +272 -272
- package/templates/_bmad/bmb/workflows/byan/data/templates.yaml +59 -59
- package/templates/_bmad/bmb/workflows/byan/delete-agent-workflow.md +657 -657
- package/templates/_bmad/bmb/workflows/byan/edit-agent-workflow.md +688 -688
- package/templates/_bmad/bmb/workflows/byan/interview-workflow.md +753 -753
- package/templates/_bmad/bmb/workflows/byan/quick-create-workflow.md +450 -450
- package/templates/_bmad/bmb/workflows/byan/templates/base-agent-template.md +79 -79
- package/templates/_bmad/bmb/workflows/byan/validate-agent-workflow.md +676 -676
- package/templates/_bmad/core/agents/carmack.md +238 -238
|
@@ -1,657 +1,657 @@
|
|
|
1
|
-
# BYAN Delete Agent Workflow
|
|
2
|
-
|
|
3
|
-
**Workflow:** Safe Agent Deletion with Backup & Consequences Warning
|
|
4
|
-
**Duration:** 5 minutes
|
|
5
|
-
**Methodology:** Mantra #39 (Consequences) + Safety First
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## OVERVIEW
|
|
10
|
-
|
|
11
|
-
Delete Agent workflow safely removes agents with:
|
|
12
|
-
- **Mandatory backup** before deletion
|
|
13
|
-
- **Consequences evaluation** (Mantra #39)
|
|
14
|
-
- **Explicit confirmation** required
|
|
15
|
-
- **Dependency checking**
|
|
16
|
-
- **Rollback capability**
|
|
17
|
-
|
|
18
|
-
**Key Principle:**
|
|
19
|
-
> "Deletion is permanent. Evaluate consequences, backup everything, confirm explicitly."
|
|
20
|
-
|
|
21
|
-
**Mantras Applied:**
|
|
22
|
-
- Mantra #39: Évaluation des Conséquences (PRIMARY)
|
|
23
|
-
- Mantra IA-1: Trust But Verify
|
|
24
|
-
- RG-DEL-001: Confirmation explicite
|
|
25
|
-
- RG-DEL-002: Backup obligatoire
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## SAFETY LEVELS
|
|
30
|
-
|
|
31
|
-
### 🟢 LOW RISK
|
|
32
|
-
- Agent status: draft
|
|
33
|
-
- Never deployed
|
|
34
|
-
- No dependencies
|
|
35
|
-
- No usage history
|
|
36
|
-
|
|
37
|
-
→ Simple deletion with backup
|
|
38
|
-
|
|
39
|
-
### 🟡 MEDIUM RISK
|
|
40
|
-
- Agent status: validated
|
|
41
|
-
- Not deployed but tested
|
|
42
|
-
- Some documentation references
|
|
43
|
-
|
|
44
|
-
→ Requires confirmation + backup
|
|
45
|
-
|
|
46
|
-
### 🔴 HIGH RISK
|
|
47
|
-
- Agent status: deployed
|
|
48
|
-
- Actively used in workflows
|
|
49
|
-
- Referenced by other agents
|
|
50
|
-
- Has usage history
|
|
51
|
-
|
|
52
|
-
→ Requires deprecation period, not immediate deletion
|
|
53
|
-
|
|
54
|
-
### 🔥 CRITICAL RISK
|
|
55
|
-
- Agent status: deployed
|
|
56
|
-
- Core/critical agent
|
|
57
|
-
- Multiple dependencies
|
|
58
|
-
- High usage frequency
|
|
59
|
-
|
|
60
|
-
→ **CANNOT DELETE** - Deprecation and migration required
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
## WORKFLOW STEPS
|
|
65
|
-
|
|
66
|
-
### Step 1: Select Agent to Delete
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
"⚠️ AGENT DELETION - PERMANENT ACTION
|
|
70
|
-
|
|
71
|
-
Which agent do you want to delete?
|
|
72
|
-
|
|
73
|
-
Available agents:
|
|
74
|
-
1. {agent_1} - [{status}] - {usage_info}
|
|
75
|
-
2. {agent_2} - [{status}] - {usage_info}
|
|
76
|
-
3. {agent_3} - [{status}] - {usage_info}
|
|
77
|
-
...
|
|
78
|
-
|
|
79
|
-
Agent number or name (or 'cancel' to exit): ____
|
|
80
|
-
"
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**Load agent and analyze:**
|
|
84
|
-
```python
|
|
85
|
-
agent_spec = AgentSpec.load(agent_id_or_name)
|
|
86
|
-
context = ProjectContext.load(agent_spec.context_id)
|
|
87
|
-
|
|
88
|
-
# Analyze risk
|
|
89
|
-
risk_level = analyze_deletion_risk(agent_spec)
|
|
90
|
-
dependencies = find_dependencies(agent_spec)
|
|
91
|
-
usage_stats = get_usage_stats(agent_spec)
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
### Step 2: Display Agent Info & Risk Assessment
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
"════════════════════════════════════════════════════
|
|
100
|
-
AGENT DELETION ANALYSIS
|
|
101
|
-
════════════════════════════════════════════════════
|
|
102
|
-
|
|
103
|
-
AGENT INFORMATION:
|
|
104
|
-
Name: {agent_name}
|
|
105
|
-
Role: {role}
|
|
106
|
-
Status: {status}
|
|
107
|
-
Created: {created_at}
|
|
108
|
-
Last Modified: {updated_at}
|
|
109
|
-
Last Used: {last_used}
|
|
110
|
-
|
|
111
|
-
USAGE STATISTICS:
|
|
112
|
-
Total Invocations: {invocation_count}
|
|
113
|
-
Active Users: {user_count}
|
|
114
|
-
Referenced In: {reference_count} files
|
|
115
|
-
Dependencies: {dependency_count}
|
|
116
|
-
|
|
117
|
-
RISK ASSESSMENT: {risk_level}
|
|
118
|
-
|
|
119
|
-
{if LOW RISK 🟢:}
|
|
120
|
-
This agent can be safely deleted.
|
|
121
|
-
- Status: draft
|
|
122
|
-
- No active usage
|
|
123
|
-
- No dependencies detected
|
|
124
|
-
|
|
125
|
-
{if MEDIUM RISK 🟡:}
|
|
126
|
-
This agent has some references.
|
|
127
|
-
- Status: validated
|
|
128
|
-
- Referenced in {n} places
|
|
129
|
-
- Deletion will break: {list_affected}
|
|
130
|
-
|
|
131
|
-
{if HIGH RISK 🔴:}
|
|
132
|
-
This agent is actively used!
|
|
133
|
-
- Status: deployed
|
|
134
|
-
- {n} active users
|
|
135
|
-
- {n} dependencies
|
|
136
|
-
- Immediate deletion NOT RECOMMENDED
|
|
137
|
-
|
|
138
|
-
{if CRITICAL RISK 🔥:}
|
|
139
|
-
⛔ DELETION BLOCKED - This is a critical agent!
|
|
140
|
-
- Core system component
|
|
141
|
-
- {n} critical dependencies
|
|
142
|
-
- Cannot delete without migration plan
|
|
143
|
-
|
|
144
|
-
════════════════════════════════════════════════════
|
|
145
|
-
"
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
---
|
|
149
|
-
|
|
150
|
-
### Step 3: Consequences Evaluation (Mantra #39)
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
"CONSEQUENCES OF DELETING '{agent_name}':
|
|
154
|
-
|
|
155
|
-
1. 📊 SCOPE:
|
|
156
|
-
- Agent will be completely removed
|
|
157
|
-
- All configurations lost
|
|
158
|
-
- History lost (unless backed up)
|
|
159
|
-
Impact: {High/Medium/Low}
|
|
160
|
-
|
|
161
|
-
2. 💾 DATA:
|
|
162
|
-
- AgentSpec record deleted
|
|
163
|
-
- AgentFile(s) deleted
|
|
164
|
-
- Database entries removed
|
|
165
|
-
Impact: {High/Medium/Low}
|
|
166
|
-
|
|
167
|
-
3. 🔧 CODE:
|
|
168
|
-
- References to this agent will break
|
|
169
|
-
- Files affected: {list}
|
|
170
|
-
Impact: {High/Medium/Low}
|
|
171
|
-
|
|
172
|
-
4. 👥 TEAM:
|
|
173
|
-
- Users actively using this agent: {count}
|
|
174
|
-
- Team members to notify: {list}
|
|
175
|
-
Impact: {High/Medium/Low}
|
|
176
|
-
|
|
177
|
-
5. 🎯 CLIENTS:
|
|
178
|
-
- User workflows affected: {workflows}
|
|
179
|
-
- Breaking change: {yes/no}
|
|
180
|
-
Impact: {High/Medium/Low}
|
|
181
|
-
|
|
182
|
-
6. ⚖️ LEGAL:
|
|
183
|
-
- Compliance impact: {none/review required}
|
|
184
|
-
Impact: {High/Medium/Low}
|
|
185
|
-
|
|
186
|
-
7. 🚀 OPERATIONS:
|
|
187
|
-
- Active processes using agent: {count}
|
|
188
|
-
- Immediate impact: {yes/no}
|
|
189
|
-
Impact: {High/Medium/Low}
|
|
190
|
-
|
|
191
|
-
8. 🔗 DEPENDENCIES:
|
|
192
|
-
- Agents depending on this one: {list}
|
|
193
|
-
- External systems affected: {list}
|
|
194
|
-
Impact: {High/Medium/Low}
|
|
195
|
-
|
|
196
|
-
9. ⏱️ TIME:
|
|
197
|
-
- Deletion time: Immediate
|
|
198
|
-
- Recovery time if mistake: {estimate}
|
|
199
|
-
- Team notification time: {estimate}
|
|
200
|
-
Impact: {High/Medium/Low}
|
|
201
|
-
|
|
202
|
-
10. 🔄 ALTERNATIVES:
|
|
203
|
-
- Deprecate instead of delete: {recommended/not needed}
|
|
204
|
-
- Archive and keep backup: {always}
|
|
205
|
-
- Migrate to replacement agent: {needed/not needed}
|
|
206
|
-
|
|
207
|
-
OVERALL RISK: {risk_level}
|
|
208
|
-
|
|
209
|
-
════════════════════════════════════════════════════
|
|
210
|
-
"
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
### Step 4: Dependencies Check
|
|
216
|
-
|
|
217
|
-
```
|
|
218
|
-
"DEPENDENCY ANALYSIS:
|
|
219
|
-
|
|
220
|
-
{if no dependencies:}
|
|
221
|
-
✅ No dependencies found. Safe to delete.
|
|
222
|
-
|
|
223
|
-
{if dependencies exist:}
|
|
224
|
-
⚠️ Dependencies detected:
|
|
225
|
-
|
|
226
|
-
FILES REFERENCING THIS AGENT:
|
|
227
|
-
1. {file_1}:{line} - {context}
|
|
228
|
-
2. {file_2}:{line} - {context}
|
|
229
|
-
...
|
|
230
|
-
|
|
231
|
-
AGENTS DEPENDING ON THIS ONE:
|
|
232
|
-
- {dependent_agent_1}: {reason}
|
|
233
|
-
- {dependent_agent_2}: {reason}
|
|
234
|
-
|
|
235
|
-
WORKFLOWS USING THIS AGENT:
|
|
236
|
-
- {workflow_1}
|
|
237
|
-
- {workflow_2}
|
|
238
|
-
|
|
239
|
-
BREAKING IMPACT:
|
|
240
|
-
- {impact_summary}
|
|
241
|
-
|
|
242
|
-
RECOMMENDATION:
|
|
243
|
-
{if HIGH/CRITICAL:}
|
|
244
|
-
🛑 DO NOT DELETE immediately.
|
|
245
|
-
1. Create replacement agent first
|
|
246
|
-
2. Migrate all dependencies
|
|
247
|
-
3. Deprecate this agent (30 day notice)
|
|
248
|
-
4. Delete after migration complete
|
|
249
|
-
|
|
250
|
-
{if MEDIUM:}
|
|
251
|
-
⚠️ Fix dependencies before deleting:
|
|
252
|
-
1. Update all referencing files
|
|
253
|
-
2. Notify users
|
|
254
|
-
3. Then proceed with deletion
|
|
255
|
-
|
|
256
|
-
{if LOW:}
|
|
257
|
-
✅ Safe to delete with backup
|
|
258
|
-
"
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
### Step 5: Backup Creation (MANDATORY - RG-DEL-002)
|
|
264
|
-
|
|
265
|
-
```
|
|
266
|
-
"Creating backup before deletion...
|
|
267
|
-
|
|
268
|
-
BACKUP STRATEGY:
|
|
269
|
-
1. Export AgentSpec to YAML
|
|
270
|
-
2. Save agent files to archive
|
|
271
|
-
3. Capture full history/metadata
|
|
272
|
-
4. Store in safe location
|
|
273
|
-
|
|
274
|
-
[▓▓▓▓▓▓▓▓▓▓] 100% - Backup complete
|
|
275
|
-
|
|
276
|
-
BACKUP CREATED:
|
|
277
|
-
Location: {backup_path}
|
|
278
|
-
Format: .tar.gz (compressed)
|
|
279
|
-
Size: {size}
|
|
280
|
-
Contains:
|
|
281
|
-
- agent-spec.yaml
|
|
282
|
-
- agent-files/
|
|
283
|
-
- metadata.json
|
|
284
|
-
- usage-history.log
|
|
285
|
-
|
|
286
|
-
Backup validated: ✅
|
|
287
|
-
|
|
288
|
-
To restore this agent later:
|
|
289
|
-
byan restore {backup_path}
|
|
290
|
-
|
|
291
|
-
════════════════════════════════════════════════════
|
|
292
|
-
"
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
**Backup structure:**
|
|
296
|
-
```
|
|
297
|
-
backup-{agent_name}-{timestamp}.tar.gz
|
|
298
|
-
├── agent-spec.yaml # Full AgentSpec export
|
|
299
|
-
├── agent-files/
|
|
300
|
-
│ ├── copilot.md # Generated files
|
|
301
|
-
│ ├── vscode.md
|
|
302
|
-
│ └── claude.md
|
|
303
|
-
├── metadata.json # Timestamps, user, reason
|
|
304
|
-
├── usage-history.log # Usage statistics
|
|
305
|
-
└── dependencies.json # Captured dependencies
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
|
-
### Step 6: Final Confirmation (RG-DEL-001)
|
|
311
|
-
|
|
312
|
-
```
|
|
313
|
-
"════════════════════════════════════════════════════
|
|
314
|
-
⚠️ FINAL CONFIRMATION REQUIRED
|
|
315
|
-
════════════════════════════════════════════════════
|
|
316
|
-
|
|
317
|
-
You are about to PERMANENTLY DELETE:
|
|
318
|
-
Agent: {agent_name}
|
|
319
|
-
Role: {role}
|
|
320
|
-
Status: {status}
|
|
321
|
-
|
|
322
|
-
This action:
|
|
323
|
-
❌ CANNOT be undone (except from backup)
|
|
324
|
-
❌ Will break {n} references
|
|
325
|
-
❌ Will affect {n} users
|
|
326
|
-
✅ Backup created at: {backup_path}
|
|
327
|
-
|
|
328
|
-
RISK LEVEL: {risk_level}
|
|
329
|
-
|
|
330
|
-
To confirm deletion, type the agent name exactly: '{agent_name}'
|
|
331
|
-
|
|
332
|
-
Confirmation: ____
|
|
333
|
-
|
|
334
|
-
(or type 'cancel' to abort)
|
|
335
|
-
════════════════════════════════════════════════════
|
|
336
|
-
"
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
**Validation:**
|
|
340
|
-
```python
|
|
341
|
-
def confirm_deletion(user_input, agent_name):
|
|
342
|
-
if user_input.lower() == 'cancel':
|
|
343
|
-
return "CANCELLED"
|
|
344
|
-
|
|
345
|
-
if user_input == agent_name: # Exact match required
|
|
346
|
-
return "CONFIRMED"
|
|
347
|
-
|
|
348
|
-
return "INVALID" # Must retype
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
**If confirmation fails:**
|
|
352
|
-
```
|
|
353
|
-
"❌ Confirmation failed. Agent name must match exactly.
|
|
354
|
-
|
|
355
|
-
Expected: '{agent_name}'
|
|
356
|
-
You typed: '{user_input}'
|
|
357
|
-
|
|
358
|
-
Try again or type 'cancel': ____
|
|
359
|
-
"
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
### Step 7: Execute Deletion
|
|
365
|
-
|
|
366
|
-
**If confirmed:**
|
|
367
|
-
```python
|
|
368
|
-
def delete_agent(agent_spec, backup):
|
|
369
|
-
try:
|
|
370
|
-
# 1. Delete agent files
|
|
371
|
-
agent_files = AgentFile.find_by_agent(agent_spec.id)
|
|
372
|
-
for file in agent_files:
|
|
373
|
-
file.delete()
|
|
374
|
-
log_deletion(file, backup)
|
|
375
|
-
|
|
376
|
-
# 2. Delete AgentSpec
|
|
377
|
-
agent_spec.delete()
|
|
378
|
-
log_deletion(agent_spec, backup)
|
|
379
|
-
|
|
380
|
-
# 3. Update project context (remove agent reference)
|
|
381
|
-
context = ProjectContext.load(agent_spec.context_id)
|
|
382
|
-
context.remove_agent_reference(agent_spec.id)
|
|
383
|
-
context.save()
|
|
384
|
-
|
|
385
|
-
# 4. Create deletion record (audit trail)
|
|
386
|
-
DeletionRecord.create(
|
|
387
|
-
agent_name=agent_spec.agent_name,
|
|
388
|
-
deleted_by=current_user,
|
|
389
|
-
deleted_at=now(),
|
|
390
|
-
backup_location=backup.path,
|
|
391
|
-
reason=deletion_reason,
|
|
392
|
-
consequences=consequences_evaluated
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
return DeleteSuccess(backup=backup)
|
|
396
|
-
|
|
397
|
-
except Exception as e:
|
|
398
|
-
# Rollback if anything fails
|
|
399
|
-
rollback_deletion(backup)
|
|
400
|
-
return DeleteFailed(error=e)
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
**Progress:**
|
|
404
|
-
```
|
|
405
|
-
"Deleting agent...
|
|
406
|
-
|
|
407
|
-
[▓▓▓░░░░░░░] 30% - Removing agent files...
|
|
408
|
-
[▓▓▓▓▓▓░░░░] 60% - Deleting AgentSpec...
|
|
409
|
-
[▓▓▓▓▓▓▓▓░░] 80% - Updating project context...
|
|
410
|
-
[▓▓▓▓▓▓▓▓▓▓] 100% - Creating audit record...
|
|
411
|
-
|
|
412
|
-
✅ Deletion complete.
|
|
413
|
-
"
|
|
414
|
-
```
|
|
415
|
-
|
|
416
|
-
---
|
|
417
|
-
|
|
418
|
-
### Step 8: Post-Deletion Summary
|
|
419
|
-
|
|
420
|
-
```
|
|
421
|
-
"════════════════════════════════════════════════════
|
|
422
|
-
DELETION COMPLETE
|
|
423
|
-
════════════════════════════════════════════════════
|
|
424
|
-
|
|
425
|
-
Agent '{agent_name}' has been permanently deleted.
|
|
426
|
-
|
|
427
|
-
WHAT WAS DELETED:
|
|
428
|
-
❌ AgentSpec record
|
|
429
|
-
❌ {n} agent file(s)
|
|
430
|
-
❌ Agent configurations
|
|
431
|
-
❌ Menu references
|
|
432
|
-
|
|
433
|
-
WHAT WAS PRESERVED:
|
|
434
|
-
✅ Full backup: {backup_path}
|
|
435
|
-
✅ Deletion audit record
|
|
436
|
-
✅ Usage history (in backup)
|
|
437
|
-
|
|
438
|
-
NEXT STEPS:
|
|
439
|
-
|
|
440
|
-
{if dependencies existed:}
|
|
441
|
-
⚠️ ACTION REQUIRED:
|
|
442
|
-
1. Fix broken references:
|
|
443
|
-
{list_files_to_fix}
|
|
444
|
-
2. Notify affected users:
|
|
445
|
-
{list_users}
|
|
446
|
-
3. Update documentation
|
|
447
|
-
|
|
448
|
-
{if no dependencies:}
|
|
449
|
-
✅ No further action needed.
|
|
450
|
-
|
|
451
|
-
RESTORATION:
|
|
452
|
-
To restore this agent from backup:
|
|
453
|
-
byan restore {backup_path}
|
|
454
|
-
|
|
455
|
-
Backup will be kept for {retention_period} days.
|
|
456
|
-
|
|
457
|
-
AUDIT TRAIL:
|
|
458
|
-
Deletion recorded in: {audit_log_path}
|
|
459
|
-
Deleted by: {user}
|
|
460
|
-
Timestamp: {timestamp}
|
|
461
|
-
Reason: {reason}
|
|
462
|
-
|
|
463
|
-
════════════════════════════════════════════════════
|
|
464
|
-
"
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
---
|
|
468
|
-
|
|
469
|
-
## ALTERNATIVE: DEPRECATION (Recommended for Deployed Agents)
|
|
470
|
-
|
|
471
|
-
**If agent is HIGH or CRITICAL risk:**
|
|
472
|
-
|
|
473
|
-
```
|
|
474
|
-
"🛑 DELETION NOT RECOMMENDED
|
|
475
|
-
|
|
476
|
-
This agent is actively used. Instead of deleting immediately,
|
|
477
|
-
I recommend DEPRECATION:
|
|
478
|
-
|
|
479
|
-
DEPRECATION WORKFLOW:
|
|
480
|
-
1. Mark agent as 'deprecated' (status change)
|
|
481
|
-
2. Add deprecation notice (30-60 day warning)
|
|
482
|
-
3. Notify all users
|
|
483
|
-
4. Provide migration path to replacement
|
|
484
|
-
5. Monitor usage decline
|
|
485
|
-
6. Delete after usage reaches zero
|
|
486
|
-
|
|
487
|
-
Start deprecation workflow? (yes/cancel): ____
|
|
488
|
-
"
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
**Deprecation process:**
|
|
492
|
-
```python
|
|
493
|
-
def deprecate_agent(agent_spec, replacement=None):
|
|
494
|
-
# 1. Change status
|
|
495
|
-
agent_spec.status = "deprecated"
|
|
496
|
-
agent_spec.deprecation_date = now()
|
|
497
|
-
agent_spec.deprecation_deadline = now() + timedelta(days=30)
|
|
498
|
-
|
|
499
|
-
if replacement:
|
|
500
|
-
agent_spec.replacement_agent = replacement.id
|
|
501
|
-
|
|
502
|
-
# 2. Add deprecation warning to agent
|
|
503
|
-
agent_spec.add_deprecation_notice(
|
|
504
|
-
message=f"This agent is deprecated and will be removed on {deadline}",
|
|
505
|
-
replacement=replacement.agent_name if replacement else None,
|
|
506
|
-
migration_guide=generate_migration_guide(agent_spec, replacement)
|
|
507
|
-
)
|
|
508
|
-
|
|
509
|
-
# 3. Notify users
|
|
510
|
-
notify_users(
|
|
511
|
-
agent=agent_spec,
|
|
512
|
-
message="Agent deprecated - action required",
|
|
513
|
-
deadline=agent_spec.deprecation_deadline
|
|
514
|
-
)
|
|
515
|
-
|
|
516
|
-
agent_spec.save()
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
---
|
|
520
|
-
|
|
521
|
-
## RESTORE FROM BACKUP
|
|
522
|
-
|
|
523
|
-
**If user made a mistake:**
|
|
524
|
-
|
|
525
|
-
```
|
|
526
|
-
"Restore agent from backup:
|
|
527
|
-
|
|
528
|
-
byan restore {backup_path}
|
|
529
|
-
|
|
530
|
-
This will:
|
|
531
|
-
✅ Recreate AgentSpec
|
|
532
|
-
✅ Restore all agent files
|
|
533
|
-
✅ Restore configurations
|
|
534
|
-
✅ Preserve original timestamps
|
|
535
|
-
|
|
536
|
-
Note: Any changes made after backup will be lost.
|
|
537
|
-
"
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
```python
|
|
541
|
-
def restore_agent(backup_path):
|
|
542
|
-
backup = Backup.load(backup_path)
|
|
543
|
-
|
|
544
|
-
# 1. Validate backup integrity
|
|
545
|
-
if not backup.is_valid():
|
|
546
|
-
raise BackupCorruptedError()
|
|
547
|
-
|
|
548
|
-
# 2. Check if agent name conflicts
|
|
549
|
-
if AgentSpec.exists(backup.agent_name):
|
|
550
|
-
raise AgentAlreadyExistsError()
|
|
551
|
-
|
|
552
|
-
# 3. Restore AgentSpec
|
|
553
|
-
agent_spec = AgentSpec.from_backup(backup)
|
|
554
|
-
agent_spec.save()
|
|
555
|
-
|
|
556
|
-
# 4. Restore agent files
|
|
557
|
-
for file_data in backup.files:
|
|
558
|
-
agent_file = AgentFile.from_backup(file_data)
|
|
559
|
-
agent_file.save()
|
|
560
|
-
|
|
561
|
-
# 5. Update project context
|
|
562
|
-
context = ProjectContext.load(agent_spec.context_id)
|
|
563
|
-
context.add_agent_reference(agent_spec.id)
|
|
564
|
-
context.save()
|
|
565
|
-
|
|
566
|
-
return RestoreSuccess(agent_spec)
|
|
567
|
-
```
|
|
568
|
-
|
|
569
|
-
---
|
|
570
|
-
|
|
571
|
-
## ANTI-PATTERNS
|
|
572
|
-
|
|
573
|
-
**NEVER do these:**
|
|
574
|
-
|
|
575
|
-
❌ Delete without backup
|
|
576
|
-
❌ Delete deployed agents immediately
|
|
577
|
-
❌ Delete without checking dependencies
|
|
578
|
-
❌ Delete without team notification
|
|
579
|
-
❌ Delete without explicit confirmation
|
|
580
|
-
❌ Delete without consequence evaluation
|
|
581
|
-
❌ Delete without audit trail
|
|
582
|
-
|
|
583
|
-
**ALWAYS do these:**
|
|
584
|
-
|
|
585
|
-
✅ Create backup first (RG-DEL-002)
|
|
586
|
-
✅ Evaluate consequences (Mantra #39)
|
|
587
|
-
✅ Check dependencies thoroughly
|
|
588
|
-
✅ Require explicit confirmation (RG-DEL-001)
|
|
589
|
-
✅ Notify affected users
|
|
590
|
-
✅ Prefer deprecation for deployed agents
|
|
591
|
-
✅ Keep audit trail
|
|
592
|
-
✅ Test restore procedure
|
|
593
|
-
|
|
594
|
-
---
|
|
595
|
-
|
|
596
|
-
## CANCELLATION
|
|
597
|
-
|
|
598
|
-
**At any point, user can cancel:**
|
|
599
|
-
|
|
600
|
-
```
|
|
601
|
-
"Deletion cancelled.
|
|
602
|
-
|
|
603
|
-
No changes were made. Agent '{agent_name}' is still active.
|
|
604
|
-
|
|
605
|
-
{if backup was created:}
|
|
606
|
-
Note: Backup was created but not used.
|
|
607
|
-
Location: {backup_path}
|
|
608
|
-
You can delete this backup manually if not needed.
|
|
609
|
-
|
|
610
|
-
Return to menu? (yes): ____
|
|
611
|
-
"
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
---
|
|
615
|
-
|
|
616
|
-
## SUCCESS CRITERIA
|
|
617
|
-
|
|
618
|
-
✅ Risk level assessed
|
|
619
|
-
✅ Dependencies checked
|
|
620
|
-
✅ Consequences evaluated (10 dimensions)
|
|
621
|
-
✅ Backup created and validated (RG-DEL-002)
|
|
622
|
-
✅ Explicit confirmation obtained (RG-DEL-001)
|
|
623
|
-
✅ Agent deleted successfully
|
|
624
|
-
✅ Audit trail created
|
|
625
|
-
✅ User notified of next steps
|
|
626
|
-
✅ Restore instructions provided
|
|
627
|
-
|
|
628
|
-
**For HIGH/CRITICAL risk agents:**
|
|
629
|
-
✅ Deprecation recommended instead of deletion
|
|
630
|
-
✅ Migration path provided
|
|
631
|
-
✅ Users notified of deprecation
|
|
632
|
-
|
|
633
|
-
---
|
|
634
|
-
|
|
635
|
-
## COMPLETION
|
|
636
|
-
|
|
637
|
-
```
|
|
638
|
-
"Delete Agent workflow complete.
|
|
639
|
-
|
|
640
|
-
RESULT: {SUCCESS / CANCELLED / FAILED}
|
|
641
|
-
|
|
642
|
-
{if SUCCESS:}
|
|
643
|
-
Agent '{agent_name}' has been deleted.
|
|
644
|
-
Backup: {backup_path}
|
|
645
|
-
Audit: {audit_path}
|
|
646
|
-
|
|
647
|
-
{if CANCELLED:}
|
|
648
|
-
No changes made.
|
|
649
|
-
|
|
650
|
-
{if FAILED:}
|
|
651
|
-
Error: {error_message}
|
|
652
|
-
Agent NOT deleted.
|
|
653
|
-
Rollback successful.
|
|
654
|
-
|
|
655
|
-
Session summary: {output_folder}/delete-agent-{agent_name}-{timestamp}.md
|
|
656
|
-
"
|
|
657
|
-
```
|
|
1
|
+
# BYAN Delete Agent Workflow
|
|
2
|
+
|
|
3
|
+
**Workflow:** Safe Agent Deletion with Backup & Consequences Warning
|
|
4
|
+
**Duration:** 5 minutes
|
|
5
|
+
**Methodology:** Mantra #39 (Consequences) + Safety First
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## OVERVIEW
|
|
10
|
+
|
|
11
|
+
Delete Agent workflow safely removes agents with:
|
|
12
|
+
- **Mandatory backup** before deletion
|
|
13
|
+
- **Consequences evaluation** (Mantra #39)
|
|
14
|
+
- **Explicit confirmation** required
|
|
15
|
+
- **Dependency checking**
|
|
16
|
+
- **Rollback capability**
|
|
17
|
+
|
|
18
|
+
**Key Principle:**
|
|
19
|
+
> "Deletion is permanent. Evaluate consequences, backup everything, confirm explicitly."
|
|
20
|
+
|
|
21
|
+
**Mantras Applied:**
|
|
22
|
+
- Mantra #39: Évaluation des Conséquences (PRIMARY)
|
|
23
|
+
- Mantra IA-1: Trust But Verify
|
|
24
|
+
- RG-DEL-001: Confirmation explicite
|
|
25
|
+
- RG-DEL-002: Backup obligatoire
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## SAFETY LEVELS
|
|
30
|
+
|
|
31
|
+
### 🟢 LOW RISK
|
|
32
|
+
- Agent status: draft
|
|
33
|
+
- Never deployed
|
|
34
|
+
- No dependencies
|
|
35
|
+
- No usage history
|
|
36
|
+
|
|
37
|
+
→ Simple deletion with backup
|
|
38
|
+
|
|
39
|
+
### 🟡 MEDIUM RISK
|
|
40
|
+
- Agent status: validated
|
|
41
|
+
- Not deployed but tested
|
|
42
|
+
- Some documentation references
|
|
43
|
+
|
|
44
|
+
→ Requires confirmation + backup
|
|
45
|
+
|
|
46
|
+
### 🔴 HIGH RISK
|
|
47
|
+
- Agent status: deployed
|
|
48
|
+
- Actively used in workflows
|
|
49
|
+
- Referenced by other agents
|
|
50
|
+
- Has usage history
|
|
51
|
+
|
|
52
|
+
→ Requires deprecation period, not immediate deletion
|
|
53
|
+
|
|
54
|
+
### 🔥 CRITICAL RISK
|
|
55
|
+
- Agent status: deployed
|
|
56
|
+
- Core/critical agent
|
|
57
|
+
- Multiple dependencies
|
|
58
|
+
- High usage frequency
|
|
59
|
+
|
|
60
|
+
→ **CANNOT DELETE** - Deprecation and migration required
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## WORKFLOW STEPS
|
|
65
|
+
|
|
66
|
+
### Step 1: Select Agent to Delete
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
"⚠️ AGENT DELETION - PERMANENT ACTION
|
|
70
|
+
|
|
71
|
+
Which agent do you want to delete?
|
|
72
|
+
|
|
73
|
+
Available agents:
|
|
74
|
+
1. {agent_1} - [{status}] - {usage_info}
|
|
75
|
+
2. {agent_2} - [{status}] - {usage_info}
|
|
76
|
+
3. {agent_3} - [{status}] - {usage_info}
|
|
77
|
+
...
|
|
78
|
+
|
|
79
|
+
Agent number or name (or 'cancel' to exit): ____
|
|
80
|
+
"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Load agent and analyze:**
|
|
84
|
+
```python
|
|
85
|
+
agent_spec = AgentSpec.load(agent_id_or_name)
|
|
86
|
+
context = ProjectContext.load(agent_spec.context_id)
|
|
87
|
+
|
|
88
|
+
# Analyze risk
|
|
89
|
+
risk_level = analyze_deletion_risk(agent_spec)
|
|
90
|
+
dependencies = find_dependencies(agent_spec)
|
|
91
|
+
usage_stats = get_usage_stats(agent_spec)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Step 2: Display Agent Info & Risk Assessment
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
"════════════════════════════════════════════════════
|
|
100
|
+
AGENT DELETION ANALYSIS
|
|
101
|
+
════════════════════════════════════════════════════
|
|
102
|
+
|
|
103
|
+
AGENT INFORMATION:
|
|
104
|
+
Name: {agent_name}
|
|
105
|
+
Role: {role}
|
|
106
|
+
Status: {status}
|
|
107
|
+
Created: {created_at}
|
|
108
|
+
Last Modified: {updated_at}
|
|
109
|
+
Last Used: {last_used}
|
|
110
|
+
|
|
111
|
+
USAGE STATISTICS:
|
|
112
|
+
Total Invocations: {invocation_count}
|
|
113
|
+
Active Users: {user_count}
|
|
114
|
+
Referenced In: {reference_count} files
|
|
115
|
+
Dependencies: {dependency_count}
|
|
116
|
+
|
|
117
|
+
RISK ASSESSMENT: {risk_level}
|
|
118
|
+
|
|
119
|
+
{if LOW RISK 🟢:}
|
|
120
|
+
This agent can be safely deleted.
|
|
121
|
+
- Status: draft
|
|
122
|
+
- No active usage
|
|
123
|
+
- No dependencies detected
|
|
124
|
+
|
|
125
|
+
{if MEDIUM RISK 🟡:}
|
|
126
|
+
This agent has some references.
|
|
127
|
+
- Status: validated
|
|
128
|
+
- Referenced in {n} places
|
|
129
|
+
- Deletion will break: {list_affected}
|
|
130
|
+
|
|
131
|
+
{if HIGH RISK 🔴:}
|
|
132
|
+
This agent is actively used!
|
|
133
|
+
- Status: deployed
|
|
134
|
+
- {n} active users
|
|
135
|
+
- {n} dependencies
|
|
136
|
+
- Immediate deletion NOT RECOMMENDED
|
|
137
|
+
|
|
138
|
+
{if CRITICAL RISK 🔥:}
|
|
139
|
+
⛔ DELETION BLOCKED - This is a critical agent!
|
|
140
|
+
- Core system component
|
|
141
|
+
- {n} critical dependencies
|
|
142
|
+
- Cannot delete without migration plan
|
|
143
|
+
|
|
144
|
+
════════════════════════════════════════════════════
|
|
145
|
+
"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### Step 3: Consequences Evaluation (Mantra #39)
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
"CONSEQUENCES OF DELETING '{agent_name}':
|
|
154
|
+
|
|
155
|
+
1. 📊 SCOPE:
|
|
156
|
+
- Agent will be completely removed
|
|
157
|
+
- All configurations lost
|
|
158
|
+
- History lost (unless backed up)
|
|
159
|
+
Impact: {High/Medium/Low}
|
|
160
|
+
|
|
161
|
+
2. 💾 DATA:
|
|
162
|
+
- AgentSpec record deleted
|
|
163
|
+
- AgentFile(s) deleted
|
|
164
|
+
- Database entries removed
|
|
165
|
+
Impact: {High/Medium/Low}
|
|
166
|
+
|
|
167
|
+
3. 🔧 CODE:
|
|
168
|
+
- References to this agent will break
|
|
169
|
+
- Files affected: {list}
|
|
170
|
+
Impact: {High/Medium/Low}
|
|
171
|
+
|
|
172
|
+
4. 👥 TEAM:
|
|
173
|
+
- Users actively using this agent: {count}
|
|
174
|
+
- Team members to notify: {list}
|
|
175
|
+
Impact: {High/Medium/Low}
|
|
176
|
+
|
|
177
|
+
5. 🎯 CLIENTS:
|
|
178
|
+
- User workflows affected: {workflows}
|
|
179
|
+
- Breaking change: {yes/no}
|
|
180
|
+
Impact: {High/Medium/Low}
|
|
181
|
+
|
|
182
|
+
6. ⚖️ LEGAL:
|
|
183
|
+
- Compliance impact: {none/review required}
|
|
184
|
+
Impact: {High/Medium/Low}
|
|
185
|
+
|
|
186
|
+
7. 🚀 OPERATIONS:
|
|
187
|
+
- Active processes using agent: {count}
|
|
188
|
+
- Immediate impact: {yes/no}
|
|
189
|
+
Impact: {High/Medium/Low}
|
|
190
|
+
|
|
191
|
+
8. 🔗 DEPENDENCIES:
|
|
192
|
+
- Agents depending on this one: {list}
|
|
193
|
+
- External systems affected: {list}
|
|
194
|
+
Impact: {High/Medium/Low}
|
|
195
|
+
|
|
196
|
+
9. ⏱️ TIME:
|
|
197
|
+
- Deletion time: Immediate
|
|
198
|
+
- Recovery time if mistake: {estimate}
|
|
199
|
+
- Team notification time: {estimate}
|
|
200
|
+
Impact: {High/Medium/Low}
|
|
201
|
+
|
|
202
|
+
10. 🔄 ALTERNATIVES:
|
|
203
|
+
- Deprecate instead of delete: {recommended/not needed}
|
|
204
|
+
- Archive and keep backup: {always}
|
|
205
|
+
- Migrate to replacement agent: {needed/not needed}
|
|
206
|
+
|
|
207
|
+
OVERALL RISK: {risk_level}
|
|
208
|
+
|
|
209
|
+
════════════════════════════════════════════════════
|
|
210
|
+
"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
### Step 4: Dependencies Check
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
"DEPENDENCY ANALYSIS:
|
|
219
|
+
|
|
220
|
+
{if no dependencies:}
|
|
221
|
+
✅ No dependencies found. Safe to delete.
|
|
222
|
+
|
|
223
|
+
{if dependencies exist:}
|
|
224
|
+
⚠️ Dependencies detected:
|
|
225
|
+
|
|
226
|
+
FILES REFERENCING THIS AGENT:
|
|
227
|
+
1. {file_1}:{line} - {context}
|
|
228
|
+
2. {file_2}:{line} - {context}
|
|
229
|
+
...
|
|
230
|
+
|
|
231
|
+
AGENTS DEPENDING ON THIS ONE:
|
|
232
|
+
- {dependent_agent_1}: {reason}
|
|
233
|
+
- {dependent_agent_2}: {reason}
|
|
234
|
+
|
|
235
|
+
WORKFLOWS USING THIS AGENT:
|
|
236
|
+
- {workflow_1}
|
|
237
|
+
- {workflow_2}
|
|
238
|
+
|
|
239
|
+
BREAKING IMPACT:
|
|
240
|
+
- {impact_summary}
|
|
241
|
+
|
|
242
|
+
RECOMMENDATION:
|
|
243
|
+
{if HIGH/CRITICAL:}
|
|
244
|
+
🛑 DO NOT DELETE immediately.
|
|
245
|
+
1. Create replacement agent first
|
|
246
|
+
2. Migrate all dependencies
|
|
247
|
+
3. Deprecate this agent (30 day notice)
|
|
248
|
+
4. Delete after migration complete
|
|
249
|
+
|
|
250
|
+
{if MEDIUM:}
|
|
251
|
+
⚠️ Fix dependencies before deleting:
|
|
252
|
+
1. Update all referencing files
|
|
253
|
+
2. Notify users
|
|
254
|
+
3. Then proceed with deletion
|
|
255
|
+
|
|
256
|
+
{if LOW:}
|
|
257
|
+
✅ Safe to delete with backup
|
|
258
|
+
"
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
### Step 5: Backup Creation (MANDATORY - RG-DEL-002)
|
|
264
|
+
|
|
265
|
+
```
|
|
266
|
+
"Creating backup before deletion...
|
|
267
|
+
|
|
268
|
+
BACKUP STRATEGY:
|
|
269
|
+
1. Export AgentSpec to YAML
|
|
270
|
+
2. Save agent files to archive
|
|
271
|
+
3. Capture full history/metadata
|
|
272
|
+
4. Store in safe location
|
|
273
|
+
|
|
274
|
+
[▓▓▓▓▓▓▓▓▓▓] 100% - Backup complete
|
|
275
|
+
|
|
276
|
+
BACKUP CREATED:
|
|
277
|
+
Location: {backup_path}
|
|
278
|
+
Format: .tar.gz (compressed)
|
|
279
|
+
Size: {size}
|
|
280
|
+
Contains:
|
|
281
|
+
- agent-spec.yaml
|
|
282
|
+
- agent-files/
|
|
283
|
+
- metadata.json
|
|
284
|
+
- usage-history.log
|
|
285
|
+
|
|
286
|
+
Backup validated: ✅
|
|
287
|
+
|
|
288
|
+
To restore this agent later:
|
|
289
|
+
byan restore {backup_path}
|
|
290
|
+
|
|
291
|
+
════════════════════════════════════════════════════
|
|
292
|
+
"
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Backup structure:**
|
|
296
|
+
```
|
|
297
|
+
backup-{agent_name}-{timestamp}.tar.gz
|
|
298
|
+
├── agent-spec.yaml # Full AgentSpec export
|
|
299
|
+
├── agent-files/
|
|
300
|
+
│ ├── copilot.md # Generated files
|
|
301
|
+
│ ├── vscode.md
|
|
302
|
+
│ └── claude.md
|
|
303
|
+
├── metadata.json # Timestamps, user, reason
|
|
304
|
+
├── usage-history.log # Usage statistics
|
|
305
|
+
└── dependencies.json # Captured dependencies
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
### Step 6: Final Confirmation (RG-DEL-001)
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
"════════════════════════════════════════════════════
|
|
314
|
+
⚠️ FINAL CONFIRMATION REQUIRED
|
|
315
|
+
════════════════════════════════════════════════════
|
|
316
|
+
|
|
317
|
+
You are about to PERMANENTLY DELETE:
|
|
318
|
+
Agent: {agent_name}
|
|
319
|
+
Role: {role}
|
|
320
|
+
Status: {status}
|
|
321
|
+
|
|
322
|
+
This action:
|
|
323
|
+
❌ CANNOT be undone (except from backup)
|
|
324
|
+
❌ Will break {n} references
|
|
325
|
+
❌ Will affect {n} users
|
|
326
|
+
✅ Backup created at: {backup_path}
|
|
327
|
+
|
|
328
|
+
RISK LEVEL: {risk_level}
|
|
329
|
+
|
|
330
|
+
To confirm deletion, type the agent name exactly: '{agent_name}'
|
|
331
|
+
|
|
332
|
+
Confirmation: ____
|
|
333
|
+
|
|
334
|
+
(or type 'cancel' to abort)
|
|
335
|
+
════════════════════════════════════════════════════
|
|
336
|
+
"
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Validation:**
|
|
340
|
+
```python
|
|
341
|
+
def confirm_deletion(user_input, agent_name):
|
|
342
|
+
if user_input.lower() == 'cancel':
|
|
343
|
+
return "CANCELLED"
|
|
344
|
+
|
|
345
|
+
if user_input == agent_name: # Exact match required
|
|
346
|
+
return "CONFIRMED"
|
|
347
|
+
|
|
348
|
+
return "INVALID" # Must retype
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**If confirmation fails:**
|
|
352
|
+
```
|
|
353
|
+
"❌ Confirmation failed. Agent name must match exactly.
|
|
354
|
+
|
|
355
|
+
Expected: '{agent_name}'
|
|
356
|
+
You typed: '{user_input}'
|
|
357
|
+
|
|
358
|
+
Try again or type 'cancel': ____
|
|
359
|
+
"
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
### Step 7: Execute Deletion
|
|
365
|
+
|
|
366
|
+
**If confirmed:**
|
|
367
|
+
```python
|
|
368
|
+
def delete_agent(agent_spec, backup):
|
|
369
|
+
try:
|
|
370
|
+
# 1. Delete agent files
|
|
371
|
+
agent_files = AgentFile.find_by_agent(agent_spec.id)
|
|
372
|
+
for file in agent_files:
|
|
373
|
+
file.delete()
|
|
374
|
+
log_deletion(file, backup)
|
|
375
|
+
|
|
376
|
+
# 2. Delete AgentSpec
|
|
377
|
+
agent_spec.delete()
|
|
378
|
+
log_deletion(agent_spec, backup)
|
|
379
|
+
|
|
380
|
+
# 3. Update project context (remove agent reference)
|
|
381
|
+
context = ProjectContext.load(agent_spec.context_id)
|
|
382
|
+
context.remove_agent_reference(agent_spec.id)
|
|
383
|
+
context.save()
|
|
384
|
+
|
|
385
|
+
# 4. Create deletion record (audit trail)
|
|
386
|
+
DeletionRecord.create(
|
|
387
|
+
agent_name=agent_spec.agent_name,
|
|
388
|
+
deleted_by=current_user,
|
|
389
|
+
deleted_at=now(),
|
|
390
|
+
backup_location=backup.path,
|
|
391
|
+
reason=deletion_reason,
|
|
392
|
+
consequences=consequences_evaluated
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
return DeleteSuccess(backup=backup)
|
|
396
|
+
|
|
397
|
+
except Exception as e:
|
|
398
|
+
# Rollback if anything fails
|
|
399
|
+
rollback_deletion(backup)
|
|
400
|
+
return DeleteFailed(error=e)
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**Progress:**
|
|
404
|
+
```
|
|
405
|
+
"Deleting agent...
|
|
406
|
+
|
|
407
|
+
[▓▓▓░░░░░░░] 30% - Removing agent files...
|
|
408
|
+
[▓▓▓▓▓▓░░░░] 60% - Deleting AgentSpec...
|
|
409
|
+
[▓▓▓▓▓▓▓▓░░] 80% - Updating project context...
|
|
410
|
+
[▓▓▓▓▓▓▓▓▓▓] 100% - Creating audit record...
|
|
411
|
+
|
|
412
|
+
✅ Deletion complete.
|
|
413
|
+
"
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
### Step 8: Post-Deletion Summary
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
"════════════════════════════════════════════════════
|
|
422
|
+
DELETION COMPLETE
|
|
423
|
+
════════════════════════════════════════════════════
|
|
424
|
+
|
|
425
|
+
Agent '{agent_name}' has been permanently deleted.
|
|
426
|
+
|
|
427
|
+
WHAT WAS DELETED:
|
|
428
|
+
❌ AgentSpec record
|
|
429
|
+
❌ {n} agent file(s)
|
|
430
|
+
❌ Agent configurations
|
|
431
|
+
❌ Menu references
|
|
432
|
+
|
|
433
|
+
WHAT WAS PRESERVED:
|
|
434
|
+
✅ Full backup: {backup_path}
|
|
435
|
+
✅ Deletion audit record
|
|
436
|
+
✅ Usage history (in backup)
|
|
437
|
+
|
|
438
|
+
NEXT STEPS:
|
|
439
|
+
|
|
440
|
+
{if dependencies existed:}
|
|
441
|
+
⚠️ ACTION REQUIRED:
|
|
442
|
+
1. Fix broken references:
|
|
443
|
+
{list_files_to_fix}
|
|
444
|
+
2. Notify affected users:
|
|
445
|
+
{list_users}
|
|
446
|
+
3. Update documentation
|
|
447
|
+
|
|
448
|
+
{if no dependencies:}
|
|
449
|
+
✅ No further action needed.
|
|
450
|
+
|
|
451
|
+
RESTORATION:
|
|
452
|
+
To restore this agent from backup:
|
|
453
|
+
byan restore {backup_path}
|
|
454
|
+
|
|
455
|
+
Backup will be kept for {retention_period} days.
|
|
456
|
+
|
|
457
|
+
AUDIT TRAIL:
|
|
458
|
+
Deletion recorded in: {audit_log_path}
|
|
459
|
+
Deleted by: {user}
|
|
460
|
+
Timestamp: {timestamp}
|
|
461
|
+
Reason: {reason}
|
|
462
|
+
|
|
463
|
+
════════════════════════════════════════════════════
|
|
464
|
+
"
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## ALTERNATIVE: DEPRECATION (Recommended for Deployed Agents)
|
|
470
|
+
|
|
471
|
+
**If agent is HIGH or CRITICAL risk:**
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
"🛑 DELETION NOT RECOMMENDED
|
|
475
|
+
|
|
476
|
+
This agent is actively used. Instead of deleting immediately,
|
|
477
|
+
I recommend DEPRECATION:
|
|
478
|
+
|
|
479
|
+
DEPRECATION WORKFLOW:
|
|
480
|
+
1. Mark agent as 'deprecated' (status change)
|
|
481
|
+
2. Add deprecation notice (30-60 day warning)
|
|
482
|
+
3. Notify all users
|
|
483
|
+
4. Provide migration path to replacement
|
|
484
|
+
5. Monitor usage decline
|
|
485
|
+
6. Delete after usage reaches zero
|
|
486
|
+
|
|
487
|
+
Start deprecation workflow? (yes/cancel): ____
|
|
488
|
+
"
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Deprecation process:**
|
|
492
|
+
```python
|
|
493
|
+
def deprecate_agent(agent_spec, replacement=None):
|
|
494
|
+
# 1. Change status
|
|
495
|
+
agent_spec.status = "deprecated"
|
|
496
|
+
agent_spec.deprecation_date = now()
|
|
497
|
+
agent_spec.deprecation_deadline = now() + timedelta(days=30)
|
|
498
|
+
|
|
499
|
+
if replacement:
|
|
500
|
+
agent_spec.replacement_agent = replacement.id
|
|
501
|
+
|
|
502
|
+
# 2. Add deprecation warning to agent
|
|
503
|
+
agent_spec.add_deprecation_notice(
|
|
504
|
+
message=f"This agent is deprecated and will be removed on {deadline}",
|
|
505
|
+
replacement=replacement.agent_name if replacement else None,
|
|
506
|
+
migration_guide=generate_migration_guide(agent_spec, replacement)
|
|
507
|
+
)
|
|
508
|
+
|
|
509
|
+
# 3. Notify users
|
|
510
|
+
notify_users(
|
|
511
|
+
agent=agent_spec,
|
|
512
|
+
message="Agent deprecated - action required",
|
|
513
|
+
deadline=agent_spec.deprecation_deadline
|
|
514
|
+
)
|
|
515
|
+
|
|
516
|
+
agent_spec.save()
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## RESTORE FROM BACKUP
|
|
522
|
+
|
|
523
|
+
**If user made a mistake:**
|
|
524
|
+
|
|
525
|
+
```
|
|
526
|
+
"Restore agent from backup:
|
|
527
|
+
|
|
528
|
+
byan restore {backup_path}
|
|
529
|
+
|
|
530
|
+
This will:
|
|
531
|
+
✅ Recreate AgentSpec
|
|
532
|
+
✅ Restore all agent files
|
|
533
|
+
✅ Restore configurations
|
|
534
|
+
✅ Preserve original timestamps
|
|
535
|
+
|
|
536
|
+
Note: Any changes made after backup will be lost.
|
|
537
|
+
"
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
```python
|
|
541
|
+
def restore_agent(backup_path):
|
|
542
|
+
backup = Backup.load(backup_path)
|
|
543
|
+
|
|
544
|
+
# 1. Validate backup integrity
|
|
545
|
+
if not backup.is_valid():
|
|
546
|
+
raise BackupCorruptedError()
|
|
547
|
+
|
|
548
|
+
# 2. Check if agent name conflicts
|
|
549
|
+
if AgentSpec.exists(backup.agent_name):
|
|
550
|
+
raise AgentAlreadyExistsError()
|
|
551
|
+
|
|
552
|
+
# 3. Restore AgentSpec
|
|
553
|
+
agent_spec = AgentSpec.from_backup(backup)
|
|
554
|
+
agent_spec.save()
|
|
555
|
+
|
|
556
|
+
# 4. Restore agent files
|
|
557
|
+
for file_data in backup.files:
|
|
558
|
+
agent_file = AgentFile.from_backup(file_data)
|
|
559
|
+
agent_file.save()
|
|
560
|
+
|
|
561
|
+
# 5. Update project context
|
|
562
|
+
context = ProjectContext.load(agent_spec.context_id)
|
|
563
|
+
context.add_agent_reference(agent_spec.id)
|
|
564
|
+
context.save()
|
|
565
|
+
|
|
566
|
+
return RestoreSuccess(agent_spec)
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
|
|
571
|
+
## ANTI-PATTERNS
|
|
572
|
+
|
|
573
|
+
**NEVER do these:**
|
|
574
|
+
|
|
575
|
+
❌ Delete without backup
|
|
576
|
+
❌ Delete deployed agents immediately
|
|
577
|
+
❌ Delete without checking dependencies
|
|
578
|
+
❌ Delete without team notification
|
|
579
|
+
❌ Delete without explicit confirmation
|
|
580
|
+
❌ Delete without consequence evaluation
|
|
581
|
+
❌ Delete without audit trail
|
|
582
|
+
|
|
583
|
+
**ALWAYS do these:**
|
|
584
|
+
|
|
585
|
+
✅ Create backup first (RG-DEL-002)
|
|
586
|
+
✅ Evaluate consequences (Mantra #39)
|
|
587
|
+
✅ Check dependencies thoroughly
|
|
588
|
+
✅ Require explicit confirmation (RG-DEL-001)
|
|
589
|
+
✅ Notify affected users
|
|
590
|
+
✅ Prefer deprecation for deployed agents
|
|
591
|
+
✅ Keep audit trail
|
|
592
|
+
✅ Test restore procedure
|
|
593
|
+
|
|
594
|
+
---
|
|
595
|
+
|
|
596
|
+
## CANCELLATION
|
|
597
|
+
|
|
598
|
+
**At any point, user can cancel:**
|
|
599
|
+
|
|
600
|
+
```
|
|
601
|
+
"Deletion cancelled.
|
|
602
|
+
|
|
603
|
+
No changes were made. Agent '{agent_name}' is still active.
|
|
604
|
+
|
|
605
|
+
{if backup was created:}
|
|
606
|
+
Note: Backup was created but not used.
|
|
607
|
+
Location: {backup_path}
|
|
608
|
+
You can delete this backup manually if not needed.
|
|
609
|
+
|
|
610
|
+
Return to menu? (yes): ____
|
|
611
|
+
"
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
---
|
|
615
|
+
|
|
616
|
+
## SUCCESS CRITERIA
|
|
617
|
+
|
|
618
|
+
✅ Risk level assessed
|
|
619
|
+
✅ Dependencies checked
|
|
620
|
+
✅ Consequences evaluated (10 dimensions)
|
|
621
|
+
✅ Backup created and validated (RG-DEL-002)
|
|
622
|
+
✅ Explicit confirmation obtained (RG-DEL-001)
|
|
623
|
+
✅ Agent deleted successfully
|
|
624
|
+
✅ Audit trail created
|
|
625
|
+
✅ User notified of next steps
|
|
626
|
+
✅ Restore instructions provided
|
|
627
|
+
|
|
628
|
+
**For HIGH/CRITICAL risk agents:**
|
|
629
|
+
✅ Deprecation recommended instead of deletion
|
|
630
|
+
✅ Migration path provided
|
|
631
|
+
✅ Users notified of deprecation
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
## COMPLETION
|
|
636
|
+
|
|
637
|
+
```
|
|
638
|
+
"Delete Agent workflow complete.
|
|
639
|
+
|
|
640
|
+
RESULT: {SUCCESS / CANCELLED / FAILED}
|
|
641
|
+
|
|
642
|
+
{if SUCCESS:}
|
|
643
|
+
Agent '{agent_name}' has been deleted.
|
|
644
|
+
Backup: {backup_path}
|
|
645
|
+
Audit: {audit_path}
|
|
646
|
+
|
|
647
|
+
{if CANCELLED:}
|
|
648
|
+
No changes made.
|
|
649
|
+
|
|
650
|
+
{if FAILED:}
|
|
651
|
+
Error: {error_message}
|
|
652
|
+
Agent NOT deleted.
|
|
653
|
+
Rollback successful.
|
|
654
|
+
|
|
655
|
+
Session summary: {output_folder}/delete-agent-{agent_name}-{timestamp}.md
|
|
656
|
+
"
|
|
657
|
+
```
|