JSPM

  • Created
  • Published
  • Downloads 1611
  • Score
    100M100P100Q106365F
  • License MIT

简约的插件化 Agent 框架

Package Exports

  • foliko
  • foliko/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (foliko) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Foliko

简约的插件化 Agent 框架

特性

  • 插件化架构 - 核心简单,通过插件扩展功能
  • 流式输出 - 支持实时流式输出
  • 多 AI 支持 - 支持 Anthropic、DeepSeek、MiniMax 等
  • 内置工具 - Shell、Python、MCP、文件系统等
  • 技能系统 - 可扩展的 Skill 管理
  • 会话管理 - 支持多会话切换
  • 规则引擎 - 可配置的行为规则

快速开始

# 安装
npm install

# 启动聊天
npm run chat

项目结构

vb-agent/
├── cli/                 # 命令行入口
│   └── bin/foliko.js    # CLI 入口
├── src/                 # 核心框架
│   ├── core/            # 核心组件
│   ├── capabilities/    # 能力插件
│   └── executors/       # 执行器
├── plugins/             # 内置插件
├── skills/              # 技能目录
└── examples/            # 示例

配置

在项目根目录创建 .agent 目录:

.agent/
├── config              # 配置文件
├── ai.json            # AI 配置
├── mcp_config.json    # MCP 服务器配置
├── plugins/           # 用户插件目录
├── skills/            # 用户技能目录
└── data/              # 数据目录

config 文件格式

ai_key: your-api-key
ai_model: MiniMax-M2.7
ai_provider: minimax

ai.json 格式

{
  "provider": "minimax",
  "model": "MiniMax-M2.7",
  "apiKey": "your-api-key",
  "baseURL": "https://api.minimaxi.com/v1"
}

mcp_config.json 格式

{
  "mcpServers": {
    "fetch": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-fetch"]
    }
  }
}

开发插件

用户插件(.agent/plugins/)

插件支持两种结构:文件夹结构(推荐)和单文件结构

文件夹结构(推荐)

.agent/plugins/my-plugin/
├── package.json      # 可选,main 字段指定入口
├── index.js          # 默认入口
└── node_modules/     # 可选,插件私有依赖
// package.json 示例
{
  "name": "my-plugin",
  "main": "index.js"
}
// .agent/plugins/my-plugin/index.js
module.exports = function(Plugin) {
  return class MyPlugin extends Plugin {
    constructor(config = {}) {
      super()
      this.name = 'my-plugin'
      this.version = '1.0.0'
      this.description = '我的工具插件'
      this.priority = 10
    }

    install(framework) {
      const { z } = require('zod')
      framework.registerTool({
        name: 'my_tool',
        description: '我的工具',
        inputSchema: z.object({
          param: z.string().describe('参数描述')
        }),
        execute: async (args, framework) => {
          return { success: true, result: args.param }
        }
      })
      return this
    }
  }
}

单文件结构(兼容)

.agent/plugins/my-plugin.js

如果同时存在文件夹和同名 .js 文件,文件夹优先

注意:如果插件需要第三方库(如 zod),需要先安装:

  1. 创建插件文件/文件夹
  2. 调用 install 工具安装依赖
  3. 热重载插件

技能开发

.agent/skills/ 下创建技能:

.agent/skills/my-skill/
└── SKILL.md

SKILL.md 格式:

---
name: my-skill
description: 技能描述
allowed-tools: tool1,tool2
---

技能内容...

CLI 命令

# 聊天模式
foliko chat

# 指定模型
foliko chat --model gpt-4

# 指定 API
foliko chat --api-key xxx

内置工具

工具 说明
loadSkill 加载技能
mcp_execute 执行 MCP 工具
shell_execute 执行 Shell 命令
python_execute 执行 Python 代码
install 安装 npm 包
mcp_reload 重载 MCP 服务器
audit_query 查询审计日志

工作目录

CLI 工作目录默认使用执行命令的目录。

许可证

MIT