npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@aisd/sub-agents

v0.1.1

Published

Distributed intelligent agent system for AISD Toolkit

Readme

AISD Sub-Agents 系统

基于 Anthropic 的 sub-agents 模式实现的分布式智能代理系统,为 AISD Toolkit 提供专业化的 AI 能力。

特性

  • 专业化分工:每个 agent 专注特定领域,提供深度专业知识
  • 并行执行:支持多个 agents 并行工作,提高效率
  • 灵活组合:agents 可自由组合完成复杂任务
  • 消息总线:完善的 agent 间通信机制
  • 易于扩展:简单的 API 支持添加新的专业 agents

安装

pnpm add @aisd/sub-agents

快速开始

import { createOrchestrator } from '@aisd/sub-agents';

// 创建 orchestrator
const orchestrator = createOrchestrator();

// 执行需求分析
const result = await orchestrator.executeWorkflow({
  type: 'requirement-analysis',
  input: {
    rawRequirements: '用户需要一个实时协作的文档编辑器...',
    projectContext: {
      domain: 'collaboration-tools'
    }
  }
});

// 处理结果
if (result.success) {
  result.results.forEach((output, agentId) => {
    console.log(`${agentId}: `, output.data);
  });
}

可用的 Agents

Requirements Agent

  • ID: requirements-agent
  • 功能: 需求分析、EARS 转换、依赖识别
  • 输入: 原始需求文本、项目上下文
  • 输出: EARS 格式需求、澄清问题、风险评估

Architecture Agent (开发中)

  • ID: architecture-agent
  • 功能: 技术架构设计、技术选型
  • 输入: EARS 需求、技术约束
  • 输出: 架构图、技术栈建议、ADR

Testing Agent (开发中)

  • ID: testing-agent
  • 功能: 测试策略制定、测试用例生成
  • 输入: 需求、架构设计
  • 输出: 测试策略、测试用例、测试数据

Code Review Agent (开发中)

  • ID: code-review-agent
  • 功能: 代码质量审查、安全检查
  • 输入: 代码文件、审查标准
  • 输出: 问题列表、改进建议

Documentation Agent (开发中)

  • ID: documentation-agent
  • 功能: 文档生成、API 文档维护
  • 输入: 代码库、架构设计
  • 输出: 技术文档、API 文档、用户指南

Knowledge Agent (开发中)

  • ID: knowledge-agent
  • 功能: 知识提取、模式识别
  • 输入: 项目历史、代码变更
  • 输出: 最佳实践、经验教训

创建自定义 Agent

import { BaseAgent, AgentInput, ValidationResult } from '@aisd/sub-agents';

export class MyCustomAgent extends BaseAgent {
  constructor() {
    super({
      id: 'my-custom-agent',
      name: 'My Custom Agent',
      description: '自定义 agent 描述',
      capabilities: [
        {
          name: 'analyze',
          description: '分析功能'
        }
      ]
    });
  }

  protected async validateInput(input: AgentInput): Promise<ValidationResult> {
    // 验证输入
    return { valid: true };
  }

  protected async prepareContext(input: AgentInput) {
    // 准备上下文
    return input.context;
  }

  protected async executeTask(context: any, data: any) {
    // 执行任务
    return { result: 'success' };
  }

  protected async formatOutput(result: any) {
    // 格式化输出
    return result;
  }
}

// 注册自定义 agent
orchestrator.registerAgent(new MyCustomAgent());

工作流类型

预定义工作流

  • requirement-analysis: 需求分析工作流
  • code-review: 代码审查工作流
  • knowledge-extraction: 知识提取工作流

自定义工作流

const result = await orchestrator.executeWorkflow({
  type: 'custom',
  agents: ['agent1', 'agent2'],
  input: { /* 输入数据 */ },
  options: {
    parallel: true,
    timeout: 60000
  }
});

事件监听

// 监听工作流事件
orchestrator.on('workflow:start', ({ workflowId, task }) => {
  console.log(`工作流开始: ${workflowId}`);
});

orchestrator.on('workflow:complete', ({ workflowId, result }) => {
  console.log(`工作流完成: ${workflowId}`);
});

// 监听 agent 事件
orchestrator.on('agent:registered', ({ agentId }) => {
  console.log(`Agent 注册: ${agentId}`);
});

// 监听日志
orchestrator.on('log', ({ level, message, agentId }) => {
  console.log(`[${agentId}] ${level}: ${message}`);
});

CLI 集成

# 分析需求文档
aisd analyze -t requirements -i requirements.txt -o analysis.json

# 使用特定 agents
aisd analyze -t code-review -a code-review-agent,testing-agent -i pr.json

# 提取项目知识
aisd analyze -t knowledge-extraction -i project-history.json

配置选项

const orchestrator = new AISDOrchestrator({
  maxConcurrency: 5,      // 最大并发数
  timeout: 60000,         // 超时时间(ms)
  retryFailedAgents: true, // 失败重试
  logLevel: 'info'        // 日志级别
});

最佳实践

  1. 选择合适的 agents:根据任务类型选择必要的 agents,避免过度使用
  2. 优化输入数据:提供结构化的输入数据以获得更好的结果
  3. 处理错误:始终检查 result.success 并处理错误情况
  4. 监控性能:使用事件监听跟踪执行时间和资源使用
  5. 渐进式采用:从单个 agent 开始,逐步增加复杂度

路线图

  • [ ] 完成所有核心 agents 实现
  • [ ] 添加 agent 间直接通信
  • [ ] 实现 agent 状态持久化
  • [ ] 支持流式输出
  • [ ] 添加更多预定义工作流
  • [ ] 性能优化和缓存机制

贡献

欢迎贡献新的 agents 或改进现有功能!请查看贡献指南。

许可证

MIT