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 管理
- 会话管理 - 支持多会话切换
- 规则引擎 - 可配置的行为规则
- 子 Agent - 支持多子 Agent 分工协作
安装
# 方式一:npm 安装
npm install -g foliko
# 方式二:Windows 一键脚本安装
irm https://folikoai.com/install.ps1 | iex
# 方式三:Mac/Linux 一键脚本安装
curl -fsSL https://folikoai.com/install.sh | bash快速开始
# 全局安装后
foliko chatCLI 命令
# 聊天模式(使用 .env 中的配置)
foliko chat
# 指定完整配置
foliko chat --provider deepseek --model deepseek-chat --base-url https://api.deepseek.com/v1 --api-key sk-xxx
# 只指定 provider(使用 provider 默认 model 和 baseURL)
foliko chat --provider deepseek --api-key sk-xxx
# 列出所有子Agent配置
foliko list项目结构
foliko/
├── cli/ # 命令行入口
│ └── bin/foliko.js # CLI 入口
├── src/ # 核心框架
│ ├── core/ # 核心组件
│ ├── capabilities/ # 能力插件
│ └── executors/ # 执行器
├── plugins/ # 内置插件
├── skills/ # 技能目录
└── examples/ # 示例配置
环境变量配置 (.env)
在项目根目录创建 .env 文件:
# AI Provider: minimax, deepseek, openai, anthropic 等
FOLIKO_PROVIDER=minimax
# AI Model(可选,不填则使用 provider 默认值)
# MiniMax: MiniMax-M2.7
# DeepSeek: deepseek-chat, deepseek-coder 等
FOLIKO_MODEL=MiniMax-M2.7
# API Base URL(可选,不填则使用 provider 默认值)
# MiniMax: https://api.minimaxi.com/v1
# DeepSeek: https://api.deepseek.com/v1
FOLIKO_BASE_URL=https://api.minimaxi.com/v1
# API Key(通用,不填则使用 provider 专用 key)
FOLIKO_API_KEY=sk-your-minimax-api-key
# Provider 专用 API Key(可选)
# DEEPSEEK_API_KEY=sk-your-deepseek-api-key
# MINIMAX_API_KEY=sk-your-minimax-api-key配置优先级:命令行参数 > .env配置 > provider默认值
.agent 目录结构
.agent/
├── config # 配置文件
├── ai.json # AI 配置
├── mcp_config.json # MCP 服务器配置
├── agents/ # 子Agent配置目录
├── plugins/ # 用户插件目录
├── skills/ # 用户技能目录
└── data/ # 数据目录子 Agent 配置 (.agent/agents/)
在 .agent/agents/ 目录下放置子 Agent 配置文件,支持 .js、.json、.md 格式:
.agent/agents/
├── backend-specialist.md
├── frontend-specialist.md
└── database-architect.mdJSON 格式
{
"name": "backend-specialist",
"role": "Backend Specialist",
"description": "Expert in backend development",
"parentTools": ["read_file", "run_command"]
}Markdown 格式
# Backend Specialist
```json
{
"name": "backend-specialist",
"role": "Backend Specialist",
"description": "Expert in backend development",
"parentTools": ["read_file", "run_command"]
}
### ai.json 格式
```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),需要先安装:
- 创建插件文件/文件夹
- 调用
install工具安装依赖 - 热重载插件
技能开发
在 .agent/skills/ 下创建技能:
.agent/skills/my-skill/
└── SKILL.mdSKILL.md 格式:
---
name: my-skill
description: 技能描述
allowed-tools: tool1,tool2
---
技能内容...内置工具
通用工具
| 工具 | 说明 |
|---|---|
loadSkill |
加载技能 |
list_plugins |
列出所有插件 |
list_tools |
列出所有工具 |
reload_plugins |
重载插件 |
shell |
执行 Shell 命令 |
powershell |
执行 PowerShell 命令 |
python-execute |
执行 Python 代码 |
python_script |
执行 Python 脚本 |
pip_install |
安装 Python 包 |
install |
安装 npm 包 |
mcp_reload |
重载 MCP 服务器 |
audit_query |
查询审计日志 |
子 Agent 管理工具
| 工具 | 说明 |
|---|---|
subagent_list |
列出所有子Agent |
subagent_call |
调用指定的子Agent处理任务 |
subagent_reload |
重新加载子Agent配置 |
会话工具
| 工具 | 说明 |
|---|---|
session_create |
创建会话 |
session_get |
获取会话 |
session_list |
列出所有会话 |
session_delete |
删除会话 |
session_history |
获取会话历史 |
定时任务工具
| 工具 | 说明 |
|---|---|
schedule_task |
创建定时任务 |
schedule_list |
列出定时任务 |
schedule_cancel |
取消定时任务 |
cron_examples |
显示 cron 示例 |
工作目录
CLI 工作目录默认使用执行命令的目录。
.agent/目录会创建在工作目录下- 配置文件、插件、技能等都放在工作目录的
.agent/下
许可证
MIT