Loading...
Loading...
Compare original and translation side by side
Skill by ara.so — Hermes Skills collection.
SOUL.md由ara.so提供的Skill——Hermes技能合集。
SOUL.mdundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedSOUL.mdundefinedSOUL.mdundefinedundefinedundefined// Example: Setting up the Orion project manager agent
const fs = require('fs');
const path = require('path');
// Copy Orion template
const orionSOUL = fs.readFileSync(
path.join(__dirname, 'agents/productivity/orion/SOUL.md'),
'utf8'
);
// Save to your project
fs.writeFileSync('./SOUL.md', orionSOUL);
// Use cases for Orion:
// - Daily task prioritization
// - Deadline tracking
// - Team alignment
// - Project status updates// 示例:配置Orion项目管理Agent
const fs = require('fs');
const path = require('path');
// 复制Orion模板
const orionSOUL = fs.readFileSync(
path.join(__dirname, 'agents/productivity/orion/SOUL.md'),
'utf8'
);
// 保存到你的项目中
fs.writeFileSync('./SOUL.md', orionSOUL);
// Orion的适用场景:
// - 每日任务优先级排序
// - 截止日期追踪
// - 团队对齐
// - 项目状态更新// Example: Code reviewer (Lens) setup
const lensConfig = {
agent: 'lens',
role: 'PR review, security scanning, code quality',
triggers: ['pr opened', 'pr updated'],
integrations: {
github: {
token: process.env.GITHUB_TOKEN,
webhooks: ['pull_request']
}
}
};
// Load template
const lensSOUL = fs.readFileSync(
'./agents/development/code-reviewer/SOUL.md',
'utf8'
);
// Configure for your repo
const customSOUL = lensSOUL.replace(
'{{REPO}}',
process.env.GITHUB_REPO
);// 示例:代码审核Agent(Lens)配置
const lensConfig = {
agent: 'lens',
role: 'PR审核、安全扫描、代码质量检查',
triggers: ['pr opened', 'pr updated'],
integrations: {
github: {
token: process.env.GITHUB_TOKEN,
webhooks: ['pull_request']
}
}
};
// 加载模板
const lensSOUL = fs.readFileSync(
'./agents/development/code-reviewer/SOUL.md',
'utf8'
);
// 为你的仓库自定义配置
const customSOUL = lensSOUL.replace(
'{{REPO}}',
process.env.GITHUB_REPO
);// Example: Content writer (Echo) agent
const echoTemplate = `// 示例:内容创作Agent(Echo)
const echoTemplate = `undefinedundefined// Daily standup collection agent
const standupAgent = {
schedule: '0 9 * * *', // 9 AM daily
action: 'collect standup responses',
integrations: ['slack'],
behavior: `
Send message to #standup channel:
"Good morning! Please share:
- Yesterday's progress
- Today's plans
- Blockers"
Collect responses for 30 minutes.
Generate summary report.
Post to #management channel.
`
};// 每日站会收集Agent
const standupAgent = {
schedule: '0 9 * * *', // 每天上午9点
action: '收集站会反馈',
integrations: ['slack'],
behavior: `
向#standup频道发送消息:
"早上好!请分享:
- 昨日进展
- 今日计划
- 遇到的阻塞"
收集30分钟内的反馈。
生成汇总报告。
发布到#management频道。
`
};// PR reviewer agent (webhooks)
const prReviewerAgent = {
trigger: 'github.pull_request.opened',
workflow: [
'Fetch PR diff',
'Analyze code changes',
'Check for security issues',
'Verify test coverage',
'Post review comment'
],
config: {
github: {
webhook_url: process.env.GITHUB_WEBHOOK_URL,
secret: process.env.GITHUB_WEBHOOK_SECRET
}
}
};// PR审核Agent(基于Webhook)
const prReviewerAgent = {
trigger: 'github.pull_request.opened',
workflow: [
'获取PR差异内容',
'分析代码变更',
'检查安全问题',
'验证测试覆盖率',
'发布审核评论'
],
config: {
github: {
webhook_url: process.env.GITHUB_WEBHOOK_URL,
secret: process.env.GITHUB_WEBHOOK_SECRET
}
}
};// Customer support agent
const supportAgent = {
interface: 'telegram',
memory: 'redis',
behavior: `
Greet users warmly.
Understand their issue through questions.
Search knowledge base for solutions.
If no solution found, escalate to human.
Track conversation history.
`,
integrations: {
telegram: {
token: process.env.TELEGRAM_BOT_TOKEN
},
redis: {
url: process.env.REDIS_URL
},
zendesk: {
api_key: process.env.ZENDESK_API_KEY,
subdomain: process.env.ZENDESK_SUBDOMAIN
}
}
};// 客户支持Agent
const supportAgent = {
interface: 'telegram',
memory: 'redis',
behavior: `
热情问候用户。
通过提问了解用户问题。
在知识库中搜索解决方案。
若未找到解决方案,升级至人工支持。
追踪对话历史。
`,
integrations: {
telegram: {
token: process.env.TELEGRAM_BOT_TOKEN
},
redis: {
url: process.env.REDIS_URL
},
zendesk: {
api_key: process.env.ZENDESK_API_KEY,
subdomain: process.env.ZENDESK_SUBDOMAIN
}
}
};// bot.js - Basic agent runner
const fs = require('fs');
const { OpenAI } = require('openai');
// Load SOUL.md configuration
const soulConfig = fs.readFileSync('./SOUL.md', 'utf8');
// Initialize OpenAI (or your LLM provider)
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
// Agent runtime
async function runAgent(userInput) {
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{
role: 'system',
content: soulConfig // SOUL.md defines behavior
},
{
role: 'user',
content: userInput
}
]
});
return completion.choices[0].message.content;
}
// Example usage
runAgent('What tasks are due today?').then(console.log);// bot.js - 基础Agent运行器
const fs = require('fs');
const { OpenAI } = require('openai');
// 加载SOUL.md配置
const soulConfig = fs.readFileSync('./SOUL.md', 'utf8');
// 初始化OpenAI(或你的大语言模型提供商)
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
// Agent运行逻辑
async function runAgent(userInput) {
const completion = await openai.chat.completions.create({
model: 'gpt-4',
messages: [
{
role: 'system',
content: soulConfig // SOUL.md定义Agent行为
},
{
role: 'user',
content: userInput
}
]
});
return completion.choices[0].message.content;
}
// 示例用法
runAgent('今天有哪些任务到期?').then(console.log);undefinedundefined
```yaml
```yamlundefinedundefinedundefinedundefinedundefinedundefined// Search agents.json programmatically
const agents = require('./agents.json');
function findAgent(useCase) {
return agents.filter(agent =>
agent.specialty.toLowerCase().includes(useCase.toLowerCase()) ||
agent.whenToUse.toLowerCase().includes(useCase.toLowerCase())
);
}
// Example: Find agents for "email"
const emailAgents = findAgent('email');
// Returns: [{ name: 'Inbox', specialty: 'Email triage...', ... }]// 通过agents.json程序式搜索
const agents = require('./agents.json');
function findAgent(useCase) {
return agents.filter(agent =>
agent.specialty.toLowerCase().includes(useCase.toLowerCase()) ||
agent.whenToUse.toLowerCase().includes(useCase.toLowerCase())
);
}
// 示例:查找与"邮件"相关的Agent
const emailAgents = findAgent('email');
// 返回:[{ name: 'Inbox', specialty: 'Email triage...', ... }]<!-- Original SOUL.md --><!-- 原始SOUL.md -->undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefined// multi-agent.js - Run multiple agents
const agents = [
{ name: 'orion', soul: './agents/productivity/orion/SOUL.md' },
{ name: 'lens', soul: './agents/development/code-reviewer/SOUL.md' },
{ name: 'echo', soul: './agents/marketing/echo/SOUL.md' }
];
agents.forEach(agent => {
const config = fs.readFileSync(agent.soul, 'utf8');
// Spawn agent process
const child = spawn('node', ['bot.js'], {
env: {
...process.env,
AGENT_NAME: agent.name,
SOUL_CONFIG: config
}
});
console.log(`Started ${agent.name} agent`);
});// multi-agent.js - 运行多个Agent
const agents = [
{ name: 'orion', soul: './agents/productivity/orion/SOUL.md' },
{ name: 'lens', soul: './agents/development/code-reviewer/SOUL.md' },
{ name: 'echo', soul: './agents/marketing/echo/SOUL.md' }
];
agents.forEach(agent => {
const config = fs.readFileSync(agent.soul, 'utf8');
// 启动Agent进程
const child = spawn('node', ['bot.js'], {
env: {
...process.env,
AGENT_NAME: agent.name,
SOUL_CONFIG: config
}
});
console.log(`已启动${agent.name} Agent`);
});// Debug mode
const DEBUG = process.env.DEBUG === 'true';
async function runAgent(input) {
if (DEBUG) {
console.log('Input:', input);
console.log('SOUL config length:', soulConfig.length);
}
try {
const response = await openai.chat.completions.create({...});
if (DEBUG) console.log('Response:', response);
return response.choices[0].message.content;
} catch (error) {
console.error('Agent error:', error.message);
return 'Error processing request';
}
}// 调试模式
const DEBUG = process.env.DEBUG === 'true';
async function runAgent(input) {
if (DEBUG) {
console.log('输入:', input);
console.log('SOUL配置长度:', soulConfig.length);
}
try {
const response = await openai.chat.completions.create({...});
if (DEBUG) console.log('响应:', response);
return response.choices[0].message.content;
} catch (error) {
console.error('Agent错误:', error.message);
return '处理请求时出错';
}
}# Check all required vars are set
node -e "console.log(process.env.OPENAI_API_KEY ? 'OK' : 'MISSING')"// Validate SOUL.md format
const soul = fs.readFileSync('./SOUL.md', 'utf8');
if (!soul.includes('# ')) {
throw new Error('Invalid SOUL.md: missing heading');
}// Test integrations independently
const testSlack = await fetch(process.env.SLACK_WEBHOOK_URL, {
method: 'POST',
body: JSON.stringify({ text: 'Test' })
});
console.log('Slack test:', testSlack.ok ? 'OK' : 'FAILED');# 检查所有必填变量是否已设置
node -e "console.log(process.env.OPENAI_API_KEY ? '已配置' : '缺失')"// 验证SOUL.md格式
const soul = fs.readFileSync('./SOUL.md', 'utf8');
if (!soul.includes('# ')) {
throw new Error('无效SOUL.md:缺少标题');
}// 独立测试集成工具
const testSlack = await fetch(process.env.SLACK_WEBHOOK_URL, {
method: 'POST',
body: JSON.stringify({ text: '测试消息' })
});
console.log('Slack测试:', testSlack.ok ? '成功' : '失败');// redis-memory.js - Persistent agent memory
const Redis = require('ioredis');
const redis = new Redis(process.env.REDIS_URL);
async function rememberContext(agentName, userId, context) {
const key = `agent:${agentName}:user:${userId}`;
await redis.set(key, JSON.stringify(context), 'EX', 86400); // 24h
}
async function recallContext(agentName, userId) {
const key = `agent:${agentName}:user:${userId}`;
const data = await redis.get(key);
return data ? JSON.parse(data) : null;
}
// Use in agent
const context = await recallContext('orion', userId);
const response = await runAgent(userInput, context);
await rememberContext('orion', userId, { ...context, lastInput: userInput });// redis-memory.js - Agent持久化记忆
const Redis = require('ioredis');
const redis = new Redis(process.env.REDIS_URL);
async function rememberContext(agentName, userId, context) {
const key = `agent:${agentName}:user:${userId}`;
await redis.set(key, JSON.stringify(context), 'EX', 86400); // 24小时有效期
}
async function recallContext(agentName, userId) {
const key = `agent:${agentName}:user:${userId}`;
const data = await redis.get(key);
return data ? JSON.parse(data) : null;
}
// 在Agent中使用
const context = await recallContext('orion', userId);
const response = await runAgent(userInput, context);
await rememberContext('orion', userId, { ...context, lastInput: userInput });// Chain multiple agents for complex workflows
async function processCustomerRequest(request) {
// Step 1: Categorize with support agent
const category = await runAgent('support',
`Categorize this request: ${request}`
);
// Step 2: Route to specialist
let specialist;
if (category.includes('technical')) specialist = 'tech-support';
else if (category.includes('billing')) specialist = 'billing';
else specialist = 'general';
// Step 3: Generate response
const response = await runAgent(specialist, request);
// Step 4: QA check
const qaResult = await runAgent('qa-agent',
`Review this response: ${response}`
);
return qaResult.includes('approved') ? response : 'Escalate to human';
}// 链式调用多个Agent处理复杂工作流
async function processCustomerRequest(request) {
// 步骤1:通过支持Agent分类请求
const category = await runAgent('support',
`对以下请求进行分类:${request}`
);
// 步骤2:路由到对应专家Agent
let specialist;
if (category.includes('技术')) specialist = 'tech-support';
else if (category.includes('账单')) specialist = 'billing';
else specialist = 'general';
// 步骤3:生成响应
const response = await runAgent(specialist, request);
// 步骤4:QA审核
const qaResult = await runAgent('qa-agent',
`审核以下响应:${response}`
);
return qaResult.includes('通过') ? response : '升级至人工处理';
}agents.jsonTROUBLESHOOTING.mdagents.jsonTROUBLESHOOTING.md