foliko 1.0.87 → 1.1.1

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.
Files changed (259) hide show
  1. package/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
  2. package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
  3. package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
  4. package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
  5. package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
  6. package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
  7. package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
  8. package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  9. package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  10. package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  11. package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  12. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  13. package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  14. package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  15. package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
  16. package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  17. package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  18. package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  19. package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  20. package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
  21. package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
  22. package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  23. package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  24. package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
  25. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
  26. package/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
  27. package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
  28. package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
  29. package/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
  30. package/.agent/ARCHITECTURE.md +288 -0
  31. package/.agent/agents/ambient-agent.md +57 -0
  32. package/.agent/agents/debugger.md +55 -0
  33. package/.agent/agents/email-assistant.md +49 -0
  34. package/.agent/agents/file-manager.md +42 -0
  35. package/.agent/agents/python-developer.md +60 -0
  36. package/.agent/agents/scheduler.md +59 -0
  37. package/.agent/agents/web-developer.md +45 -0
  38. package/.agent/data/default.json +325 -21
  39. package/.agent/data/plugins-state.json +194 -162
  40. package/.agent/data/puppeteer-sessions/undefined.json +6 -0
  41. package/.agent/mcp_config.json +0 -1
  42. package/.agent/mcp_config_updated.json +12 -0
  43. package/.agent/plugins/poster-plugin/README.md +304 -0
  44. package/.agent/plugins/poster-plugin/fonts/NotoColorEmoji-Regular.ttf +0 -0
  45. package/.agent/plugins/poster-plugin/fonts/PatuaOne-Regular.ttf +0 -0
  46. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221.ttf +0 -0
  47. package/.agent/plugins/poster-plugin/fonts//345/276/256/350/275/257/351/233/205/351/273/221/347/262/227/344/275/223.ttf +0 -0
  48. package/.agent/plugins/poster-plugin/index.js +13 -0
  49. package/.agent/plugins/poster-plugin/package.json +28 -0
  50. package/.agent/plugins/poster-plugin/src/canvas.js +161 -0
  51. package/.agent/plugins/poster-plugin/src/components/arrow.js +84 -0
  52. package/.agent/plugins/poster-plugin/src/components/avatar.js +71 -0
  53. package/.agent/plugins/poster-plugin/src/components/badge.js +85 -0
  54. package/.agent/plugins/poster-plugin/src/components/card.js +88 -0
  55. package/.agent/plugins/poster-plugin/src/components/chart.js +127 -0
  56. package/.agent/plugins/poster-plugin/src/components/chip.js +88 -0
  57. package/.agent/plugins/poster-plugin/src/components/columns.js +107 -0
  58. package/.agent/plugins/poster-plugin/src/components/cta.js +85 -0
  59. package/.agent/plugins/poster-plugin/src/components/divider.js +55 -0
  60. package/.agent/plugins/poster-plugin/src/components/feature.js +85 -0
  61. package/.agent/plugins/poster-plugin/src/components/featureGrid.js +112 -0
  62. package/.agent/plugins/poster-plugin/src/components/grid.js +118 -0
  63. package/.agent/plugins/poster-plugin/src/components/imageFrame.js +155 -0
  64. package/.agent/plugins/poster-plugin/src/components/index.js +62 -0
  65. package/.agent/plugins/poster-plugin/src/components/listItem.js +146 -0
  66. package/.agent/plugins/poster-plugin/src/components/notification.js +123 -0
  67. package/.agent/plugins/poster-plugin/src/components/progress.js +79 -0
  68. package/.agent/plugins/poster-plugin/src/components/progressCircle.js +117 -0
  69. package/.agent/plugins/poster-plugin/src/components/quote.js +97 -0
  70. package/.agent/plugins/poster-plugin/src/components/rating.js +85 -0
  71. package/.agent/plugins/poster-plugin/src/components/star.js +70 -0
  72. package/.agent/plugins/poster-plugin/src/components/statCard.js +105 -0
  73. package/.agent/plugins/poster-plugin/src/components/stepper.js +118 -0
  74. package/.agent/plugins/poster-plugin/src/components/table.js +159 -0
  75. package/.agent/plugins/poster-plugin/src/components/tagCloud.js +78 -0
  76. package/.agent/plugins/poster-plugin/src/components/timeline.js +105 -0
  77. package/.agent/plugins/poster-plugin/src/components/watermark.js +52 -0
  78. package/.agent/plugins/poster-plugin/src/composer.js +1904 -0
  79. package/.agent/plugins/poster-plugin/src/elements/artText.js +60 -0
  80. package/.agent/plugins/poster-plugin/src/elements/background.js +52 -0
  81. package/.agent/plugins/poster-plugin/src/elements/circle.js +31 -0
  82. package/.agent/plugins/poster-plugin/src/elements/image.js +71 -0
  83. package/.agent/plugins/poster-plugin/src/elements/index.js +26 -0
  84. package/.agent/plugins/poster-plugin/src/elements/line.js +23 -0
  85. package/.agent/plugins/poster-plugin/src/elements/polygon.js +63 -0
  86. package/.agent/plugins/poster-plugin/src/elements/rectangle.js +32 -0
  87. package/.agent/plugins/poster-plugin/src/elements/svg.js +92 -0
  88. package/.agent/plugins/poster-plugin/src/elements/text.js +107 -0
  89. package/.agent/plugins/poster-plugin/src/fonts.js +233 -0
  90. package/.agent/plugins/poster-plugin/src/index.js +1658 -0
  91. package/.agent/plugins/poster-plugin/src/presets.js +36 -0
  92. package/.agent/plugins/poster-plugin/src/templates/business.js +60 -0
  93. package/.agent/plugins/poster-plugin/src/templates/gradient.js +64 -0
  94. package/.agent/plugins/poster-plugin/src/templates/index.js +43 -0
  95. package/.agent/plugins/poster-plugin/src/templates/modern.js +69 -0
  96. package/.agent/plugins/poster-plugin/src/templates/simple.js +58 -0
  97. package/.agent/plugins/poster-plugin/src/templates/social.js +62 -0
  98. package/.agent/plugins/poster-plugin/src/templates/tech.js +84 -0
  99. package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/index.js +1 -1
  100. package/.agent/plugins.json +5 -11
  101. package/.agent/rules/GEMINI.md +273 -0
  102. package/.agent/rules/allow-rule.md +77 -0
  103. package/.agent/rules/log-rule.md +83 -0
  104. package/.agent/rules/security-rule.md +93 -0
  105. package/.agent/scripts/auto_preview.py +148 -0
  106. package/.agent/scripts/checklist.py +217 -0
  107. package/.agent/scripts/session_manager.py +120 -0
  108. package/.agent/scripts/verify_all.py +327 -0
  109. package/.agent/sessions/cli_default.json +419 -0
  110. package/.agent/sessions/weixin_o9cq80zgZqKPA2-s59PN43GdDy1w@im.wechat.json +2195 -0
  111. package/.agent/skills/api-patterns/SKILL.md +81 -0
  112. package/.agent/skills/api-patterns/api-style.md +42 -0
  113. package/.agent/skills/api-patterns/auth.md +24 -0
  114. package/.agent/skills/api-patterns/documentation.md +26 -0
  115. package/.agent/skills/api-patterns/graphql.md +41 -0
  116. package/.agent/skills/api-patterns/rate-limiting.md +31 -0
  117. package/.agent/skills/api-patterns/response.md +37 -0
  118. package/.agent/skills/api-patterns/rest.md +40 -0
  119. package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
  120. package/.agent/skills/api-patterns/security-testing.md +122 -0
  121. package/.agent/skills/api-patterns/trpc.md +41 -0
  122. package/.agent/skills/api-patterns/versioning.md +22 -0
  123. package/.agent/skills/app-builder/SKILL.md +75 -0
  124. package/.agent/skills/app-builder/agent-coordination.md +71 -0
  125. package/.agent/skills/app-builder/feature-building.md +53 -0
  126. package/.agent/skills/app-builder/project-detection.md +34 -0
  127. package/.agent/skills/app-builder/scaffolding.md +118 -0
  128. package/.agent/skills/app-builder/tech-stack.md +40 -0
  129. package/.agent/skills/app-builder/templates/SKILL.md +39 -0
  130. package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
  131. package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
  132. package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
  133. package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
  134. package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
  135. package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
  136. package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
  137. package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
  138. package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
  139. package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
  140. package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
  141. package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
  142. package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
  143. package/.agent/skills/architecture/SKILL.md +55 -0
  144. package/.agent/skills/architecture/context-discovery.md +43 -0
  145. package/.agent/skills/architecture/examples.md +94 -0
  146. package/.agent/skills/architecture/pattern-selection.md +68 -0
  147. package/.agent/skills/architecture/patterns-reference.md +50 -0
  148. package/.agent/skills/architecture/trade-off-analysis.md +77 -0
  149. package/.agent/skills/clean-code/SKILL.md +201 -0
  150. package/.agent/skills/doc.md +177 -0
  151. package/.agent/skills/frontend-design/SKILL.md +418 -0
  152. package/.agent/skills/frontend-design/animation-guide.md +331 -0
  153. package/.agent/skills/frontend-design/color-system.md +311 -0
  154. package/.agent/skills/frontend-design/decision-trees.md +418 -0
  155. package/.agent/skills/frontend-design/motion-graphics.md +306 -0
  156. package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  157. package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
  158. package/.agent/skills/frontend-design/typography-system.md +345 -0
  159. package/.agent/skills/frontend-design/ux-psychology.md +1116 -0
  160. package/.agent/skills/frontend-design/visual-effects.md +383 -0
  161. package/.agent/skills/i18n-localization/SKILL.md +154 -0
  162. package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
  163. package/.agent/skills/mcp-builder/SKILL.md +176 -0
  164. package/.agent/skills/web-design-guidelines/SKILL.md +57 -0
  165. package/.agent/workflows/brainstorm.md +113 -0
  166. package/.agent/workflows/create.md +59 -0
  167. package/.agent/workflows/debug.md +103 -0
  168. package/.agent/workflows/deploy.md +176 -0
  169. package/.agent/workflows/enhance.md +63 -0
  170. package/.agent/workflows/orchestrate.md +237 -0
  171. package/.agent/workflows/plan.md +89 -0
  172. package/.agent/workflows/preview.md +81 -0
  173. package/.agent/workflows/simple-test.md +42 -0
  174. package/.agent/workflows/status.md +86 -0
  175. package/.agent/workflows/structured-orchestrate.md +180 -0
  176. package/.agent/workflows/test.md +144 -0
  177. package/.agent/workflows/ui-ux-pro-max.md +296 -0
  178. package/.claude/settings.local.json +20 -8
  179. package/.env.example +56 -56
  180. package/CLAUDE.md +144 -108
  181. package/README.md +441 -441
  182. package/calc_tokens_weixin.js +81 -0
  183. package/cli/src/commands/chat.js +2 -1
  184. package/docs/CONTEXT_DESIGN.md +1596 -0
  185. package/examples/test-concurrent-chat.js +60 -60
  186. package/foliko-creative-3.png +0 -0
  187. package/foliko-creative-4.png +0 -0
  188. package/foliko-creative-5.png +0 -0
  189. package/package.json +2 -2
  190. package/plugins/default-plugins.js +2 -1
  191. package/plugins/extension-executor-plugin.js +91 -2
  192. package/plugins/file-system-plugin.js +2 -2
  193. package/plugins/memory-plugin.js +984 -0
  194. package/plugins/session-plugin.js +57 -1
  195. package/plugins/weixin-plugin.js +33 -23
  196. package/skills/find-skills/AGENTS.md +162 -162
  197. package/skills/find-skills/SKILL.md +133 -133
  198. package/skills/poster-guide/SKILL.md +1059 -0
  199. package/skills/python-plugin-dev/SKILL.md +238 -238
  200. package/skills/skill-guide/SKILL.md +130 -108
  201. package/src/capabilities/skill-manager.js +99 -0
  202. package/src/core/agent-chat.js +620 -141
  203. package/src/core/agent-context.js +188 -0
  204. package/src/core/agent.js +6 -2
  205. package/src/core/context-manager.js +283 -0
  206. package/src/core/framework.js +264 -3
  207. package/src/core/plugin-manager.js +79 -2
  208. package/src/core/request-context.js +98 -0
  209. package/src/core/session-context.js +341 -0
  210. package/src/core/session-storage.js +274 -0
  211. package/src/executors/mcp-executor.js +2 -2
  212. package/src/utils/index.js +239 -67
  213. package/src/utils/plugin-helpers.js +17 -0
  214. package/story-cover-book-v2.png +0 -0
  215. package/story-cover-japanese-1.png +0 -0
  216. package/story-cover-japanese-2.png +0 -0
  217. package/story-cover-japanese-3.png +0 -0
  218. package/story-cover-moran.png +0 -0
  219. package/undefined.png +0 -0
  220. package//346/265/267/346/212/245/346/217/222/344/273/266.md +621 -0
  221. package/.agent/agents/code-assistant.json +0 -14
  222. package/.agent/agents/email-assistant.json +0 -14
  223. package/.agent/agents/file-assistant.json +0 -15
  224. package/.agent/agents/system-assistant.json +0 -15
  225. package/.agent/agents/web-assistant.json +0 -12
  226. package/.agent/data/ambient/goals.json +0 -50
  227. package/.agent/data/ambient/memories.json +0 -7
  228. package/.agent/data/scheduler/tasks.json +0 -1
  229. package/.agent/package.json +0 -8
  230. package/.agent/plugins/__pycache__/test_plugin.cpython-312.pyc +0 -0
  231. package/.agent/plugins/daytona/README.md +0 -89
  232. package/.agent/plugins/daytona/index.js +0 -377
  233. package/.agent/plugins/daytona/package.json +0 -12
  234. package/.agent/plugins/marknative/README.md +0 -134
  235. package/.agent/plugins/marknative/index.js +0 -228
  236. package/.agent/plugins/marknative/package.json +0 -12
  237. package/.agent/plugins/marknative/update-readme.js +0 -134
  238. package/.agent/plugins/system-info/index.js +0 -387
  239. package/.agent/plugins/system-info/package.json +0 -4
  240. package/.agent/plugins/system-info/test.js +0 -40
  241. package/.agent/plugins/temp-repo/LICENSE +0 -201
  242. package/.agent/plugins/test_plugin.py +0 -304
  243. package/.agent/python-scripts/test_sample.py +0 -24
  244. package/.agent/skills/agent-browser/SKILL.md +0 -311
  245. package/.agent/skills/agent-browser/TEST_PLAN.md +0 -200
  246. package/.agent/skills/sysinfo/SKILL.md +0 -38
  247. package/.agent/skills/sysinfo/system-info.sh +0 -130
  248. package/.agent/skills/workflow/SKILL.md +0 -324
  249. package/.agent/workflows/email-digest.json +0 -50
  250. package/.agent/workflows/file-backup.json +0 -21
  251. package/.agent/workflows/get-ip-notify.json +0 -32
  252. package/.agent/workflows/news-aggregator.json +0 -93
  253. package/.agent/workflows/news-dashboard-v2.json +0 -94
  254. package/.agent/workflows/notification-batch.json +0 -32
  255. package/examples/test-chat-debug.js +0 -102
  256. package/examples/test-chat-result.js +0 -76
  257. package/examples/test-chat-stream-diff.js +0 -63
  258. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/README.md +0 -0
  259. /package/.agent/plugins/{temp-repo/puppeteer-plugin → puppeteer-plugin}/package.json +0 -0
