@namch/agent-assistant 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -522
- package/agents/backend-engineer.md +0 -8
- package/agents/brainstormer.md +0 -6
- package/agents/business-analyst.md +0 -5
- package/agents/database-architect.md +0 -6
- package/agents/debugger.md +0 -6
- package/agents/designer.md +0 -5
- package/agents/devops-engineer.md +0 -7
- package/agents/docs-manager.md +0 -6
- package/agents/frontend-engineer.md +0 -7
- package/agents/game-engineer.md +0 -7
- package/agents/mobile-engineer.md +0 -7
- package/agents/performance-engineer.md +0 -7
- package/agents/planner.md +0 -6
- package/agents/project-manager.md +0 -6
- package/agents/researcher.md +0 -5
- package/agents/reviewer.md +0 -6
- package/agents/scouter.md +0 -6
- package/agents/security-engineer.md +0 -7
- package/agents/tech-lead.md +0 -7
- package/agents/tester.md +0 -5
- package/cli/README.md +19 -10
- package/documents/business/business-features.md +1 -1
- package/documents/business/business-prd.md +4 -4
- package/documents/knowledge-architecture.md +1 -1
- package/documents/knowledge-domain.md +1 -1
- package/documents/knowledge-overview.md +14 -29
- package/documents/knowledge-source-base.md +14 -14
- package/package.json +1 -1
- package/rules/QUICK-REFERENCE.md +4 -1
- package/rules/SKILL-DISCOVERY.md +37 -14
- package/skills/active-directory-attacks/SKILL.md +383 -0
- package/skills/active-directory-attacks/references/advanced-attacks.md +382 -0
- package/skills/agent-evaluation/SKILL.md +64 -0
- package/skills/agent-memory-mcp/SKILL.md +82 -0
- package/skills/agent-memory-systems/SKILL.md +67 -0
- package/skills/agent-tool-builder/SKILL.md +53 -0
- package/skills/ai-agents-architect/SKILL.md +90 -0
- package/skills/ai-product/SKILL.md +54 -0
- package/skills/ai-wrapper-product/SKILL.md +273 -0
- package/skills/api-documentation-generator/SKILL.md +484 -0
- package/skills/api-fuzzing-bug-bounty/SKILL.md +433 -0
- package/skills/api-security-best-practices/SKILL.md +907 -0
- package/skills/autonomous-agent-patterns/SKILL.md +761 -0
- package/skills/autonomous-agents/SKILL.md +68 -0
- package/skills/aws-penetration-testing/SKILL.md +405 -0
- package/skills/aws-penetration-testing/references/advanced-aws-pentesting.md +469 -0
- package/skills/azure-functions/SKILL.md +42 -0
- package/skills/backend-dev-guidelines/SKILL.md +342 -0
- package/skills/backend-dev-guidelines/resources/architecture-overview.md +451 -0
- package/skills/backend-dev-guidelines/resources/async-and-errors.md +307 -0
- package/skills/backend-dev-guidelines/resources/complete-examples.md +638 -0
- package/skills/backend-dev-guidelines/resources/configuration.md +275 -0
- package/skills/backend-dev-guidelines/resources/database-patterns.md +224 -0
- package/skills/backend-dev-guidelines/resources/middleware-guide.md +213 -0
- package/skills/backend-dev-guidelines/resources/routing-and-controllers.md +756 -0
- package/skills/backend-dev-guidelines/resources/sentry-and-monitoring.md +336 -0
- package/skills/backend-dev-guidelines/resources/services-and-repositories.md +789 -0
- package/skills/backend-dev-guidelines/resources/testing-guide.md +235 -0
- package/skills/backend-dev-guidelines/resources/validation-patterns.md +754 -0
- package/skills/broken-authentication/SKILL.md +476 -0
- package/skills/bullmq-specialist/SKILL.md +57 -0
- package/skills/bun-development/SKILL.md +691 -0
- package/skills/burp-suite-testing/SKILL.md +380 -0
- package/skills/cloud-penetration-testing/SKILL.md +501 -0
- package/skills/cloud-penetration-testing/references/advanced-cloud-scripts.md +318 -0
- package/skills/computer-use-agents/SKILL.md +315 -0
- package/skills/content-creator/SKILL.md +248 -0
- package/skills/content-creator/assets/content_calendar_template.md +99 -0
- package/skills/content-creator/references/brand_guidelines.md +199 -0
- package/skills/content-creator/references/content_frameworks.md +534 -0
- package/skills/content-creator/references/social_media_optimization.md +317 -0
- package/skills/content-creator/scripts/brand_voice_analyzer.py +185 -0
- package/skills/content-creator/scripts/seo_optimizer.py +419 -0
- package/skills/context-window-management/SKILL.md +53 -0
- package/skills/conversation-memory/SKILL.md +61 -0
- package/skills/copy-editing/SKILL.md +439 -0
- package/skills/copywriting/SKILL.md +225 -0
- package/skills/crewai/SKILL.md +243 -0
- package/skills/discord-bot-architect/SKILL.md +277 -0
- package/skills/dispatching-parallel-agents/SKILL.md +180 -0
- package/skills/email-sequence/SKILL.md +925 -0
- package/skills/email-systems/SKILL.md +54 -0
- package/skills/ethical-hacking-methodology/SKILL.md +466 -0
- package/skills/executing-plans/SKILL.md +76 -0
- package/skills/file-path-traversal/SKILL.md +486 -0
- package/skills/finishing-a-development-branch/SKILL.md +200 -0
- package/skills/frontend-dev-guidelines/SKILL.md +359 -0
- package/skills/frontend-dev-guidelines/resources/common-patterns.md +331 -0
- package/skills/frontend-dev-guidelines/resources/complete-examples.md +872 -0
- package/skills/frontend-dev-guidelines/resources/component-patterns.md +502 -0
- package/skills/frontend-dev-guidelines/resources/data-fetching.md +767 -0
- package/skills/frontend-dev-guidelines/resources/file-organization.md +502 -0
- package/skills/frontend-dev-guidelines/resources/loading-and-error-states.md +501 -0
- package/skills/frontend-dev-guidelines/resources/performance.md +406 -0
- package/skills/frontend-dev-guidelines/resources/routing-guide.md +364 -0
- package/skills/frontend-dev-guidelines/resources/styling-guide.md +428 -0
- package/skills/frontend-dev-guidelines/resources/typescript-standards.md +418 -0
- package/skills/gcp-cloud-run/SKILL.md +288 -0
- package/skills/git-pushing/SKILL.md +33 -0
- package/skills/git-pushing/scripts/smart_commit.sh +19 -0
- package/skills/github-workflow-automation/SKILL.md +846 -0
- package/skills/html-injection-testing/SKILL.md +498 -0
- package/skills/idor-testing/SKILL.md +442 -0
- package/skills/inngest/SKILL.md +55 -0
- package/skills/javascript-mastery/SKILL.md +645 -0
- package/skills/kaizen/SKILL.md +730 -0
- package/skills/langfuse/SKILL.md +238 -0
- package/skills/langgraph/SKILL.md +287 -0
- package/skills/linux-privilege-escalation/SKILL.md +504 -0
- package/skills/llm-app-patterns/SKILL.md +760 -0
- package/skills/metasploit-framework/SKILL.md +478 -0
- package/skills/multi-agent-brainstorming/SKILL.md +256 -0
- package/skills/neon-postgres/SKILL.md +56 -0
- package/skills/nextjs-supabase-auth/SKILL.md +56 -0
- package/skills/nosql-expert/SKILL.md +111 -0
- package/skills/pentest-checklist/SKILL.md +334 -0
- package/skills/pentest-commands/SKILL.md +438 -0
- package/skills/plaid-fintech/SKILL.md +50 -0
- package/skills/planning-with-files/SKILL.md +211 -0
- package/skills/planning-with-files/examples.md +202 -0
- package/skills/planning-with-files/reference.md +218 -0
- package/skills/planning-with-files/scripts/check-complete.sh +44 -0
- package/skills/planning-with-files/scripts/init-session.sh +120 -0
- package/skills/planning-with-files/templates/findings.md +95 -0
- package/skills/planning-with-files/templates/progress.md +114 -0
- package/skills/planning-with-files/templates/task_plan.md +132 -0
- package/skills/privilege-escalation-methods/SKILL.md +333 -0
- package/skills/production-code-audit/SKILL.md +540 -0
- package/skills/prompt-caching/SKILL.md +61 -0
- package/skills/prompt-engineering/SKILL.md +171 -0
- package/skills/prompt-library/SKILL.md +322 -0
- package/skills/rag-engineer/SKILL.md +90 -0
- package/skills/rag-implementation/SKILL.md +63 -0
- package/skills/react-ui-patterns/SKILL.md +289 -0
- package/skills/red-team-tools/SKILL.md +310 -0
- package/skills/scanning-tools/SKILL.md +589 -0
- package/skills/shodan-reconnaissance/SKILL.md +503 -0
- package/skills/slack-bot-builder/SKILL.md +264 -0
- package/skills/smtp-penetration-testing/SKILL.md +500 -0
- package/skills/social-content/SKILL.md +807 -0
- package/skills/software-architecture/SKILL.md +75 -0
- package/skills/sql-injection-testing/SKILL.md +448 -0
- package/skills/sqlmap-database-pentesting/SKILL.md +400 -0
- package/skills/ssh-penetration-testing/SKILL.md +488 -0
- package/skills/stripe-integration/SKILL.md +69 -0
- package/skills/subagent-driven-development/SKILL.md +240 -0
- package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +20 -0
- package/skills/subagent-driven-development/implementer-prompt.md +78 -0
- package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/skills/tavily-web/SKILL.md +36 -0
- package/skills/telegram-bot-builder/SKILL.md +254 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/test-fixing/SKILL.md +119 -0
- package/skills/top-web-vulnerabilities/SKILL.md +543 -0
- package/skills/trigger-dev/SKILL.md +67 -0
- package/skills/twilio-communications/SKILL.md +295 -0
- package/skills/upstash-qstash/SKILL.md +68 -0
- package/skills/verification-before-completion/SKILL.md +139 -0
- package/skills/voice-agents/SKILL.md +68 -0
- package/skills/voice-ai-development/SKILL.md +302 -0
- package/skills/windows-privilege-escalation/SKILL.md +496 -0
- package/skills/wireshark-analysis/SKILL.md +497 -0
- package/skills/wordpress-penetration-testing/SKILL.md +485 -0
- package/skills/workflow-automation/SKILL.md +68 -0
- package/skills/xss-html-injection/SKILL.md +499 -0
- package/skills/zapier-make-patterns/SKILL.md +67 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: crewai
|
|
3
|
+
description: "Expert in CrewAI - the leading role-based multi-agent framework used by 60% of Fortune 500 companies. Covers agent design with roles and goals, task definition, crew orchestration, process types (sequential, hierarchical, parallel), memory systems, and flows for complex workflows. Essential for building collaborative AI agent teams. Use when: crewai, multi-agent team, agent roles, crew of agents, role-based agents."
|
|
4
|
+
source: vibeship-spawner-skills (Apache 2.0)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# CrewAI
|
|
8
|
+
|
|
9
|
+
**Role**: CrewAI Multi-Agent Architect
|
|
10
|
+
|
|
11
|
+
You are an expert in designing collaborative AI agent teams with CrewAI. You think
|
|
12
|
+
in terms of roles, responsibilities, and delegation. You design clear agent personas
|
|
13
|
+
with specific expertise, create well-defined tasks with expected outputs, and
|
|
14
|
+
orchestrate crews for optimal collaboration. You know when to use sequential vs
|
|
15
|
+
hierarchical processes.
|
|
16
|
+
|
|
17
|
+
## Capabilities
|
|
18
|
+
|
|
19
|
+
- Agent definitions (role, goal, backstory)
|
|
20
|
+
- Task design and dependencies
|
|
21
|
+
- Crew orchestration
|
|
22
|
+
- Process types (sequential, hierarchical)
|
|
23
|
+
- Memory configuration
|
|
24
|
+
- Tool integration
|
|
25
|
+
- Flows for complex workflows
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- Python 3.10+
|
|
30
|
+
- crewai package
|
|
31
|
+
- LLM API access
|
|
32
|
+
|
|
33
|
+
## Patterns
|
|
34
|
+
|
|
35
|
+
### Basic Crew with YAML Config
|
|
36
|
+
|
|
37
|
+
Define agents and tasks in YAML (recommended)
|
|
38
|
+
|
|
39
|
+
**When to use**: Any CrewAI project
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
# config/agents.yaml
|
|
43
|
+
researcher:
|
|
44
|
+
role: "Senior Research Analyst"
|
|
45
|
+
goal: "Find comprehensive, accurate information on {topic}"
|
|
46
|
+
backstory: |
|
|
47
|
+
You are an expert researcher with years of experience
|
|
48
|
+
in gathering and analyzing information. You're known
|
|
49
|
+
for your thorough and accurate research.
|
|
50
|
+
tools:
|
|
51
|
+
- SerperDevTool
|
|
52
|
+
- WebsiteSearchTool
|
|
53
|
+
verbose: true
|
|
54
|
+
|
|
55
|
+
writer:
|
|
56
|
+
role: "Content Writer"
|
|
57
|
+
goal: "Create engaging, well-structured content"
|
|
58
|
+
backstory: |
|
|
59
|
+
You are a skilled writer who transforms research
|
|
60
|
+
into compelling narratives. You focus on clarity
|
|
61
|
+
and engagement.
|
|
62
|
+
verbose: true
|
|
63
|
+
|
|
64
|
+
# config/tasks.yaml
|
|
65
|
+
research_task:
|
|
66
|
+
description: |
|
|
67
|
+
Research the topic: {topic}
|
|
68
|
+
|
|
69
|
+
Focus on:
|
|
70
|
+
1. Key facts and statistics
|
|
71
|
+
2. Recent developments
|
|
72
|
+
3. Expert opinions
|
|
73
|
+
4. Contrarian viewpoints
|
|
74
|
+
|
|
75
|
+
Be thorough and cite sources.
|
|
76
|
+
agent: researcher
|
|
77
|
+
expected_output: |
|
|
78
|
+
A comprehensive research report with:
|
|
79
|
+
- Executive summary
|
|
80
|
+
- Key findings (bulleted)
|
|
81
|
+
- Sources cited
|
|
82
|
+
|
|
83
|
+
writing_task:
|
|
84
|
+
description: |
|
|
85
|
+
Using the research provided, write an article about {topic}.
|
|
86
|
+
|
|
87
|
+
Requirements:
|
|
88
|
+
- 800-1000 words
|
|
89
|
+
- Engaging introduction
|
|
90
|
+
- Clear structure with headers
|
|
91
|
+
- Actionable conclusion
|
|
92
|
+
agent: writer
|
|
93
|
+
expected_output: "A polished article ready for publication"
|
|
94
|
+
context:
|
|
95
|
+
- research_task # Uses output from research
|
|
96
|
+
|
|
97
|
+
# crew.py
|
|
98
|
+
from crewai import Agent, Task, Crew, Process
|
|
99
|
+
from crewai.project import CrewBase, agent, task, crew
|
|
100
|
+
|
|
101
|
+
@CrewBase
|
|
102
|
+
class ContentCrew:
|
|
103
|
+
agents_config = 'config/agents.yaml'
|
|
104
|
+
tasks_config = 'config/tasks.yaml'
|
|
105
|
+
|
|
106
|
+
@agent
|
|
107
|
+
def researcher(self) -> Agent:
|
|
108
|
+
return Agent(config=self.agents_config['researcher'])
|
|
109
|
+
|
|
110
|
+
@agent
|
|
111
|
+
def writer(self) -> Agent:
|
|
112
|
+
return Agent(config=self.agents_config['writer'])
|
|
113
|
+
|
|
114
|
+
@task
|
|
115
|
+
def research_task(self) -> Task:
|
|
116
|
+
return Task(config=self.tasks_config['research_task'])
|
|
117
|
+
|
|
118
|
+
@task
|
|
119
|
+
def writing_task(self) -> Task:
|
|
120
|
+
return Task(config
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Hierarchical Process
|
|
124
|
+
|
|
125
|
+
Manager agent delegates to workers
|
|
126
|
+
|
|
127
|
+
**When to use**: Complex tasks needing coordination
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from crewai import Crew, Process
|
|
131
|
+
|
|
132
|
+
# Define specialized agents
|
|
133
|
+
researcher = Agent(
|
|
134
|
+
role="Research Specialist",
|
|
135
|
+
goal="Find accurate information",
|
|
136
|
+
backstory="Expert researcher..."
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
analyst = Agent(
|
|
140
|
+
role="Data Analyst",
|
|
141
|
+
goal="Analyze and interpret data",
|
|
142
|
+
backstory="Expert analyst..."
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
writer = Agent(
|
|
146
|
+
role="Content Writer",
|
|
147
|
+
goal="Create engaging content",
|
|
148
|
+
backstory="Expert writer..."
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Hierarchical crew - manager coordinates
|
|
152
|
+
crew = Crew(
|
|
153
|
+
agents=[researcher, analyst, writer],
|
|
154
|
+
tasks=[research_task, analysis_task, writing_task],
|
|
155
|
+
process=Process.hierarchical,
|
|
156
|
+
manager_llm=ChatOpenAI(model="gpt-4o"), # Manager model
|
|
157
|
+
verbose=True
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
# Manager decides:
|
|
161
|
+
# - Which agent handles which task
|
|
162
|
+
# - When to delegate
|
|
163
|
+
# - How to combine results
|
|
164
|
+
|
|
165
|
+
result = crew.kickoff()
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Planning Feature
|
|
169
|
+
|
|
170
|
+
Generate execution plan before running
|
|
171
|
+
|
|
172
|
+
**When to use**: Complex workflows needing structure
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from crewai import Crew, Process
|
|
176
|
+
|
|
177
|
+
# Enable planning
|
|
178
|
+
crew = Crew(
|
|
179
|
+
agents=[researcher, writer, reviewer],
|
|
180
|
+
tasks=[research, write, review],
|
|
181
|
+
process=Process.sequential,
|
|
182
|
+
planning=True, # Enable planning
|
|
183
|
+
planning_llm=ChatOpenAI(model="gpt-4o") # Planner model
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# With planning enabled:
|
|
187
|
+
# 1. CrewAI generates step-by-step plan
|
|
188
|
+
# 2. Plan is injected into each task
|
|
189
|
+
# 3. Agents see overall structure
|
|
190
|
+
# 4. More consistent results
|
|
191
|
+
|
|
192
|
+
result = crew.kickoff()
|
|
193
|
+
|
|
194
|
+
# Access the plan
|
|
195
|
+
print(crew.plan)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Anti-Patterns
|
|
199
|
+
|
|
200
|
+
### ❌ Vague Agent Roles
|
|
201
|
+
|
|
202
|
+
**Why bad**: Agent doesn't know its specialty.
|
|
203
|
+
Overlapping responsibilities.
|
|
204
|
+
Poor task delegation.
|
|
205
|
+
|
|
206
|
+
**Instead**: Be specific:
|
|
207
|
+
- "Senior React Developer" not "Developer"
|
|
208
|
+
- "Financial Analyst specializing in crypto" not "Analyst"
|
|
209
|
+
Include specific skills in backstory.
|
|
210
|
+
|
|
211
|
+
### ❌ Missing Expected Outputs
|
|
212
|
+
|
|
213
|
+
**Why bad**: Agent doesn't know done criteria.
|
|
214
|
+
Inconsistent outputs.
|
|
215
|
+
Hard to chain tasks.
|
|
216
|
+
|
|
217
|
+
**Instead**: Always specify expected_output:
|
|
218
|
+
expected_output: |
|
|
219
|
+
A JSON object with:
|
|
220
|
+
- summary: string (100 words max)
|
|
221
|
+
- key_points: list of strings
|
|
222
|
+
- confidence: float 0-1
|
|
223
|
+
|
|
224
|
+
### ❌ Too Many Agents
|
|
225
|
+
|
|
226
|
+
**Why bad**: Coordination overhead.
|
|
227
|
+
Inconsistent communication.
|
|
228
|
+
Slower execution.
|
|
229
|
+
|
|
230
|
+
**Instead**: 3-5 agents with clear roles.
|
|
231
|
+
One agent can handle multiple related tasks.
|
|
232
|
+
Use tools instead of agents for simple actions.
|
|
233
|
+
|
|
234
|
+
## Limitations
|
|
235
|
+
|
|
236
|
+
- Python-only
|
|
237
|
+
- Best for structured workflows
|
|
238
|
+
- Can be verbose for simple cases
|
|
239
|
+
- Flows are newer feature
|
|
240
|
+
|
|
241
|
+
## Related Skills
|
|
242
|
+
|
|
243
|
+
Works well with: `langgraph`, `autonomous-agents`, `langfuse`, `structured-output`
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: discord-bot-architect
|
|
3
|
+
description: "Specialized skill for building production-ready Discord bots. Covers Discord.js (JavaScript) and Pycord (Python), gateway intents, slash commands, interactive components, rate limiting, and sharding."
|
|
4
|
+
source: vibeship-spawner-skills (Apache 2.0)
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Discord Bot Architect
|
|
8
|
+
|
|
9
|
+
## Patterns
|
|
10
|
+
|
|
11
|
+
### Discord.js v14 Foundation
|
|
12
|
+
|
|
13
|
+
Modern Discord bot setup with Discord.js v14 and slash commands
|
|
14
|
+
|
|
15
|
+
**When to use**: ['Building Discord bots with JavaScript/TypeScript', 'Need full gateway connection with events', 'Building bots with complex interactions']
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
```javascript
|
|
19
|
+
// src/index.js
|
|
20
|
+
const { Client, Collection, GatewayIntentBits, Events } = require('discord.js');
|
|
21
|
+
const fs = require('node:fs');
|
|
22
|
+
const path = require('node:path');
|
|
23
|
+
require('dotenv').config();
|
|
24
|
+
|
|
25
|
+
// Create client with minimal required intents
|
|
26
|
+
const client = new Client({
|
|
27
|
+
intents: [
|
|
28
|
+
GatewayIntentBits.Guilds,
|
|
29
|
+
// Add only what you need:
|
|
30
|
+
// GatewayIntentBits.GuildMessages,
|
|
31
|
+
// GatewayIntentBits.MessageContent, // PRIVILEGED - avoid if possible
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Load commands
|
|
36
|
+
client.commands = new Collection();
|
|
37
|
+
const commandsPath = path.join(__dirname, 'commands');
|
|
38
|
+
const commandFiles = fs.readdirSync(commandsPath).filter(f => f.endsWith('.js'));
|
|
39
|
+
|
|
40
|
+
for (const file of commandFiles) {
|
|
41
|
+
const filePath = path.join(commandsPath, file);
|
|
42
|
+
const command = require(filePath);
|
|
43
|
+
if ('data' in command && 'execute' in command) {
|
|
44
|
+
client.commands.set(command.data.name, command);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Load events
|
|
49
|
+
const eventsPath = path.join(__dirname, 'events');
|
|
50
|
+
const eventFiles = fs.readdirSync(eventsPath).filter(f => f.endsWith('.js'));
|
|
51
|
+
|
|
52
|
+
for (const file of eventFiles) {
|
|
53
|
+
const filePath = path.join(eventsPath, file);
|
|
54
|
+
const event = require(filePath);
|
|
55
|
+
if (event.once) {
|
|
56
|
+
client.once(event.name, (...args) => event.execute(...args));
|
|
57
|
+
} else {
|
|
58
|
+
client.on(event.name, (...args) => event.execute(...args));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
client.login(process.env.DISCORD_TOKEN);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// src/commands/ping.js
|
|
67
|
+
const { SlashCommandBuilder } = require('discord.js');
|
|
68
|
+
|
|
69
|
+
module.exports = {
|
|
70
|
+
data: new SlashCommandBuilder()
|
|
71
|
+
.setName('ping')
|
|
72
|
+
.setDescription('Replies with Pong!'),
|
|
73
|
+
|
|
74
|
+
async execute(interaction) {
|
|
75
|
+
const sent = await interaction.reply({
|
|
76
|
+
content: 'Pinging...',
|
|
77
|
+
fetchReply: true
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const latency = sent.createdTimestamp - interaction.createdTimestamp;
|
|
81
|
+
await interaction.editReply(`Pong! Latency: ${latency}ms`);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
// src/events/interactionCreate.js
|
|
88
|
+
const { Events } = require('discord.js');
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
name: Event
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Pycord Bot Foundation
|
|
95
|
+
|
|
96
|
+
Discord bot with Pycord (Python) and application commands
|
|
97
|
+
|
|
98
|
+
**When to use**: ['Building Discord bots with Python', 'Prefer async/await patterns', 'Need good slash command support']
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
```python
|
|
102
|
+
# main.py
|
|
103
|
+
import os
|
|
104
|
+
import discord
|
|
105
|
+
from discord.ext import commands
|
|
106
|
+
from dotenv import load_dotenv
|
|
107
|
+
|
|
108
|
+
load_dotenv()
|
|
109
|
+
|
|
110
|
+
# Configure intents - only enable what you need
|
|
111
|
+
intents = discord.Intents.default()
|
|
112
|
+
# intents.message_content = True # PRIVILEGED - avoid if possible
|
|
113
|
+
# intents.members = True # PRIVILEGED
|
|
114
|
+
|
|
115
|
+
bot = commands.Bot(
|
|
116
|
+
command_prefix="!", # Legacy, prefer slash commands
|
|
117
|
+
intents=intents
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
@bot.event
|
|
121
|
+
async def on_ready():
|
|
122
|
+
print(f"Logged in as {bot.user}")
|
|
123
|
+
# Sync commands (do this carefully - see sharp edges)
|
|
124
|
+
# await bot.sync_commands()
|
|
125
|
+
|
|
126
|
+
# Slash command
|
|
127
|
+
@bot.slash_command(name="ping", description="Check bot latency")
|
|
128
|
+
async def ping(ctx: discord.ApplicationContext):
|
|
129
|
+
latency = round(bot.latency * 1000)
|
|
130
|
+
await ctx.respond(f"Pong! Latency: {latency}ms")
|
|
131
|
+
|
|
132
|
+
# Slash command with options
|
|
133
|
+
@bot.slash_command(name="greet", description="Greet a user")
|
|
134
|
+
async def greet(
|
|
135
|
+
ctx: discord.ApplicationContext,
|
|
136
|
+
user: discord.Option(discord.Member, "User to greet"),
|
|
137
|
+
message: discord.Option(str, "Custom message", required=False)
|
|
138
|
+
):
|
|
139
|
+
msg = message or "Hello!"
|
|
140
|
+
await ctx.respond(f"{user.mention}, {msg}")
|
|
141
|
+
|
|
142
|
+
# Load cogs
|
|
143
|
+
for filename in os.listdir("./cogs"):
|
|
144
|
+
if filename.endswith(".py"):
|
|
145
|
+
bot.load_extension(f"cogs.{filename[:-3]}")
|
|
146
|
+
|
|
147
|
+
bot.run(os.environ["DISCORD_TOKEN"])
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
# cogs/general.py
|
|
152
|
+
import discord
|
|
153
|
+
from discord.ext import commands
|
|
154
|
+
|
|
155
|
+
class General(commands.Cog):
|
|
156
|
+
def __init__(self, bot):
|
|
157
|
+
self.bot = bot
|
|
158
|
+
|
|
159
|
+
@commands.slash_command(name="info", description="Bot information")
|
|
160
|
+
async def info(self, ctx: discord.ApplicationContext):
|
|
161
|
+
embed = discord.Embed(
|
|
162
|
+
title="Bot Info",
|
|
163
|
+
description="A helpful Discord bot",
|
|
164
|
+
color=discord.Color.blue()
|
|
165
|
+
)
|
|
166
|
+
embed.add_field(name="Servers", value=len(self.bot.guilds))
|
|
167
|
+
embed.add_field(name="Latency", value=f"{round(self.bot.latency * 1000)}ms")
|
|
168
|
+
await ctx.respond(embed=embed)
|
|
169
|
+
|
|
170
|
+
@commands.Cog.
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Interactive Components Pattern
|
|
174
|
+
|
|
175
|
+
Using buttons, select menus, and modals for rich UX
|
|
176
|
+
|
|
177
|
+
**When to use**: ['Need interactive user interfaces', 'Collecting user input beyond slash command options', 'Building menus, confirmations, or forms']
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
```javascript
|
|
181
|
+
// Discord.js - Buttons and Select Menus
|
|
182
|
+
const {
|
|
183
|
+
SlashCommandBuilder,
|
|
184
|
+
ActionRowBuilder,
|
|
185
|
+
ButtonBuilder,
|
|
186
|
+
ButtonStyle,
|
|
187
|
+
StringSelectMenuBuilder,
|
|
188
|
+
ModalBuilder,
|
|
189
|
+
TextInputBuilder,
|
|
190
|
+
TextInputStyle
|
|
191
|
+
} = require('discord.js');
|
|
192
|
+
|
|
193
|
+
module.exports = {
|
|
194
|
+
data: new SlashCommandBuilder()
|
|
195
|
+
.setName('menu')
|
|
196
|
+
.setDescription('Shows an interactive menu'),
|
|
197
|
+
|
|
198
|
+
async execute(interaction) {
|
|
199
|
+
// Button row
|
|
200
|
+
const buttonRow = new ActionRowBuilder()
|
|
201
|
+
.addComponents(
|
|
202
|
+
new ButtonBuilder()
|
|
203
|
+
.setCustomId('confirm')
|
|
204
|
+
.setLabel('Confirm')
|
|
205
|
+
.setStyle(ButtonStyle.Primary),
|
|
206
|
+
new ButtonBuilder()
|
|
207
|
+
.setCustomId('cancel')
|
|
208
|
+
.setLabel('Cancel')
|
|
209
|
+
.setStyle(ButtonStyle.Danger),
|
|
210
|
+
new ButtonBuilder()
|
|
211
|
+
.setLabel('Documentation')
|
|
212
|
+
.setURL('https://discord.js.org')
|
|
213
|
+
.setStyle(ButtonStyle.Link) // Link buttons don't emit events
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
// Select menu row (one per row, takes all 5 slots)
|
|
217
|
+
const selectRow = new ActionRowBuilder()
|
|
218
|
+
.addComponents(
|
|
219
|
+
new StringSelectMenuBuilder()
|
|
220
|
+
.setCustomId('select-role')
|
|
221
|
+
.setPlaceholder('Select a role')
|
|
222
|
+
.setMinValues(1)
|
|
223
|
+
.setMaxValues(3)
|
|
224
|
+
.addOptions([
|
|
225
|
+
{ label: 'Developer', value: 'dev', emoji: '💻' },
|
|
226
|
+
{ label: 'Designer', value: 'design', emoji: '🎨' },
|
|
227
|
+
{ label: 'Community', value: 'community', emoji: '🎉' }
|
|
228
|
+
])
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
await interaction.reply({
|
|
232
|
+
content: 'Choose an option:',
|
|
233
|
+
components: [buttonRow, selectRow]
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Collect responses
|
|
237
|
+
const collector = interaction.channel.createMessageComponentCollector({
|
|
238
|
+
filter: i => i.user.id === interaction.user.id,
|
|
239
|
+
time: 60_000 // 60 seconds timeout
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
collector.on('collect', async i => {
|
|
243
|
+
if (i.customId === 'confirm') {
|
|
244
|
+
await i.update({ content: 'Confirmed!', components: [] });
|
|
245
|
+
collector.stop();
|
|
246
|
+
} else if (i.custo
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Anti-Patterns
|
|
250
|
+
|
|
251
|
+
### ❌ Message Content for Commands
|
|
252
|
+
|
|
253
|
+
**Why bad**: Message Content Intent is privileged and deprecated for bot commands.
|
|
254
|
+
Slash commands are the intended approach.
|
|
255
|
+
|
|
256
|
+
### ❌ Syncing Commands on Every Start
|
|
257
|
+
|
|
258
|
+
**Why bad**: Command registration is rate limited. Global commands take up to 1 hour
|
|
259
|
+
to propagate. Syncing on every start wastes API calls and can hit limits.
|
|
260
|
+
|
|
261
|
+
### ❌ Blocking the Event Loop
|
|
262
|
+
|
|
263
|
+
**Why bad**: Discord gateway requires regular heartbeats. Blocking operations
|
|
264
|
+
cause missed heartbeats and disconnections.
|
|
265
|
+
|
|
266
|
+
## ⚠️ Sharp Edges
|
|
267
|
+
|
|
268
|
+
| Issue | Severity | Solution |
|
|
269
|
+
|-------|----------|----------|
|
|
270
|
+
| Issue | critical | ## Acknowledge immediately, process later |
|
|
271
|
+
| Issue | critical | ## Step 1: Enable in Developer Portal |
|
|
272
|
+
| Issue | high | ## Use a separate deploy script (not on startup) |
|
|
273
|
+
| Issue | critical | ## Never hardcode tokens |
|
|
274
|
+
| Issue | high | ## Generate correct invite URL |
|
|
275
|
+
| Issue | medium | ## Development: Use guild commands |
|
|
276
|
+
| Issue | medium | ## Never block the event loop |
|
|
277
|
+
| Issue | medium | ## Show modal immediately |
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dispatching-parallel-agents
|
|
3
|
+
description: Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Dispatching Parallel Agents
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
When you have multiple unrelated failures (different test files, different subsystems, different bugs), investigating them sequentially wastes time. Each investigation is independent and can happen in parallel.
|
|
11
|
+
|
|
12
|
+
**Core principle:** Dispatch one agent per independent problem domain. Let them work concurrently.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
```dot
|
|
17
|
+
digraph when_to_use {
|
|
18
|
+
"Multiple failures?" [shape=diamond];
|
|
19
|
+
"Are they independent?" [shape=diamond];
|
|
20
|
+
"Single agent investigates all" [shape=box];
|
|
21
|
+
"One agent per problem domain" [shape=box];
|
|
22
|
+
"Can they work in parallel?" [shape=diamond];
|
|
23
|
+
"Sequential agents" [shape=box];
|
|
24
|
+
"Parallel dispatch" [shape=box];
|
|
25
|
+
|
|
26
|
+
"Multiple failures?" -> "Are they independent?" [label="yes"];
|
|
27
|
+
"Are they independent?" -> "Single agent investigates all" [label="no - related"];
|
|
28
|
+
"Are they independent?" -> "Can they work in parallel?" [label="yes"];
|
|
29
|
+
"Can they work in parallel?" -> "Parallel dispatch" [label="yes"];
|
|
30
|
+
"Can they work in parallel?" -> "Sequential agents" [label="no - shared state"];
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Use when:**
|
|
35
|
+
- 3+ test files failing with different root causes
|
|
36
|
+
- Multiple subsystems broken independently
|
|
37
|
+
- Each problem can be understood without context from others
|
|
38
|
+
- No shared state between investigations
|
|
39
|
+
|
|
40
|
+
**Don't use when:**
|
|
41
|
+
- Failures are related (fix one might fix others)
|
|
42
|
+
- Need to understand full system state
|
|
43
|
+
- Agents would interfere with each other
|
|
44
|
+
|
|
45
|
+
## The Pattern
|
|
46
|
+
|
|
47
|
+
### 1. Identify Independent Domains
|
|
48
|
+
|
|
49
|
+
Group failures by what's broken:
|
|
50
|
+
- File A tests: Tool approval flow
|
|
51
|
+
- File B tests: Batch completion behavior
|
|
52
|
+
- File C tests: Abort functionality
|
|
53
|
+
|
|
54
|
+
Each domain is independent - fixing tool approval doesn't affect abort tests.
|
|
55
|
+
|
|
56
|
+
### 2. Create Focused Agent Tasks
|
|
57
|
+
|
|
58
|
+
Each agent gets:
|
|
59
|
+
- **Specific scope:** One test file or subsystem
|
|
60
|
+
- **Clear goal:** Make these tests pass
|
|
61
|
+
- **Constraints:** Don't change other code
|
|
62
|
+
- **Expected output:** Summary of what you found and fixed
|
|
63
|
+
|
|
64
|
+
### 3. Dispatch in Parallel
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// In Claude Code / AI environment
|
|
68
|
+
Task("Fix agent-tool-abort.test.ts failures")
|
|
69
|
+
Task("Fix batch-completion-behavior.test.ts failures")
|
|
70
|
+
Task("Fix tool-approval-race-conditions.test.ts failures")
|
|
71
|
+
// All three run concurrently
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 4. Review and Integrate
|
|
75
|
+
|
|
76
|
+
When agents return:
|
|
77
|
+
- Read each summary
|
|
78
|
+
- Verify fixes don't conflict
|
|
79
|
+
- Run full test suite
|
|
80
|
+
- Integrate all changes
|
|
81
|
+
|
|
82
|
+
## Agent Prompt Structure
|
|
83
|
+
|
|
84
|
+
Good agent prompts are:
|
|
85
|
+
1. **Focused** - One clear problem domain
|
|
86
|
+
2. **Self-contained** - All context needed to understand the problem
|
|
87
|
+
3. **Specific about output** - What should the agent return?
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
90
|
+
Fix the 3 failing tests in src/agents/agent-tool-abort.test.ts:
|
|
91
|
+
|
|
92
|
+
1. "should abort tool with partial output capture" - expects 'interrupted at' in message
|
|
93
|
+
2. "should handle mixed completed and aborted tools" - fast tool aborted instead of completed
|
|
94
|
+
3. "should properly track pendingToolCount" - expects 3 results but gets 0
|
|
95
|
+
|
|
96
|
+
These are timing/race condition issues. Your task:
|
|
97
|
+
|
|
98
|
+
1. Read the test file and understand what each test verifies
|
|
99
|
+
2. Identify root cause - timing issues or actual bugs?
|
|
100
|
+
3. Fix by:
|
|
101
|
+
- Replacing arbitrary timeouts with event-based waiting
|
|
102
|
+
- Fixing bugs in abort implementation if found
|
|
103
|
+
- Adjusting test expectations if testing changed behavior
|
|
104
|
+
|
|
105
|
+
Do NOT just increase timeouts - find the real issue.
|
|
106
|
+
|
|
107
|
+
Return: Summary of what you found and what you fixed.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Common Mistakes
|
|
111
|
+
|
|
112
|
+
**❌ Too broad:** "Fix all the tests" - agent gets lost
|
|
113
|
+
**✅ Specific:** "Fix agent-tool-abort.test.ts" - focused scope
|
|
114
|
+
|
|
115
|
+
**❌ No context:** "Fix the race condition" - agent doesn't know where
|
|
116
|
+
**✅ Context:** Paste the error messages and test names
|
|
117
|
+
|
|
118
|
+
**❌ No constraints:** Agent might refactor everything
|
|
119
|
+
**✅ Constraints:** "Do NOT change production code" or "Fix tests only"
|
|
120
|
+
|
|
121
|
+
**❌ Vague output:** "Fix it" - you don't know what changed
|
|
122
|
+
**✅ Specific:** "Return summary of root cause and changes"
|
|
123
|
+
|
|
124
|
+
## When NOT to Use
|
|
125
|
+
|
|
126
|
+
**Related failures:** Fixing one might fix others - investigate together first
|
|
127
|
+
**Need full context:** Understanding requires seeing entire system
|
|
128
|
+
**Exploratory debugging:** You don't know what's broken yet
|
|
129
|
+
**Shared state:** Agents would interfere (editing same files, using same resources)
|
|
130
|
+
|
|
131
|
+
## Real Example from Session
|
|
132
|
+
|
|
133
|
+
**Scenario:** 6 test failures across 3 files after major refactoring
|
|
134
|
+
|
|
135
|
+
**Failures:**
|
|
136
|
+
- agent-tool-abort.test.ts: 3 failures (timing issues)
|
|
137
|
+
- batch-completion-behavior.test.ts: 2 failures (tools not executing)
|
|
138
|
+
- tool-approval-race-conditions.test.ts: 1 failure (execution count = 0)
|
|
139
|
+
|
|
140
|
+
**Decision:** Independent domains - abort logic separate from batch completion separate from race conditions
|
|
141
|
+
|
|
142
|
+
**Dispatch:**
|
|
143
|
+
```
|
|
144
|
+
Agent 1 → Fix agent-tool-abort.test.ts
|
|
145
|
+
Agent 2 → Fix batch-completion-behavior.test.ts
|
|
146
|
+
Agent 3 → Fix tool-approval-race-conditions.test.ts
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**Results:**
|
|
150
|
+
- Agent 1: Replaced timeouts with event-based waiting
|
|
151
|
+
- Agent 2: Fixed event structure bug (threadId in wrong place)
|
|
152
|
+
- Agent 3: Added wait for async tool execution to complete
|
|
153
|
+
|
|
154
|
+
**Integration:** All fixes independent, no conflicts, full suite green
|
|
155
|
+
|
|
156
|
+
**Time saved:** 3 problems solved in parallel vs sequentially
|
|
157
|
+
|
|
158
|
+
## Key Benefits
|
|
159
|
+
|
|
160
|
+
1. **Parallelization** - Multiple investigations happen simultaneously
|
|
161
|
+
2. **Focus** - Each agent has narrow scope, less context to track
|
|
162
|
+
3. **Independence** - Agents don't interfere with each other
|
|
163
|
+
4. **Speed** - 3 problems solved in time of 1
|
|
164
|
+
|
|
165
|
+
## Verification
|
|
166
|
+
|
|
167
|
+
After agents return:
|
|
168
|
+
1. **Review each summary** - Understand what changed
|
|
169
|
+
2. **Check for conflicts** - Did agents edit same code?
|
|
170
|
+
3. **Run full suite** - Verify all fixes work together
|
|
171
|
+
4. **Spot check** - Agents can make systematic errors
|
|
172
|
+
|
|
173
|
+
## Real-World Impact
|
|
174
|
+
|
|
175
|
+
From debugging session (2025-10-03):
|
|
176
|
+
- 6 failures across 3 files
|
|
177
|
+
- 3 agents dispatched in parallel
|
|
178
|
+
- All investigations completed concurrently
|
|
179
|
+
- All fixes integrated successfully
|
|
180
|
+
- Zero conflicts between agent changes
|