claude-flow-novice 2.10.7 → 2.10.8
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/.claude/commands/cfn/CFN_LOOP_TASK_MODE.md +94 -0
- package/.claude/commands/cfn/cfn-loop.md +4 -3
- package/claude-assets/commands/cfn/CFN_LOOP_TASK_MODE.md +94 -0
- package/claude-assets/commands/cfn/cfn-loop.md +4 -3
- package/dist/agents/agent-loader.js +133 -467
- package/dist/agents/agent-loader.js.map +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,23 @@ Task Mode: Main Chat spawns coordinator and agents via Task() tool with full con
|
|
|
15
15
|
| **Provider** | All Anthropic | CLI uses Z.ai routing |
|
|
16
16
|
| **Cost** | ~$0.150/iteration | ~$0.054/iteration (64% savings) |
|
|
17
17
|
| **Use Case** | Debugging, prototyping, learning | Production, cost optimization |
|
|
18
|
+
| **ACE Reflection** | Optional via `--ace-reflect` flag | Always enabled |
|
|
19
|
+
|
|
20
|
+
### ACE Reflection Flag
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Enable ACE reflection after each sprint (captures lessons learned)
|
|
24
|
+
/cfn-loop "Task description" --spawn-mode=task --ace-reflect
|
|
25
|
+
|
|
26
|
+
# Without ACE reflection (default for backwards compatibility)
|
|
27
|
+
/cfn-loop "Task description" --spawn-mode=task
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**When to use `--ace-reflect`:**
|
|
31
|
+
- Long-running epics (3+ sprints) where learning accumulates
|
|
32
|
+
- Complex tasks with multiple iterations
|
|
33
|
+
- Teams building organizational knowledge
|
|
34
|
+
- Post-mortem analysis and continuous improvement
|
|
18
35
|
|
|
19
36
|
---
|
|
20
37
|
|
|
@@ -144,9 +161,30 @@ Iterations: Loop 3: ${L3}, Loop 2: ${L2} | Decision: PROCEED
|
|
|
144
161
|
EOF
|
|
145
162
|
```
|
|
146
163
|
|
|
164
|
+
### 5. ACE Reflection (Optional - If `--ace-reflect` flag enabled)
|
|
165
|
+
```bash
|
|
166
|
+
# Only run if --ace-reflect flag was passed to /cfn-loop command
|
|
167
|
+
if [[ "$ACE_REFLECT_ENABLED" == "true" ]]; then
|
|
168
|
+
echo "📊 Capturing ACE reflection..."
|
|
169
|
+
./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
|
|
170
|
+
--task-id "${TASK_ID}" \
|
|
171
|
+
--sprint-id "${SPRINT_NUM}" \
|
|
172
|
+
--consensus "${CONSENSUS}" \
|
|
173
|
+
--iterations-loop3 "${L3}" \
|
|
174
|
+
--iterations-loop2 "${L2}" \
|
|
175
|
+
--deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
|
|
176
|
+
|
|
177
|
+
# Output: Stores reflection in SQLite with tags, confidence, priority
|
|
178
|
+
# Categories: PATTERN, STRAT, ANTI, EDGE
|
|
179
|
+
# Automatic tag extraction and deduplication
|
|
180
|
+
echo "✅ ACE reflection captured: $(sqlite3 .claude/cfn-data/cfn-loop.db 'SELECT COUNT(*) FROM context_reflections WHERE task_id = \"'${TASK_ID}'\"') bullets"
|
|
181
|
+
fi
|
|
182
|
+
```
|
|
183
|
+
|
|
147
184
|
**Checklist:**
|
|
148
185
|
- [ ] Consensus ≥ threshold | [ ] Product Owner approved | [ ] Deliverables verified
|
|
149
186
|
- [ ] Tests passing | [ ] Git committed | [ ] Git pushed | [ ] Summary generated
|
|
187
|
+
- [ ] ACE reflection captured (if `--ace-reflect` enabled)
|
|
150
188
|
|
|
151
189
|
---
|
|
152
190
|
|
|
@@ -341,12 +379,68 @@ Complex/Enterprise (>5 files, >500 LOC): +code-analyzer
|
|
|
341
379
|
|
|
342
380
|
---
|
|
343
381
|
|
|
382
|
+
## ACE System Integration
|
|
383
|
+
|
|
384
|
+
### Reflection After Sprint
|
|
385
|
+
After each sprint completion, Task Mode should capture lessons learned:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Automatic reflection capture (called after git push)
|
|
389
|
+
./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
|
|
390
|
+
--task-id "${TASK_ID}" \
|
|
391
|
+
--sprint-id "${SPRINT_NUM}" \
|
|
392
|
+
--consensus "${CONSENSUS}" \
|
|
393
|
+
--iterations-loop3 "${L3}" \
|
|
394
|
+
--iterations-loop2 "${L2}" \
|
|
395
|
+
--deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**What Gets Captured:**
|
|
399
|
+
- Patterns that worked well (consensus ≥0.90, low iterations)
|
|
400
|
+
- Anti-patterns that caused issues (high iterations, deliverable failures)
|
|
401
|
+
- Strategy patterns (agent selection, validator scaling effectiveness)
|
|
402
|
+
- Edge cases (timeout scenarios, race conditions, blocking issues)
|
|
403
|
+
|
|
404
|
+
**Storage:**
|
|
405
|
+
- SQLite database: `.claude/cfn-data/cfn-loop.db`
|
|
406
|
+
- Table: `context_reflections`
|
|
407
|
+
- Automatic tagging, deduplication, confidence scoring
|
|
408
|
+
|
|
409
|
+
**Benefits:**
|
|
410
|
+
- Future sprints learn from past mistakes
|
|
411
|
+
- Adaptive validator scaling improves over time
|
|
412
|
+
- Pattern recognition across projects
|
|
413
|
+
- Knowledge accumulation (not lost between sessions)
|
|
414
|
+
|
|
415
|
+
### Optional: Context Injection (Future Enhancement)
|
|
416
|
+
Before spawning agents, inject relevant lessons:
|
|
417
|
+
```bash
|
|
418
|
+
# Not yet implemented in Task Mode, but available:
|
|
419
|
+
./.claude/skills/cfn-ace-system/invoke-context-inject.sh \
|
|
420
|
+
--task "${TASK_DESCRIPTION}" \
|
|
421
|
+
--phase "${PHASE_NAME}" \
|
|
422
|
+
--tags "validation,consensus,deliverables"
|
|
423
|
+
# Returns: Top N relevant bullets from past reflections
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Optional: Context Curation (Periodic Maintenance)
|
|
427
|
+
Merge and deduplicate reflection data:
|
|
428
|
+
```bash
|
|
429
|
+
# Run monthly or after major epics:
|
|
430
|
+
./.claude/skills/cfn-ace-system/invoke-context-curate.sh \
|
|
431
|
+
--confidence-threshold 0.85 \
|
|
432
|
+
--merge-similar-patterns
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
344
437
|
## Related Documentation
|
|
345
438
|
|
|
346
439
|
- **CFN Coordinator Parameters**: `.claude/commands/cfn/CFN_COORDINATOR_PARAMETERS.md`
|
|
347
440
|
- **Redis Coordination**: `.claude/skills/cfn-redis-coordination/SKILL.md`
|
|
348
441
|
- **Product Owner Decision**: `.claude/skills/cfn-product-owner-decision/SKILL.md`
|
|
349
442
|
- **Agent Output Standards**: `docs/AGENT_OUTPUT_STANDARDS.md`
|
|
443
|
+
- **ACE System**: `.claude/skills/cfn-ace-system/SKILL.md`
|
|
350
444
|
|
|
351
445
|
---
|
|
352
446
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: "Execute autonomous 3-loop self-correcting CFN workflow with automatic retry and consensus validation"
|
|
3
|
-
argument-hint: "<task description> [--phase=name] [--mode=mvp|standard|enterprise] [--spawn-mode=cli|task] [--max-loop2=10] [--max-loop3=10]"
|
|
3
|
+
argument-hint: "<task description> [--phase=name] [--mode=mvp|standard|enterprise] [--spawn-mode=cli|task] [--max-loop2=10] [--max-loop3=10] [--ace-reflect]"
|
|
4
4
|
allowed-tools: ["Task", "TodoWrite", "Read", "Write", "Edit", "Bash", "Glob", "Grep"]
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -38,10 +38,11 @@ LOOP 3: Primary Swarm Execution with subtask iterations
|
|
|
38
38
|
- `--phase=<name>`: Optional phase name for tracking
|
|
39
39
|
- `--mode=<mvp|standard|enterprise>`: Coordinator mode (default: standard)
|
|
40
40
|
- `--spawn-mode=<cli|task>`: Agent spawning method (default: cli)
|
|
41
|
-
- **cli**: Cost-optimized (95-98% savings), background execution, Redis monitoring
|
|
42
|
-
- **task**: Full visibility in Main Chat, direct spawning, debugging
|
|
41
|
+
- **cli**: Cost-optimized (95-98% savings), background execution, Redis monitoring, ACE always enabled
|
|
42
|
+
- **task**: Full visibility in Main Chat, direct spawning, debugging, ACE optional via flag
|
|
43
43
|
- `--max-loop2=<n>`: Max consensus iterations (default: 10)
|
|
44
44
|
- `--max-loop3=<n>`: Max primary swarm iterations (default: 10)
|
|
45
|
+
- `--ace-reflect`: Enable ACE reflection after each sprint (Task mode only, captures lessons learned)
|
|
45
46
|
|
|
46
47
|
## Coordinator Modes
|
|
47
48
|
|
|
@@ -15,6 +15,23 @@ Task Mode: Main Chat spawns coordinator and agents via Task() tool with full con
|
|
|
15
15
|
| **Provider** | All Anthropic | CLI uses Z.ai routing |
|
|
16
16
|
| **Cost** | ~$0.150/iteration | ~$0.054/iteration (64% savings) |
|
|
17
17
|
| **Use Case** | Debugging, prototyping, learning | Production, cost optimization |
|
|
18
|
+
| **ACE Reflection** | Optional via `--ace-reflect` flag | Always enabled |
|
|
19
|
+
|
|
20
|
+
### ACE Reflection Flag
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Enable ACE reflection after each sprint (captures lessons learned)
|
|
24
|
+
/cfn-loop "Task description" --spawn-mode=task --ace-reflect
|
|
25
|
+
|
|
26
|
+
# Without ACE reflection (default for backwards compatibility)
|
|
27
|
+
/cfn-loop "Task description" --spawn-mode=task
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**When to use `--ace-reflect`:**
|
|
31
|
+
- Long-running epics (3+ sprints) where learning accumulates
|
|
32
|
+
- Complex tasks with multiple iterations
|
|
33
|
+
- Teams building organizational knowledge
|
|
34
|
+
- Post-mortem analysis and continuous improvement
|
|
18
35
|
|
|
19
36
|
---
|
|
20
37
|
|
|
@@ -144,9 +161,30 @@ Iterations: Loop 3: ${L3}, Loop 2: ${L2} | Decision: PROCEED
|
|
|
144
161
|
EOF
|
|
145
162
|
```
|
|
146
163
|
|
|
164
|
+
### 5. ACE Reflection (Optional - If `--ace-reflect` flag enabled)
|
|
165
|
+
```bash
|
|
166
|
+
# Only run if --ace-reflect flag was passed to /cfn-loop command
|
|
167
|
+
if [[ "$ACE_REFLECT_ENABLED" == "true" ]]; then
|
|
168
|
+
echo "📊 Capturing ACE reflection..."
|
|
169
|
+
./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
|
|
170
|
+
--task-id "${TASK_ID}" \
|
|
171
|
+
--sprint-id "${SPRINT_NUM}" \
|
|
172
|
+
--consensus "${CONSENSUS}" \
|
|
173
|
+
--iterations-loop3 "${L3}" \
|
|
174
|
+
--iterations-loop2 "${L2}" \
|
|
175
|
+
--deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
|
|
176
|
+
|
|
177
|
+
# Output: Stores reflection in SQLite with tags, confidence, priority
|
|
178
|
+
# Categories: PATTERN, STRAT, ANTI, EDGE
|
|
179
|
+
# Automatic tag extraction and deduplication
|
|
180
|
+
echo "✅ ACE reflection captured: $(sqlite3 .claude/cfn-data/cfn-loop.db 'SELECT COUNT(*) FROM context_reflections WHERE task_id = \"'${TASK_ID}'\"') bullets"
|
|
181
|
+
fi
|
|
182
|
+
```
|
|
183
|
+
|
|
147
184
|
**Checklist:**
|
|
148
185
|
- [ ] Consensus ≥ threshold | [ ] Product Owner approved | [ ] Deliverables verified
|
|
149
186
|
- [ ] Tests passing | [ ] Git committed | [ ] Git pushed | [ ] Summary generated
|
|
187
|
+
- [ ] ACE reflection captured (if `--ace-reflect` enabled)
|
|
150
188
|
|
|
151
189
|
---
|
|
152
190
|
|
|
@@ -341,12 +379,68 @@ Complex/Enterprise (>5 files, >500 LOC): +code-analyzer
|
|
|
341
379
|
|
|
342
380
|
---
|
|
343
381
|
|
|
382
|
+
## ACE System Integration
|
|
383
|
+
|
|
384
|
+
### Reflection After Sprint
|
|
385
|
+
After each sprint completion, Task Mode should capture lessons learned:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
# Automatic reflection capture (called after git push)
|
|
389
|
+
./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
|
|
390
|
+
--task-id "${TASK_ID}" \
|
|
391
|
+
--sprint-id "${SPRINT_NUM}" \
|
|
392
|
+
--consensus "${CONSENSUS}" \
|
|
393
|
+
--iterations-loop3 "${L3}" \
|
|
394
|
+
--iterations-loop2 "${L2}" \
|
|
395
|
+
--deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**What Gets Captured:**
|
|
399
|
+
- Patterns that worked well (consensus ≥0.90, low iterations)
|
|
400
|
+
- Anti-patterns that caused issues (high iterations, deliverable failures)
|
|
401
|
+
- Strategy patterns (agent selection, validator scaling effectiveness)
|
|
402
|
+
- Edge cases (timeout scenarios, race conditions, blocking issues)
|
|
403
|
+
|
|
404
|
+
**Storage:**
|
|
405
|
+
- SQLite database: `.claude/cfn-data/cfn-loop.db`
|
|
406
|
+
- Table: `context_reflections`
|
|
407
|
+
- Automatic tagging, deduplication, confidence scoring
|
|
408
|
+
|
|
409
|
+
**Benefits:**
|
|
410
|
+
- Future sprints learn from past mistakes
|
|
411
|
+
- Adaptive validator scaling improves over time
|
|
412
|
+
- Pattern recognition across projects
|
|
413
|
+
- Knowledge accumulation (not lost between sessions)
|
|
414
|
+
|
|
415
|
+
### Optional: Context Injection (Future Enhancement)
|
|
416
|
+
Before spawning agents, inject relevant lessons:
|
|
417
|
+
```bash
|
|
418
|
+
# Not yet implemented in Task Mode, but available:
|
|
419
|
+
./.claude/skills/cfn-ace-system/invoke-context-inject.sh \
|
|
420
|
+
--task "${TASK_DESCRIPTION}" \
|
|
421
|
+
--phase "${PHASE_NAME}" \
|
|
422
|
+
--tags "validation,consensus,deliverables"
|
|
423
|
+
# Returns: Top N relevant bullets from past reflections
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Optional: Context Curation (Periodic Maintenance)
|
|
427
|
+
Merge and deduplicate reflection data:
|
|
428
|
+
```bash
|
|
429
|
+
# Run monthly or after major epics:
|
|
430
|
+
./.claude/skills/cfn-ace-system/invoke-context-curate.sh \
|
|
431
|
+
--confidence-threshold 0.85 \
|
|
432
|
+
--merge-similar-patterns
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
|
|
344
437
|
## Related Documentation
|
|
345
438
|
|
|
346
439
|
- **CFN Coordinator Parameters**: `.claude/commands/cfn/CFN_COORDINATOR_PARAMETERS.md`
|
|
347
440
|
- **Redis Coordination**: `.claude/skills/cfn-redis-coordination/SKILL.md`
|
|
348
441
|
- **Product Owner Decision**: `.claude/skills/cfn-product-owner-decision/SKILL.md`
|
|
349
442
|
- **Agent Output Standards**: `docs/AGENT_OUTPUT_STANDARDS.md`
|
|
443
|
+
- **ACE System**: `.claude/skills/cfn-ace-system/SKILL.md`
|
|
350
444
|
|
|
351
445
|
---
|
|
352
446
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: "Execute autonomous 3-loop self-correcting CFN workflow with automatic retry and consensus validation"
|
|
3
|
-
argument-hint: "<task description> [--phase=name] [--mode=mvp|standard|enterprise] [--spawn-mode=cli|task] [--max-loop2=10] [--max-loop3=10]"
|
|
3
|
+
argument-hint: "<task description> [--phase=name] [--mode=mvp|standard|enterprise] [--spawn-mode=cli|task] [--max-loop2=10] [--max-loop3=10] [--ace-reflect]"
|
|
4
4
|
allowed-tools: ["Task", "TodoWrite", "Read", "Write", "Edit", "Bash", "Glob", "Grep"]
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -38,10 +38,11 @@ LOOP 3: Primary Swarm Execution with subtask iterations
|
|
|
38
38
|
- `--phase=<name>`: Optional phase name for tracking
|
|
39
39
|
- `--mode=<mvp|standard|enterprise>`: Coordinator mode (default: standard)
|
|
40
40
|
- `--spawn-mode=<cli|task>`: Agent spawning method (default: cli)
|
|
41
|
-
- **cli**: Cost-optimized (95-98% savings), background execution, Redis monitoring
|
|
42
|
-
- **task**: Full visibility in Main Chat, direct spawning, debugging
|
|
41
|
+
- **cli**: Cost-optimized (95-98% savings), background execution, Redis monitoring, ACE always enabled
|
|
42
|
+
- **task**: Full visibility in Main Chat, direct spawning, debugging, ACE optional via flag
|
|
43
43
|
- `--max-loop2=<n>`: Max consensus iterations (default: 10)
|
|
44
44
|
- `--max-loop3=<n>`: Max primary swarm iterations (default: 10)
|
|
45
|
+
- `--ace-reflect`: Enable ACE reflection after each sprint (Task mode only, captures lessons learned)
|
|
45
46
|
|
|
46
47
|
## Coordinator Modes
|
|
47
48
|
|
|
@@ -1,145 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Dynamic Agent Loader - Reads agent definitions from .claude/agents/ directory
|
|
4
3
|
* Single source of truth for agent types in the system
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
12
|
-
function fulfilled(value) {
|
|
13
|
-
try {
|
|
14
|
-
step(generator.next(value));
|
|
15
|
-
} catch (e) {
|
|
16
|
-
reject(e);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function rejected(value) {
|
|
20
|
-
try {
|
|
21
|
-
step(generator["throw"](value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function step(result) {
|
|
27
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
28
|
-
}
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
33
|
-
var _ = {
|
|
34
|
-
label: 0,
|
|
35
|
-
sent: function() {
|
|
36
|
-
if (t[0] & 1) throw t[1];
|
|
37
|
-
return t[1];
|
|
38
|
-
},
|
|
39
|
-
trys: [],
|
|
40
|
-
ops: []
|
|
41
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
42
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
43
|
-
return this;
|
|
44
|
-
}), g;
|
|
45
|
-
function verb(n) {
|
|
46
|
-
return function(v) {
|
|
47
|
-
return step([
|
|
48
|
-
n,
|
|
49
|
-
v
|
|
50
|
-
]);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
-
if (y = 0, t) op = [
|
|
58
|
-
op[0] & 2,
|
|
59
|
-
t.value
|
|
60
|
-
];
|
|
61
|
-
switch(op[0]){
|
|
62
|
-
case 0:
|
|
63
|
-
case 1:
|
|
64
|
-
t = op;
|
|
65
|
-
break;
|
|
66
|
-
case 4:
|
|
67
|
-
_.label++;
|
|
68
|
-
return {
|
|
69
|
-
value: op[1],
|
|
70
|
-
done: false
|
|
71
|
-
};
|
|
72
|
-
case 5:
|
|
73
|
-
_.label++;
|
|
74
|
-
y = op[1];
|
|
75
|
-
op = [
|
|
76
|
-
0
|
|
77
|
-
];
|
|
78
|
-
continue;
|
|
79
|
-
case 7:
|
|
80
|
-
op = _.ops.pop();
|
|
81
|
-
_.trys.pop();
|
|
82
|
-
continue;
|
|
83
|
-
default:
|
|
84
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
85
|
-
_ = 0;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
89
|
-
_.label = op[1];
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
93
|
-
_.label = t[1];
|
|
94
|
-
t = op;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
if (t && _.label < t[2]) {
|
|
98
|
-
_.label = t[2];
|
|
99
|
-
_.ops.push(op);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
if (t[2]) _.ops.pop();
|
|
103
|
-
_.trys.pop();
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
op = body.call(thisArg, _);
|
|
107
|
-
} catch (e) {
|
|
108
|
-
op = [
|
|
109
|
-
6,
|
|
110
|
-
e
|
|
111
|
-
];
|
|
112
|
-
y = 0;
|
|
113
|
-
} finally{
|
|
114
|
-
f = t = 0;
|
|
115
|
-
}
|
|
116
|
-
if (op[0] & 5) throw op[1];
|
|
117
|
-
return {
|
|
118
|
-
value: op[0] ? op[1] : void 0,
|
|
119
|
-
done: true
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var __spreadArray = this && this.__spreadArray || function(to, from, pack) {
|
|
124
|
-
if (pack || arguments.length === 2) for(var i = 0, l = from.length, ar; i < l; i++){
|
|
125
|
-
if (ar || !(i in from)) {
|
|
126
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
127
|
-
ar[i] = from[i];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
131
|
-
};
|
|
132
|
-
Object.defineProperty(exports, "__esModule", {
|
|
133
|
-
value: true
|
|
134
|
-
});
|
|
135
|
-
exports.refreshAgents = exports.getAgentsByCategory = exports.isValidAgentType = exports.searchAgents = exports.getAgentCategories = exports.getAllAgents = exports.getAgent = exports.getAvailableAgentTypes = exports.agentLoader = exports.AgentLoader = void 0;
|
|
136
|
-
exports.resolveLegacyAgentType = resolveLegacyAgentType;
|
|
137
|
-
var node_fs_1 = require("node:fs");
|
|
138
|
-
var glob_1 = require("glob");
|
|
139
|
-
var node_path_1 = require("node:path");
|
|
140
|
-
var yaml_1 = require("yaml");
|
|
4
|
+
*/ import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
import { resolve, dirname } from 'node:path';
|
|
7
|
+
import { parse as parseYaml } from 'yaml';
|
|
141
8
|
// Legacy agent type mapping for backward compatibility
|
|
142
|
-
|
|
9
|
+
const LEGACY_AGENT_MAPPING = {
|
|
143
10
|
analyst: 'code-analyzer',
|
|
144
11
|
coordinator: 'hierarchical-coordinator',
|
|
145
12
|
optimizer: 'perf-analyzer',
|
|
@@ -150,40 +17,38 @@ var LEGACY_AGENT_MAPPING = {
|
|
|
150
17
|
};
|
|
151
18
|
/**
|
|
152
19
|
* Resolve legacy agent types to current equivalents
|
|
153
|
-
*/ function resolveLegacyAgentType(legacyType) {
|
|
20
|
+
*/ export function resolveLegacyAgentType(legacyType) {
|
|
154
21
|
return LEGACY_AGENT_MAPPING[legacyType] || legacyType;
|
|
155
22
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
AgentLoader.prototype.getAgentsDirectory = function() {
|
|
164
|
-
var currentDir = process.cwd();
|
|
23
|
+
export class AgentLoader {
|
|
24
|
+
agentCache = new Map();
|
|
25
|
+
categoriesCache = [];
|
|
26
|
+
lastLoadTime = 0;
|
|
27
|
+
CACHE_EXPIRY = 60_000;
|
|
28
|
+
getAgentsDirectory() {
|
|
29
|
+
let currentDir = process.cwd();
|
|
165
30
|
while(currentDir !== '/'){
|
|
166
|
-
|
|
167
|
-
if (
|
|
31
|
+
const claudeAgentsPath = resolve(currentDir, '.claude', 'agents');
|
|
32
|
+
if (existsSync(claudeAgentsPath)) {
|
|
168
33
|
return claudeAgentsPath;
|
|
169
34
|
}
|
|
170
|
-
currentDir =
|
|
35
|
+
currentDir = dirname(currentDir);
|
|
171
36
|
}
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
|
|
37
|
+
return resolve(process.cwd(), '.claude', 'agents');
|
|
38
|
+
}
|
|
39
|
+
parseAgentFile(filePath) {
|
|
175
40
|
try {
|
|
176
|
-
|
|
177
|
-
|
|
41
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
42
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
178
43
|
if (!frontmatterMatch) {
|
|
179
|
-
console.warn(
|
|
44
|
+
console.warn(`No frontmatter found in ${filePath}`);
|
|
180
45
|
return null;
|
|
181
46
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
47
|
+
const [, yamlContent, markdownContent] = frontmatterMatch;
|
|
48
|
+
const frontmatter = parseYaml(yamlContent);
|
|
49
|
+
const description = frontmatter.description;
|
|
185
50
|
if (!frontmatter.name || !description) {
|
|
186
|
-
console.warn(
|
|
51
|
+
console.warn(`Missing required fields (name, description) in ${filePath}`);
|
|
187
52
|
return null;
|
|
188
53
|
}
|
|
189
54
|
return {
|
|
@@ -204,325 +69,126 @@ var AgentLoader = /** @class */ function() {
|
|
|
204
69
|
content: markdownContent.trim()
|
|
205
70
|
};
|
|
206
71
|
} catch (error) {
|
|
207
|
-
console.error(
|
|
72
|
+
console.error(`Error parsing agent file ${filePath}:`, error);
|
|
208
73
|
return null;
|
|
209
74
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
75
|
+
}
|
|
76
|
+
parseTools(frontmatter) {
|
|
77
|
+
const extractTools = (input)=>{
|
|
213
78
|
if (Array.isArray(input)) return input.map(String);
|
|
214
79
|
if (typeof input === 'string') {
|
|
215
|
-
return input.split(/[,\s]+/).map(
|
|
216
|
-
return t.trim();
|
|
217
|
-
}).filter(function(t) {
|
|
218
|
-
return t.length > 0;
|
|
219
|
-
});
|
|
80
|
+
return input.split(/[,\s]+/).map((t)=>t.trim()).filter((t)=>t.length > 0);
|
|
220
81
|
}
|
|
221
82
|
return [];
|
|
222
83
|
};
|
|
223
84
|
// Safely handle tools and capabilities.tools
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
'**/MIGRATION_SUMMARY.md'
|
|
249
|
-
],
|
|
250
|
-
absolute: true
|
|
251
|
-
}, function(err, matches) {
|
|
252
|
-
if (err) reject(err);
|
|
253
|
-
else resolve(matches);
|
|
254
|
-
});
|
|
255
|
-
})
|
|
256
|
-
];
|
|
257
|
-
case 1:
|
|
258
|
-
agentFiles = _a.sent();
|
|
259
|
-
this.agentCache.clear();
|
|
260
|
-
this.categoriesCache = [];
|
|
261
|
-
categoryMap = new Map();
|
|
262
|
-
for(_i = 0, agentFiles_1 = agentFiles; _i < agentFiles_1.length; _i++){
|
|
263
|
-
filePath = agentFiles_1[_i];
|
|
264
|
-
agent = this.parseAgentFile(filePath);
|
|
265
|
-
if (agent) {
|
|
266
|
-
this.agentCache.set(agent.name, agent);
|
|
267
|
-
relativePath = filePath.replace(agentsDir, '');
|
|
268
|
-
pathParts = relativePath.split('/');
|
|
269
|
-
category = pathParts[1] || 'uncategorized';
|
|
270
|
-
if (!categoryMap.has(category)) {
|
|
271
|
-
categoryMap.set(category, []);
|
|
272
|
-
}
|
|
273
|
-
categoryMap.get(category).push(agent);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
this.categoriesCache = Array.from(categoryMap.entries()).map(function(_a) {
|
|
277
|
-
var name = _a[0], agents = _a[1];
|
|
278
|
-
return {
|
|
279
|
-
name: name,
|
|
280
|
-
agents: agents.sort(function(a, b) {
|
|
281
|
-
return a.name.localeCompare(b.name);
|
|
282
|
-
})
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
this.lastLoadTime = Date.now();
|
|
286
|
-
return [
|
|
287
|
-
2 /*return*/
|
|
288
|
-
];
|
|
289
|
-
}
|
|
85
|
+
const toolsFromFrontmatter = frontmatter.tools ? extractTools(frontmatter.tools) : [];
|
|
86
|
+
const toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object' ? extractTools(Object(frontmatter.capabilities).tools) : [];
|
|
87
|
+
return [
|
|
88
|
+
...toolsFromFrontmatter,
|
|
89
|
+
...toolsFromCapabilities
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
async loadAgents() {
|
|
93
|
+
const agentsDir = this.getAgentsDirectory();
|
|
94
|
+
if (!existsSync(agentsDir)) {
|
|
95
|
+
console.warn(`Agents directory not found: ${agentsDir}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const agentFiles = await new Promise((resolve, reject)=>{
|
|
99
|
+
glob('**/*.md', {
|
|
100
|
+
cwd: agentsDir,
|
|
101
|
+
ignore: [
|
|
102
|
+
'**/README.md',
|
|
103
|
+
'**/MIGRATION_SUMMARY.md'
|
|
104
|
+
],
|
|
105
|
+
absolute: true
|
|
106
|
+
}, (err, matches)=>{
|
|
107
|
+
if (err) reject(err);
|
|
108
|
+
else resolve(matches);
|
|
290
109
|
});
|
|
291
110
|
});
|
|
292
|
-
|
|
111
|
+
this.agentCache.clear();
|
|
112
|
+
this.categoriesCache = [];
|
|
113
|
+
const categoryMap = new Map();
|
|
114
|
+
for (const filePath of agentFiles){
|
|
115
|
+
const agent = this.parseAgentFile(filePath);
|
|
116
|
+
if (agent) {
|
|
117
|
+
this.agentCache.set(agent.name, agent);
|
|
118
|
+
const relativePath = filePath.replace(agentsDir, '');
|
|
119
|
+
const pathParts = relativePath.split('/');
|
|
120
|
+
const category = pathParts[1] || 'uncategorized';
|
|
121
|
+
if (!categoryMap.has(category)) {
|
|
122
|
+
categoryMap.set(category, []);
|
|
123
|
+
}
|
|
124
|
+
categoryMap.get(category).push(agent);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.categoriesCache = Array.from(categoryMap.entries()).map(([name, agents])=>({
|
|
128
|
+
name,
|
|
129
|
+
agents: agents.sort((a, b)=>a.name.localeCompare(b.name))
|
|
130
|
+
}));
|
|
131
|
+
this.lastLoadTime = Date.now();
|
|
132
|
+
}
|
|
293
133
|
// Rest of the methods remain similar to the original implementation
|
|
294
|
-
|
|
134
|
+
needsRefresh() {
|
|
295
135
|
return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
};
|
|
343
|
-
AgentLoader.prototype.getAgent = function(name) {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
345
|
-
return __generator(this, function(_a) {
|
|
346
|
-
switch(_a.label){
|
|
347
|
-
case 0:
|
|
348
|
-
return [
|
|
349
|
-
4 /*yield*/ ,
|
|
350
|
-
this.ensureLoaded()
|
|
351
|
-
];
|
|
352
|
-
case 1:
|
|
353
|
-
_a.sent();
|
|
354
|
-
return [
|
|
355
|
-
2 /*return*/ ,
|
|
356
|
-
this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null
|
|
357
|
-
];
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
AgentLoader.prototype.getAllAgents = function() {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
364
|
-
return __generator(this, function(_a) {
|
|
365
|
-
switch(_a.label){
|
|
366
|
-
case 0:
|
|
367
|
-
return [
|
|
368
|
-
4 /*yield*/ ,
|
|
369
|
-
this.ensureLoaded()
|
|
370
|
-
];
|
|
371
|
-
case 1:
|
|
372
|
-
_a.sent();
|
|
373
|
-
return [
|
|
374
|
-
2 /*return*/ ,
|
|
375
|
-
Array.from(this.agentCache.values()).sort(function(a, b) {
|
|
376
|
-
return a.name.localeCompare(b.name);
|
|
377
|
-
})
|
|
378
|
-
];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
AgentLoader.prototype.getAgentCategories = function() {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
385
|
-
return __generator(this, function(_a) {
|
|
386
|
-
switch(_a.label){
|
|
387
|
-
case 0:
|
|
388
|
-
return [
|
|
389
|
-
4 /*yield*/ ,
|
|
390
|
-
this.ensureLoaded()
|
|
391
|
-
];
|
|
392
|
-
case 1:
|
|
393
|
-
_a.sent();
|
|
394
|
-
return [
|
|
395
|
-
2 /*return*/ ,
|
|
396
|
-
this.categoriesCache
|
|
397
|
-
];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
AgentLoader.prototype.searchAgents = function(query) {
|
|
403
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
404
|
-
var lowerQuery;
|
|
405
|
-
return __generator(this, function(_a) {
|
|
406
|
-
switch(_a.label){
|
|
407
|
-
case 0:
|
|
408
|
-
return [
|
|
409
|
-
4 /*yield*/ ,
|
|
410
|
-
this.ensureLoaded()
|
|
411
|
-
];
|
|
412
|
-
case 1:
|
|
413
|
-
_a.sent();
|
|
414
|
-
lowerQuery = query.toLowerCase();
|
|
415
|
-
return [
|
|
416
|
-
2 /*return*/ ,
|
|
417
|
-
Array.from(this.agentCache.values()).filter(function(agent) {
|
|
418
|
-
var _a;
|
|
419
|
-
return agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || ((_a = agent.capabilities) === null || _a === void 0 ? void 0 : _a.some(function(cap) {
|
|
420
|
-
return cap.toLowerCase().includes(lowerQuery);
|
|
421
|
-
}));
|
|
422
|
-
})
|
|
423
|
-
];
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
AgentLoader.prototype.isValidAgentType = function(name) {
|
|
429
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
430
|
-
return __generator(this, function(_a) {
|
|
431
|
-
switch(_a.label){
|
|
432
|
-
case 0:
|
|
433
|
-
return [
|
|
434
|
-
4 /*yield*/ ,
|
|
435
|
-
this.ensureLoaded()
|
|
436
|
-
];
|
|
437
|
-
case 1:
|
|
438
|
-
_a.sent();
|
|
439
|
-
return [
|
|
440
|
-
2 /*return*/ ,
|
|
441
|
-
this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name))
|
|
442
|
-
];
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
};
|
|
447
|
-
AgentLoader.prototype.getAgentsByCategory = function(category) {
|
|
448
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
449
|
-
var categories, found;
|
|
450
|
-
return __generator(this, function(_a) {
|
|
451
|
-
switch(_a.label){
|
|
452
|
-
case 0:
|
|
453
|
-
return [
|
|
454
|
-
4 /*yield*/ ,
|
|
455
|
-
this.getAgentCategories()
|
|
456
|
-
];
|
|
457
|
-
case 1:
|
|
458
|
-
categories = _a.sent();
|
|
459
|
-
found = categories.find(function(cat) {
|
|
460
|
-
return cat.name === category;
|
|
461
|
-
});
|
|
462
|
-
return [
|
|
463
|
-
2 /*return*/ ,
|
|
464
|
-
(found === null || found === void 0 ? void 0 : found.agents) || []
|
|
465
|
-
];
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
AgentLoader.prototype.refresh = function() {
|
|
471
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
472
|
-
return __generator(this, function(_a) {
|
|
473
|
-
switch(_a.label){
|
|
474
|
-
case 0:
|
|
475
|
-
this.lastLoadTime = 0;
|
|
476
|
-
return [
|
|
477
|
-
4 /*yield*/ ,
|
|
478
|
-
this.loadAgents()
|
|
479
|
-
];
|
|
480
|
-
case 1:
|
|
481
|
-
_a.sent();
|
|
482
|
-
return [
|
|
483
|
-
2 /*return*/
|
|
484
|
-
];
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
};
|
|
489
|
-
return AgentLoader;
|
|
490
|
-
}();
|
|
491
|
-
exports.AgentLoader = AgentLoader;
|
|
136
|
+
}
|
|
137
|
+
async ensureLoaded() {
|
|
138
|
+
if (this.agentCache.size === 0 || this.needsRefresh()) {
|
|
139
|
+
await this.loadAgents();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async getAvailableAgentTypes() {
|
|
143
|
+
await this.ensureLoaded();
|
|
144
|
+
const currentTypes = Array.from(this.agentCache.keys());
|
|
145
|
+
const legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);
|
|
146
|
+
return Array.from(new Set([
|
|
147
|
+
...currentTypes,
|
|
148
|
+
...legacyTypes
|
|
149
|
+
])).sort();
|
|
150
|
+
}
|
|
151
|
+
async getAgent(name) {
|
|
152
|
+
await this.ensureLoaded();
|
|
153
|
+
return this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null;
|
|
154
|
+
}
|
|
155
|
+
async getAllAgents() {
|
|
156
|
+
await this.ensureLoaded();
|
|
157
|
+
return Array.from(this.agentCache.values()).sort((a, b)=>a.name.localeCompare(b.name));
|
|
158
|
+
}
|
|
159
|
+
async getAgentCategories() {
|
|
160
|
+
await this.ensureLoaded();
|
|
161
|
+
return this.categoriesCache;
|
|
162
|
+
}
|
|
163
|
+
async searchAgents(query) {
|
|
164
|
+
await this.ensureLoaded();
|
|
165
|
+
const lowerQuery = query.toLowerCase();
|
|
166
|
+
return Array.from(this.agentCache.values()).filter((agent)=>agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || agent.capabilities?.some((cap)=>cap.toLowerCase().includes(lowerQuery)));
|
|
167
|
+
}
|
|
168
|
+
async isValidAgentType(name) {
|
|
169
|
+
await this.ensureLoaded();
|
|
170
|
+
return this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name));
|
|
171
|
+
}
|
|
172
|
+
async getAgentsByCategory(category) {
|
|
173
|
+
const categories = await this.getAgentCategories();
|
|
174
|
+
const found = categories.find((cat)=>cat.name === category);
|
|
175
|
+
return found?.agents || [];
|
|
176
|
+
}
|
|
177
|
+
async refresh() {
|
|
178
|
+
this.lastLoadTime = 0;
|
|
179
|
+
await this.loadAgents();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
492
182
|
// Singleton instance
|
|
493
|
-
|
|
183
|
+
export const agentLoader = new AgentLoader();
|
|
494
184
|
// Convenience exports for use in other modules
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
var getAllAgents = function() {
|
|
504
|
-
return exports.agentLoader.getAllAgents();
|
|
505
|
-
};
|
|
506
|
-
exports.getAllAgents = getAllAgents;
|
|
507
|
-
var getAgentCategories = function() {
|
|
508
|
-
return exports.agentLoader.getAgentCategories();
|
|
509
|
-
};
|
|
510
|
-
exports.getAgentCategories = getAgentCategories;
|
|
511
|
-
var searchAgents = function(query) {
|
|
512
|
-
return exports.agentLoader.searchAgents(query);
|
|
513
|
-
};
|
|
514
|
-
exports.searchAgents = searchAgents;
|
|
515
|
-
var isValidAgentType = function(name) {
|
|
516
|
-
return exports.agentLoader.isValidAgentType(name);
|
|
517
|
-
};
|
|
518
|
-
exports.isValidAgentType = isValidAgentType;
|
|
519
|
-
var getAgentsByCategory = function(category) {
|
|
520
|
-
return exports.agentLoader.getAgentsByCategory(category);
|
|
521
|
-
};
|
|
522
|
-
exports.getAgentsByCategory = getAgentsByCategory;
|
|
523
|
-
var refreshAgents = function() {
|
|
524
|
-
return exports.agentLoader.refresh();
|
|
525
|
-
};
|
|
526
|
-
exports.refreshAgents = refreshAgents;
|
|
185
|
+
export const getAvailableAgentTypes = ()=>agentLoader.getAvailableAgentTypes();
|
|
186
|
+
export const getAgent = (name)=>agentLoader.getAgent(name);
|
|
187
|
+
export const getAllAgents = ()=>agentLoader.getAllAgents();
|
|
188
|
+
export const getAgentCategories = ()=>agentLoader.getAgentCategories();
|
|
189
|
+
export const searchAgents = (query)=>agentLoader.searchAgents(query);
|
|
190
|
+
export const isValidAgentType = (name)=>agentLoader.isValidAgentType(name);
|
|
191
|
+
export const getAgentsByCategory = (category)=>agentLoader.getAgentsByCategory(category);
|
|
192
|
+
export const refreshAgents = ()=>agentLoader.refresh();
|
|
527
193
|
|
|
528
194
|
//# sourceMappingURL=agent-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/agents/agent-loader.js"],"sourcesContent":["\"use strict\";\n/**\n * Dynamic Agent Loader - Reads agent definitions from .claude/agents/ directory\n * Single source of truth for agent types in the system\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.refreshAgents = exports.getAgentsByCategory = exports.isValidAgentType = exports.searchAgents = exports.getAgentCategories = exports.getAllAgents = exports.getAgent = exports.getAvailableAgentTypes = exports.agentLoader = exports.AgentLoader = void 0;\nexports.resolveLegacyAgentType = resolveLegacyAgentType;\nvar node_fs_1 = require(\"node:fs\");\nvar glob_1 = require(\"glob\");\nvar node_path_1 = require(\"node:path\");\nvar yaml_1 = require(\"yaml\");\n// Legacy agent type mapping for backward compatibility\nvar LEGACY_AGENT_MAPPING = {\n analyst: 'code-analyzer',\n coordinator: 'hierarchical-coordinator',\n optimizer: 'perf-analyzer',\n documenter: 'api-docs',\n monitor: 'performance-benchmarker',\n specialist: 'system-architect',\n architect: 'system-architect',\n};\n/**\n * Resolve legacy agent types to current equivalents\n */\nfunction resolveLegacyAgentType(legacyType) {\n return LEGACY_AGENT_MAPPING[legacyType] || legacyType;\n}\nvar AgentLoader = /** @class */ (function () {\n function AgentLoader() {\n this.agentCache = new Map();\n this.categoriesCache = [];\n this.lastLoadTime = 0;\n this.CACHE_EXPIRY = 60000; // 1 minute cache\n }\n AgentLoader.prototype.getAgentsDirectory = function () {\n var currentDir = process.cwd();\n while (currentDir !== '/') {\n var claudeAgentsPath = (0, node_path_1.resolve)(currentDir, '.claude', 'agents');\n if ((0, node_fs_1.existsSync)(claudeAgentsPath)) {\n return claudeAgentsPath;\n }\n currentDir = (0, node_path_1.dirname)(currentDir);\n }\n return (0, node_path_1.resolve)(process.cwd(), '.claude', 'agents');\n };\n AgentLoader.prototype.parseAgentFile = function (filePath) {\n try {\n var content = (0, node_fs_1.readFileSync)(filePath, 'utf-8');\n var frontmatterMatch = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n([\\s\\S]*)$/);\n if (!frontmatterMatch) {\n console.warn(\"No frontmatter found in \".concat(filePath));\n return null;\n }\n var yamlContent = frontmatterMatch[1], markdownContent = frontmatterMatch[2];\n var frontmatter = (0, yaml_1.parse)(yamlContent);\n var description = frontmatter.description;\n if (!frontmatter.name || !description) {\n console.warn(\"Missing required fields (name, description) in \".concat(filePath));\n return null;\n }\n return {\n name: String(frontmatter.name),\n type: frontmatter.type ? String(frontmatter.type) : undefined,\n color: frontmatter.color ? String(frontmatter.color) : undefined,\n description: String(description),\n model: frontmatter.model ? String(frontmatter.model) : undefined,\n capabilities: Array.isArray(frontmatter.capabilities)\n ? frontmatter.capabilities.map(String)\n : [],\n priority: ['low', 'medium', 'high', 'critical'].includes(String(frontmatter.priority))\n ? String(frontmatter.priority)\n : 'medium',\n tools: this.parseTools(frontmatter),\n hooks: frontmatter.hooks,\n content: markdownContent.trim(),\n };\n }\n catch (error) {\n console.error(\"Error parsing agent file \".concat(filePath, \":\"), error);\n return null;\n }\n };\n AgentLoader.prototype.parseTools = function (frontmatter) {\n var extractTools = function (input) {\n if (Array.isArray(input))\n return input.map(String);\n if (typeof input === 'string') {\n return input.split(/[,\\s]+/).map(function (t) { return t.trim(); }).filter(function (t) { return t.length > 0; });\n }\n return [];\n };\n // Safely handle tools and capabilities.tools\n var toolsFromFrontmatter = frontmatter.tools\n ? extractTools(frontmatter.tools)\n : [];\n var toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object'\n ? extractTools(Object(frontmatter.capabilities).tools)\n : [];\n return __spreadArray(__spreadArray([], toolsFromFrontmatter, true), toolsFromCapabilities, true);\n };\n AgentLoader.prototype.loadAgents = function () {\n return __awaiter(this, void 0, void 0, function () {\n var agentsDir, agentFiles, categoryMap, _i, agentFiles_1, filePath, agent, relativePath, pathParts, category;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n agentsDir = this.getAgentsDirectory();\n if (!(0, node_fs_1.existsSync)(agentsDir)) {\n console.warn(\"Agents directory not found: \".concat(agentsDir));\n return [2 /*return*/];\n }\n return [4 /*yield*/, new Promise(function (resolve, reject) {\n (0, glob_1.glob)('**/*.md', {\n cwd: agentsDir,\n ignore: ['**/README.md', '**/MIGRATION_SUMMARY.md'],\n absolute: true\n }, function (err, matches) {\n if (err)\n reject(err);\n else\n resolve(matches);\n });\n })];\n case 1:\n agentFiles = _a.sent();\n this.agentCache.clear();\n this.categoriesCache = [];\n categoryMap = new Map();\n for (_i = 0, agentFiles_1 = agentFiles; _i < agentFiles_1.length; _i++) {\n filePath = agentFiles_1[_i];\n agent = this.parseAgentFile(filePath);\n if (agent) {\n this.agentCache.set(agent.name, agent);\n relativePath = filePath.replace(agentsDir, '');\n pathParts = relativePath.split('/');\n category = pathParts[1] || 'uncategorized';\n if (!categoryMap.has(category)) {\n categoryMap.set(category, []);\n }\n categoryMap.get(category).push(agent);\n }\n }\n this.categoriesCache = Array.from(categoryMap.entries()).map(function (_a) {\n var name = _a[0], agents = _a[1];\n return ({\n name: name,\n agents: agents.sort(function (a, b) { return a.name.localeCompare(b.name); }),\n });\n });\n this.lastLoadTime = Date.now();\n return [2 /*return*/];\n }\n });\n });\n };\n // Rest of the methods remain similar to the original implementation\n AgentLoader.prototype.needsRefresh = function () {\n return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;\n };\n AgentLoader.prototype.ensureLoaded = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n if (!(this.agentCache.size === 0 || this.needsRefresh())) return [3 /*break*/, 2];\n return [4 /*yield*/, this.loadAgents()];\n case 1:\n _a.sent();\n _a.label = 2;\n case 2: return [2 /*return*/];\n }\n });\n });\n };\n AgentLoader.prototype.getAvailableAgentTypes = function () {\n return __awaiter(this, void 0, void 0, function () {\n var currentTypes, legacyTypes;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n currentTypes = Array.from(this.agentCache.keys());\n legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);\n return [2 /*return*/, Array.from(new Set(__spreadArray(__spreadArray([], currentTypes, true), legacyTypes, true))).sort()];\n }\n });\n });\n };\n AgentLoader.prototype.getAgent = function (name) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n return [2 /*return*/, this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null];\n }\n });\n });\n };\n AgentLoader.prototype.getAllAgents = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n return [2 /*return*/, Array.from(this.agentCache.values()).sort(function (a, b) { return a.name.localeCompare(b.name); })];\n }\n });\n });\n };\n AgentLoader.prototype.getAgentCategories = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n return [2 /*return*/, this.categoriesCache];\n }\n });\n });\n };\n AgentLoader.prototype.searchAgents = function (query) {\n return __awaiter(this, void 0, void 0, function () {\n var lowerQuery;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n lowerQuery = query.toLowerCase();\n return [2 /*return*/, Array.from(this.agentCache.values()).filter(function (agent) {\n var _a;\n return agent.name.toLowerCase().includes(lowerQuery) ||\n agent.description.toLowerCase().includes(lowerQuery) ||\n ((_a = agent.capabilities) === null || _a === void 0 ? void 0 : _a.some(function (cap) { return cap.toLowerCase().includes(lowerQuery); }));\n })];\n }\n });\n });\n };\n AgentLoader.prototype.isValidAgentType = function (name) {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.ensureLoaded()];\n case 1:\n _a.sent();\n return [2 /*return*/, this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name))];\n }\n });\n });\n };\n AgentLoader.prototype.getAgentsByCategory = function (category) {\n return __awaiter(this, void 0, void 0, function () {\n var categories, found;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.getAgentCategories()];\n case 1:\n categories = _a.sent();\n found = categories.find(function (cat) { return cat.name === category; });\n return [2 /*return*/, (found === null || found === void 0 ? void 0 : found.agents) || []];\n }\n });\n });\n };\n AgentLoader.prototype.refresh = function () {\n return __awaiter(this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n this.lastLoadTime = 0;\n return [4 /*yield*/, this.loadAgents()];\n case 1:\n _a.sent();\n return [2 /*return*/];\n }\n });\n });\n };\n return AgentLoader;\n}());\nexports.AgentLoader = AgentLoader;\n// Singleton instance\nexports.agentLoader = new AgentLoader();\n// Convenience exports for use in other modules\nvar getAvailableAgentTypes = function () { return exports.agentLoader.getAvailableAgentTypes(); };\nexports.getAvailableAgentTypes = getAvailableAgentTypes;\nvar getAgent = function (name) { return exports.agentLoader.getAgent(name); };\nexports.getAgent = getAgent;\nvar getAllAgents = function () { return exports.agentLoader.getAllAgents(); };\nexports.getAllAgents = getAllAgents;\nvar getAgentCategories = function () { return exports.agentLoader.getAgentCategories(); };\nexports.getAgentCategories = getAgentCategories;\nvar searchAgents = function (query) { return exports.agentLoader.searchAgents(query); };\nexports.searchAgents = searchAgents;\nvar isValidAgentType = function (name) { return exports.agentLoader.isValidAgentType(name); };\nexports.isValidAgentType = isValidAgentType;\nvar getAgentsByCategory = function (category) { return exports.agentLoader.getAgentsByCategory(category); };\nexports.getAgentsByCategory = getAgentsByCategory;\nvar refreshAgents = function () { return exports.agentLoader.refresh(); };\nexports.refreshAgents = refreshAgents;\n"],"names":["__awaiter","thisArg","_arguments","P","generator","adopt","value","resolve","Promise","reject","fulfilled","step","next","e","rejected","result","done","then","apply","__generator","body","_","label","sent","t","trys","ops","f","y","g","Object","create","Iterator","prototype","verb","Symbol","iterator","n","v","op","TypeError","call","pop","length","push","__spreadArray","to","from","pack","arguments","i","l","ar","Array","slice","concat","defineProperty","exports","refreshAgents","getAgentsByCategory","isValidAgentType","searchAgents","getAgentCategories","getAllAgents","getAgent","getAvailableAgentTypes","agentLoader","AgentLoader","resolveLegacyAgentType","node_fs_1","require","glob_1","node_path_1","yaml_1","LEGACY_AGENT_MAPPING","analyst","coordinator","optimizer","documenter","monitor","specialist","architect","legacyType","agentCache","Map","categoriesCache","lastLoadTime","CACHE_EXPIRY","getAgentsDirectory","currentDir","process","cwd","claudeAgentsPath","existsSync","dirname","parseAgentFile","filePath","content","readFileSync","frontmatterMatch","match","console","warn","yamlContent","markdownContent","frontmatter","parse","description","name","String","type","undefined","color","model","capabilities","isArray","map","priority","includes","tools","parseTools","hooks","trim","error","extractTools","input","split","filter","toolsFromFrontmatter","toolsFromCapabilities","loadAgents","agentsDir","agentFiles","categoryMap","_i","agentFiles_1","agent","relativePath","pathParts","category","_a","glob","ignore","absolute","err","matches","clear","set","replace","has","get","entries","agents","sort","a","b","localeCompare","Date","now","needsRefresh","ensureLoaded","size","currentTypes","legacyTypes","keys","Set","values","query","lowerQuery","toLowerCase","some","cap","categories","found","find","cat","refresh"],"mappings":"AAAA;AACA;;;CAGC,GACD,IAAIA,YAAY,AAAC,IAAI,IAAI,IAAI,CAACA,SAAS,IAAK,SAAUC,OAAO,EAAEC,UAAU,EAAEC,CAAC,EAAEC,SAAS;IACnF,SAASC,MAAMC,KAAK;QAAI,OAAOA,iBAAiBH,IAAIG,QAAQ,IAAIH,EAAE,SAAUI,OAAO;YAAIA,QAAQD;QAAQ;IAAI;IAC3G,OAAO,IAAKH,CAAAA,KAAMA,CAAAA,IAAIK,OAAM,CAAC,EAAG,SAAUD,OAAO,EAAEE,MAAM;QACrD,SAASC,UAAUJ,KAAK;YAAI,IAAI;gBAAEK,K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BAAkB,GAAGA;AAC7B,IAAID,eAAe,SAAU0G,KAAK;IAAI,OAAO9G,QAAQS,WAAW,CAACL,YAAY,CAAC0G;AAAQ;AACtF9G,QAAQI,YAAY,GAAGA;AACvB,IAAID,mBAAmB,SAAUgD,IAAI;IAAI,OAAOnD,QAAQS,WAAW,CAACN,gBAAgB,CAACgD;AAAO;AAC5FnD,QAAQG,gBAAgB,GAAGA;AAC3B,IAAID,sBAAsB,SAAUgF,QAAQ;IAAI,OAAOlF,QAAQS,WAAW,CAACP,mBAAmB,CAACgF;AAAW;AAC1GlF,QAAQE,mBAAmB,GAAGA;AAC9B,IAAID,gBAAgB;IAAc,OAAOD,QAAQS,WAAW,CAAC8G,OAAO;AAAI;AACxEvH,QAAQC,aAAa,GAAGA"}
|
|
1
|
+
{"version":3,"sources":["../../src/agents/agent-loader.ts"],"sourcesContent":["/**\n * Dynamic Agent Loader - Reads agent definitions from .claude/agents/ directory\n * Single source of truth for agent types in the system\n */\n\nimport { readFileSync, existsSync } from 'node:fs';\nimport { glob } from 'glob';\nimport { resolve, dirname } from 'node:path';\nimport { parse as parseYaml } from 'yaml';\n\n// Legacy agent type mapping for backward compatibility\nconst LEGACY_AGENT_MAPPING = {\n analyst: 'code-analyzer',\n coordinator: 'hierarchical-coordinator',\n optimizer: 'perf-analyzer',\n documenter: 'api-docs',\n monitor: 'performance-benchmarker',\n specialist: 'system-architect',\n architect: 'system-architect',\n} as const;\n\n/**\n * Resolve legacy agent types to current equivalents\n */\nexport function resolveLegacyAgentType(legacyType: string): string {\n return LEGACY_AGENT_MAPPING[legacyType as keyof typeof LEGACY_AGENT_MAPPING] || legacyType;\n}\n\nexport interface AgentDefinition {\n name: string;\n type?: string;\n color?: string;\n description: string;\n tools?: string[];\n model?: string;\n capabilities?: string[];\n priority?: 'low' | 'medium' | 'high' | 'critical';\n hooks?: {\n pre?: string;\n post?: string;\n task_complete?: string;\n on_rerun_request?: string;\n lifecycle?: Record<string, string>;\n };\n lifecycle?: {\n state_management?: boolean;\n persistent_memory?: boolean;\n max_retries?: number;\n timeout_ms?: number;\n auto_cleanup?: boolean;\n };\n content?: string;\n}\n\nexport interface AgentCategory {\n name: string;\n agents: AgentDefinition[];\n}\n\nexport class AgentLoader {\n private agentCache = new Map<string, AgentDefinition>();\n private categoriesCache: AgentCategory[] = [];\n private lastLoadTime = 0;\n private readonly CACHE_EXPIRY = 60_000; // 1 minute cache\n\n private getAgentsDirectory(): string {\n let currentDir = process.cwd();\n\n while (currentDir !== '/') {\n const claudeAgentsPath = resolve(currentDir, '.claude', 'agents');\n if (existsSync(claudeAgentsPath)) {\n return claudeAgentsPath;\n }\n currentDir = dirname(currentDir);\n }\n\n return resolve(process.cwd(), '.claude', 'agents');\n }\n\n private parseAgentFile(filePath: string): AgentDefinition | null {\n try {\n const content = readFileSync(filePath, 'utf-8');\n\n const frontmatterMatch = content.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n([\\s\\S]*)$/);\n if (!frontmatterMatch) {\n console.warn(`No frontmatter found in ${filePath}`);\n return null;\n }\n\n const [, yamlContent, markdownContent] = frontmatterMatch;\n const frontmatter = parseYaml(yamlContent) as Record<string, unknown>;\n\n const description = frontmatter.description;\n if (!frontmatter.name || !description) {\n console.warn(`Missing required fields (name, description) in ${filePath}`);\n return null;\n }\n\n return {\n name: String(frontmatter.name),\n type: frontmatter.type ? String(frontmatter.type) : undefined,\n color: frontmatter.color ? String(frontmatter.color) : undefined,\n description: String(description),\n model: frontmatter.model ? String(frontmatter.model) : undefined,\n capabilities: Array.isArray(frontmatter.capabilities)\n ? frontmatter.capabilities.map(String)\n : [],\n priority: ['low', 'medium', 'high', 'critical'].includes(String(frontmatter.priority))\n ? String(frontmatter.priority) as AgentDefinition['priority']\n : 'medium',\n tools: this.parseTools(frontmatter),\n hooks: frontmatter.hooks as AgentDefinition['hooks'],\n content: markdownContent.trim(),\n };\n } catch (error) {\n console.error(`Error parsing agent file ${filePath}:`, error);\n return null;\n }\n }\n\n private parseTools(frontmatter: Record<string, unknown>): string[] {\n const extractTools = (input: unknown): string[] => {\n if (Array.isArray(input)) return input.map(String);\n if (typeof input === 'string') {\n return input.split(/[,\\s]+/).map(t => t.trim()).filter(t => t.length > 0);\n }\n return [];\n };\n\n // Safely handle tools and capabilities.tools\n const toolsFromFrontmatter = frontmatter.tools\n ? extractTools(frontmatter.tools)\n : [];\n\n const toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object'\n ? extractTools(Object(frontmatter.capabilities).tools)\n : [];\n\n return [...toolsFromFrontmatter, ...toolsFromCapabilities];\n }\n\n private async loadAgents(): Promise<void> {\n const agentsDir = this.getAgentsDirectory();\n\n if (!existsSync(agentsDir)) {\n console.warn(`Agents directory not found: ${agentsDir}`);\n return;\n }\n\n const agentFiles = await new Promise<string[]>((resolve, reject) => {\n glob('**/*.md', {\n cwd: agentsDir,\n ignore: ['**/README.md', '**/MIGRATION_SUMMARY.md'],\n absolute: true\n }, (err, matches) => {\n if (err) reject(err);\n else resolve(matches);\n });\n });\n\n this.agentCache.clear();\n this.categoriesCache = [];\n\n const categoryMap = new Map<string, AgentDefinition[]>();\n\n for (const filePath of agentFiles) {\n const agent = this.parseAgentFile(filePath);\n if (agent) {\n this.agentCache.set(agent.name, agent);\n\n const relativePath = filePath.replace(agentsDir, '');\n const pathParts = relativePath.split('/');\n const category = pathParts[1] || 'uncategorized';\n\n if (!categoryMap.has(category)) {\n categoryMap.set(category, []);\n }\n categoryMap.get(category)!.push(agent);\n }\n }\n\n this.categoriesCache = Array.from(categoryMap.entries()).map(([name, agents]) => ({\n name,\n agents: agents.sort((a, b) => a.name.localeCompare(b.name)),\n }));\n\n this.lastLoadTime = Date.now();\n }\n\n // Rest of the methods remain similar to the original implementation\n private needsRefresh(): boolean {\n return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;\n }\n\n private async ensureLoaded(): Promise<void> {\n if (this.agentCache.size === 0 || this.needsRefresh()) {\n await this.loadAgents();\n }\n }\n\n async getAvailableAgentTypes(): Promise<string[]> {\n await this.ensureLoaded();\n const currentTypes = Array.from(this.agentCache.keys());\n const legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);\n return Array.from(new Set([...currentTypes, ...legacyTypes])).sort();\n }\n\n async getAgent(name: string): Promise<AgentDefinition | null> {\n await this.ensureLoaded();\n return this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null;\n }\n\n async getAllAgents(): Promise<AgentDefinition[]> {\n await this.ensureLoaded();\n return Array.from(this.agentCache.values()).sort((a, b) => a.name.localeCompare(b.name));\n }\n\n async getAgentCategories(): Promise<AgentCategory[]> {\n await this.ensureLoaded();\n return this.categoriesCache;\n }\n\n async searchAgents(query: string): Promise<AgentDefinition[]> {\n await this.ensureLoaded();\n const lowerQuery = query.toLowerCase();\n\n return Array.from(this.agentCache.values()).filter((agent) =>\n agent.name.toLowerCase().includes(lowerQuery) ||\n agent.description.toLowerCase().includes(lowerQuery) ||\n agent.capabilities?.some((cap) => cap.toLowerCase().includes(lowerQuery))\n );\n }\n\n async isValidAgentType(name: string): Promise<boolean> {\n await this.ensureLoaded();\n return this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name));\n }\n\n async getAgentsByCategory(category: string): Promise<AgentDefinition[]> {\n const categories = await this.getAgentCategories();\n const found = categories.find((cat) => cat.name === category);\n return found?.agents || [];\n }\n\n async refresh(): Promise<void> {\n this.lastLoadTime = 0;\n await this.loadAgents();\n }\n}\n\n// Singleton instance\nexport const agentLoader = new AgentLoader();\n\n// Convenience exports for use in other modules\nexport const getAvailableAgentTypes = () => agentLoader.getAvailableAgentTypes();\nexport const getAgent = (name: string) => agentLoader.getAgent(name);\nexport const getAllAgents = () => agentLoader.getAllAgents();\nexport const getAgentCategories = () => agentLoader.getAgentCategories();\nexport const searchAgents = (query: string) => agentLoader.searchAgents(query);\nexport const isValidAgentType = (name: string) => agentLoader.isValidAgentType(name);\nexport const getAgentsByCategory = (category: string) => agentLoader.getAgentsByCategory(category);\nexport const refreshAgents = () => agentLoader.refresh();\n"],"names":["readFileSync","existsSync","glob","resolve","dirname","parse","parseYaml","LEGACY_AGENT_MAPPING","analyst","coordinator","optimizer","documenter","monitor","specialist","architect","resolveLegacyAgentType","legacyType","AgentLoader","agentCache","Map","categoriesCache","lastLoadTime","CACHE_EXPIRY","getAgentsDirectory","currentDir","process","cwd","claudeAgentsPath","parseAgentFile","filePath","content","frontmatterMatch","match","console","warn","yamlContent","markdownContent","frontmatter","description","name","String","type","undefined","color","model","capabilities","Array","isArray","map","priority","includes","tools","parseTools","hooks","trim","error","extractTools","input","split","t","filter","length","toolsFromFrontmatter","toolsFromCapabilities","Object","loadAgents","agentsDir","agentFiles","Promise","reject","ignore","absolute","err","matches","clear","categoryMap","agent","set","relativePath","replace","pathParts","category","has","get","push","from","entries","agents","sort","a","b","localeCompare","Date","now","needsRefresh","ensureLoaded","size","getAvailableAgentTypes","currentTypes","keys","legacyTypes","Set","getAgent","getAllAgents","values","getAgentCategories","searchAgents","query","lowerQuery","toLowerCase","some","cap","isValidAgentType","getAgentsByCategory","categories","found","find","cat","refresh","agentLoader","refreshAgents"],"mappings":"AAAA;;;CAGC,GAED,SAASA,YAAY,EAAEC,UAAU,QAAQ,UAAU;AACnD,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,OAAO,EAAEC,OAAO,QAAQ,YAAY;AAC7C,SAASC,SAASC,SAAS,QAAQ,OAAO;AAE1C,uDAAuD;AACvD,MAAMC,uBAAuB;IAC3BC,SAAS;IACTC,aAAa;IACbC,WAAW;IACXC,YAAY;IACZC,SAAS;IACTC,YAAY;IACZC,WAAW;AACb;AAEA;;CAEC,GACD,OAAO,SAASC,uBAAuBC,UAAkB;IACvD,OAAOT,oBAAoB,CAACS,WAAgD,IAAIA;AAClF;AAiCA,OAAO,MAAMC;IACHC,aAAa,IAAIC,MAA+B;IAChDC,kBAAmC,EAAE,CAAC;IACtCC,eAAe,EAAE;IACRC,eAAe,OAAO;IAE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B;QACtE,MAAMiC,aAAa,MAAM,IAAI,CAACT,kBAAkB;QAChD,MAAMU,QAAQD,WAAWE,IAAI,CAAC,CAACC,MAAQA,IAAI9E,IAAI,KAAK0C;QACpD,OAAOkC,OAAO5B,UAAU,EAAE;IAC5B;IAEA,MAAM+B,UAAyB;QAC7B,IAAI,CAACjG,YAAY,GAAG;QACpB,MAAM,IAAI,CAAC4C,UAAU;IACvB;AACF;AAEA,qBAAqB;AACrB,OAAO,MAAMsD,cAAc,IAAItG,cAAc;AAE7C,+CAA+C;AAC/C,OAAO,MAAMgF,yBAAyB,IAAMsB,YAAYtB,sBAAsB,GAAG;AACjF,OAAO,MAAMK,WAAW,CAAC/D,OAAiBgF,YAAYjB,QAAQ,CAAC/D,MAAM;AACrE,OAAO,MAAMgE,eAAe,IAAMgB,YAAYhB,YAAY,GAAG;AAC7D,OAAO,MAAME,qBAAqB,IAAMc,YAAYd,kBAAkB,GAAG;AACzE,OAAO,MAAMC,eAAe,CAACC,QAAkBY,YAAYb,YAAY,CAACC,OAAO;AAC/E,OAAO,MAAMK,mBAAmB,CAACzE,OAAiBgF,YAAYP,gBAAgB,CAACzE,MAAM;AACrF,OAAO,MAAM0E,sBAAsB,CAAChC,WAAqBsC,YAAYN,mBAAmB,CAAChC,UAAU;AACnG,OAAO,MAAMuC,gBAAgB,IAAMD,YAAYD,OAAO,GAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-flow-novice",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.8",
|
|
4
4
|
"description": "AI agent orchestration framework with namespace-isolated skills, agents, and CFN Loop validation. Safe installation with ~0.01% collision risk.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|