package/CLAUDE.md CHANGED
@@ -1,108 +1,144 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- **Foliko** is a minimalist plugin-based Agent framework in pure JavaScript (no TypeScript). It provides a lightweight core with extensible plugins for AI conversation, tool execution, workflow automation, and more.
8
-
9
- ## Commands
10
-
11
- ```bash
12
- # Run basic example
13
- npm start
14
-
15
- # CLI chat mode
16
- npm run chat
17
-
18
- # Proactive agent examples
19
- npm run proactive
20
- npm run proactive:advanced
21
-
22
- # No test suite yet
23
- npm test
24
- ```
25
-
26
- ## Architecture
27
-
28
- ```
29
- ┌─────────────────────────────────────────────────┐
30
- │ Foliko Framework │
31
- ├─────────────────────────────────────────────────┤
32
- │ Framework (Container Layer) │
33
- │ ├── pluginManager - Plugin lifecycle │
34
- │ ├── toolRegistry - Tool registration │
35
- │ ├── skillManager - Skill management │
36
- └── eventEmitter - Event bus │
37
- ├─────────────────────────────────────────────────┤
38
- │ Agent (Dialogue Layer) │
39
- ├── chat() - Send messages
40
- │ ├── chatStream() - Streaming responses
41
- │ ├── tools - From Framework
42
- └── events - Message/tool events
43
- └─────────────────────────────────────────────────┘
44
- ```
45
-
46
- ### Core Classes
47
-
48
- - **Framework** (`src/core/framework.js`) - Container managing plugins, tools, events, and agent creation
49
- - **Agent** (`src/core/agent.js`) - Handles conversation, tool calls, subAgent delegation, and message queuing
50
- - **Plugin** (`src/core/plugin-base.js`) - Base class with `install()`, `start()`, `reload()`, `uninstall()` lifecycle
51
- - **PluginManager** (`src/core/plugin-manager.js`) - Manages plugin loading, priority ordering, and hot reload
52
- - **ToolRegistry** (`src/core/tool-registry.js`) - Registers and executes tools with Zod schemas
53
- - **AgentChatHandler** (`src/core/agent-chat.js`) - Handles AI provider communication and tool call loops
54
-
55
- ### Directory Structure
56
-
57
- ```
58
- src/
59
- ├── core/ # Framework, Agent, PluginManager, ToolRegistry
60
- ├── capabilities/ # SkillManager, WorkflowEngine
61
- ├── executors/ # MCPExecutor for MCP server integration
62
- └── utils/ # EventEmitter
63
-
64
- plugins/ # Built-in plugins (ai-plugin, tools-plugin, shell/python executors, session, scheduler, etc.)
65
- cli/bin/ # CLI entry point
66
- .agent/ # User configuration (plugins, skills, agents, mcp_config.json)
67
- examples/ # Usage examples
68
- ```
69
-
70
- ### Plugin System
71
-
72
- Plugins are registered via `framework.registerPlugin()` and loaded with `framework.loadPlugin()`. Each plugin:
73
-
74
- - Has a `name`, `version`, `description`, and `priority`
75
- - Implements `install(framework)` to register tools/events
76
- - Implements `start(framework)` after initialization
77
- - Can implement `reload(framework)` for hot reload
78
- - Can implement `uninstall(framework)` for cleanup
79
-
80
- ### AI Integration
81
-
82
- Uses Vercel AI SDK (`ai` package) with support for multiple providers:
83
-
84
- - Anthropic, DeepSeek, MiniMax, OpenAI, OpenAI-Compatible
85
-
86
- Provider selection via `config.provider` and AI settings in `.agent/ai.json`.
87
-
88
- ### Key Patterns
89
-
90
- 1. **Context Isolation**: `framework.runWithContext(context, fn)` uses AsyncLocalStorage for true context isolation
91
- 2. **Tool Execution**: Tools receive `(args, framework)` and return results; errors should be caught and returned as `{error: message}`
92
- 3. **Event System**: Framework emits events like `framework:ready`, `plugin:loaded`, `agent:message`, `tool-call`
93
- 4. **Hot Reload**: Manual only via `framework.reloadPlugin(name)` or `framework.reloadAllPlugins()` - no file watching
94
-
95
- ### Built-in Plugins
96
-
97
- - **ai-plugin** - AI conversation via Vercel AI SDK
98
- - **tools-plugin** - Plugin management tools (list, reload, enable/disable)
99
- - **shell-executor-plugin** - Shell command execution
100
- - **python-executor-plugin** - Python code/script execution
101
- - **session-plugin** - Multi-session management
102
- - **scheduler-plugin** - Cron-based task scheduling
103
- - **subagent-plugin** - Child agent isolation
104
- - **email.js** - SMTP/IMAP email
105
- - **telegram-plugin.js** - Telegram bot integration
106
- - **audit-plugin.js** - Operation logging
107
- - **rules-plugin.js** - Permission/content rules
108
- - **storage-plugin.js** - Key-value persistence
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **Foliko** is a minimalist plugin-based Agent framework in pure JavaScript (no TypeScript). It provides a lightweight core with extensible plugins for AI conversation, tool execution, workflow automation, and more.
8
+
9
+ ## Commands
10
+
11
+ ```bash
12
+ # Run basic example
13
+ npm start
14
+
15
+ # CLI chat mode
16
+ npm run chat
17
+
18
+ # Proactive agent examples
19
+ npm run proactive
20
+ npm run proactive:advanced
21
+
22
+ # No test suite yet
23
+ npm test
24
+ ```
25
+
26
+ ## Architecture
27
+
28
+ ```
29
+ ┌─────────────────────────────────────────────────┐
30
+ │ Foliko Framework │
31
+ ├─────────────────────────────────────────────────┤
32
+ │ Framework (Container Layer) │
33
+ │ ├── pluginManager - Plugin lifecycle │
34
+ │ ├── toolRegistry - Tool registration │
35
+ │ ├── skillManager - Skill management │
36
+ ├── eventEmitter - Event bus │
37
+ │ └── Context System - Session/Request/Agent │
38
+ ├─────────────────────────────────────────────────┤
39
+ Agent (Dialogue Layer)
40
+ │ ├── chat() - Send messages
41
+ │ ├── chatStream() - Streaming responses
42
+ ├── tools - From Framework
43
+ │ └── events - Message/tool events │
44
+ └─────────────────────────────────────────────────┘
45
+ ```
46
+
47
+ ### Context Architecture (分层上下文)
48
+
49
+ ```
50
+ ┌─────────────────────────────────────────────────┐
51
+ │ Request Context (Layer 1)
52
+ │ requestId, traceId, timeout, startTime │
53
+ └─────────────────────────────────────────────────┘
54
+
55
+
56
+ ┌─────────────────────────────────────────────────┐
57
+ │ Session Context (Layer 2) │
58
+ │ sessionId, variables, messageStore │
59
+ │ Per-Session 消息存储,变量管理,元数据 │
60
+ └─────────────────────────────────────────────────┘
61
+
62
+
63
+ ┌─────────────────────────────────────────────────┐
64
+ │ Agent Context (Layer 3)
65
+ │ agentId, tools, skills, systemPrompt │
66
+ └─────────────────────────────────────────────────┘
67
+ ```
68
+
69
+ **Key Features**:
70
+
71
+ - Per-Session 消息隔离:每个 session 有独立的消息数组
72
+ - AsyncLocalStorage 三层隔离:Request / Session / Agent
73
+ - SessionContext 管理会话变量、元数据、压缩状态
74
+
75
+ ### Core Classes
76
+
77
+ - **Framework** (`src/core/framework.js`) - Container managing plugins, tools, events, and agent creation
78
+ - **Agent** (`src/core/agent.js`) - Handles conversation, tool calls, subAgent delegation, and message queuing
79
+ - **Plugin** (`src/core/plugin-base.js`) - Base class with `install()`, `start()`, `reload()`, `uninstall()` lifecycle
80
+ - **PluginManager** (`src/core/plugin-manager.js`) - Manages plugin loading, priority ordering, and hot reload
81
+ - **ToolRegistry** (`src/core/tool-registry.js`) - Registers and executes tools with Zod schemas
82
+ - **AgentChatHandler** (`src/core/agent-chat.js`) - Handles AI provider communication and tool call loops
83
+ - **SessionContext** (`src/core/session-context.js`) - Per-Session 上下文,管理消息、变量、元数据
84
+ - **RequestContext** (`src/core/request-context.js`) - Per-Request 上下文,链路追踪、超时控制
85
+ - **ContextManager** (`src/core/context-manager.js`) - 上下文生命周期管理
86
+
87
+ ### Directory Structure
88
+
89
+ ```
90
+ src/
91
+ ├── core/ # Framework, Agent, PluginManager, ToolRegistry
92
+ ├── capabilities/ # SkillManager, WorkflowEngine
93
+ ├── executors/ # MCPExecutor for MCP server integration
94
+ └── utils/ # EventEmitter
95
+
96
+ plugins/ # Built-in plugins (ai-plugin, tools-plugin, shell/python executors, session, scheduler, etc.)
97
+ cli/bin/ # CLI entry point
98
+ .agent/ # User configuration (plugins, skills, agents, mcp_config.json)
99
+ examples/ # Usage examples
100
+ ```
101
+
102
+ ### Plugin System
103
+
104
+ Plugins are registered via `framework.registerPlugin()` and loaded with `framework.loadPlugin()`. Each plugin:
105
+
106
+ - Has a `name`, `version`, `description`, and `priority`
107
+ - Implements `install(framework)` to register tools/events
108
+ - Implements `start(framework)` after initialization
109
+ - Can implement `reload(framework)` for hot reload
110
+ - Can implement `uninstall(framework)` for cleanup
111
+
112
+ ### AI Integration
113
+
114
+ Uses Vercel AI SDK (`ai` package) with support for multiple providers:
115
+
116
+ - Anthropic, DeepSeek, MiniMax, OpenAI, OpenAI-Compatible
117
+
118
+ Provider selection via `config.provider` and AI settings in `.agent/ai.json`.
119
+
120
+ ### Key Patterns
121
+
122
+ 1. **Context Isolation**: Three-layer AsyncLocalStorage for Request/Session/Agent isolation
123
+ - `framework.runInSession(sessionId, options, fn)` - 在 Session 上下文中执行
124
+ - `framework.getCurrentSessionContext()` - 获取当前 Session Context
125
+ - `framework.getRequestContext()` - 获取当前 Request Context
126
+ 2. **Tool Execution**: Tools receive `(args, framework)` and return results; errors should be caught and returned as `{error: message}`
127
+ 3. **Event System**: Framework emits events like `framework:ready`, `plugin:loaded`, `agent:message`, `tool-call`
128
+ 4. **Hot Reload**: Manual only via `framework.reloadPlugin(name)` or `framework.reloadAllPlugins()` - no file watching
129
+ 5. **Per-Session Message Storage**: `AgentChatHandler` uses `_sessionMessageStores` Map for Per-Session 消息隔离
130
+
131
+ ### Built-in Plugins
132
+
133
+ - **ai-plugin** - AI conversation via Vercel AI SDK
134
+ - **tools-plugin** - Plugin management tools (list, reload, enable/disable)
135
+ - **shell-executor-plugin** - Shell command execution
136
+ - **python-executor-plugin** - Python code/script execution
137
+ - **session-plugin** - Multi-session management
138
+ - **scheduler-plugin** - Cron-based task scheduling
139
+ - **subagent-plugin** - Child agent isolation
140
+ - **email.js** - SMTP/IMAP email
141
+ - **telegram-plugin.js** - Telegram bot integration
142
+ - **audit-plugin.js** - Operation logging
143
+ - **rules-plugin.js** - Permission/content rules
144
+ - **storage-plugin.js** - Key-value persistence