@optima-chat/optima-agent 0.9.13 → 0.9.15

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 (92) hide show
  1. package/.claude/skills/.kb-skills-managed.json +9 -9
  2. package/.claude/skills/ads/SKILL.md +244 -244
  3. package/.claude/skills/ads/template/campaign/CREATIVES.md +18 -18
  4. package/.claude/skills/ads/template/campaign/NOTES.md +10 -10
  5. package/.claude/skills/ads/template/campaign/STRATEGY.md +29 -29
  6. package/.claude/skills/ads/template/user/ADS.md +29 -29
  7. package/.claude/skills/ads/template/user/LEARNINGS.md +15 -15
  8. package/.claude/skills/ads/template/user/PROGRESS.md +20 -20
  9. package/.claude/skills/ads/template/user/README.md +25 -25
  10. package/.claude/skills/ads/template/user/assets/.gitignore +2 -2
  11. package/.claude/skills/bi/SKILL.md +131 -131
  12. package/.claude/skills/browser/SKILL.md +201 -201
  13. package/.claude/skills/channels/SKILL.md +188 -188
  14. package/.claude/skills/collection/SKILL.md +88 -88
  15. package/.claude/skills/douyin/SKILL.md +408 -408
  16. package/.claude/skills/ffmpeg/SKILL.md +164 -164
  17. package/.claude/skills/gen/SKILL.md +327 -279
  18. package/.claude/skills/growth/SKILL.md +90 -90
  19. package/.claude/skills/growth/template/ACCOUNTS.md +14 -14
  20. package/.claude/skills/growth/template/CALENDAR.md +7 -7
  21. package/.claude/skills/growth/template/COMMENTS.md +7 -7
  22. package/.claude/skills/growth/template/GROWTH.md +37 -37
  23. package/.claude/skills/growth/template/PROGRESS.md +4 -4
  24. package/.claude/skills/growth/template/README.md +20 -20
  25. package/.claude/skills/growth/template/TOPICS.md +7 -7
  26. package/.claude/skills/homepage/SKILL.md +177 -177
  27. package/.claude/skills/i18n/SKILL.md +517 -517
  28. package/.claude/skills/ingesting-sources/SKILL.md +94 -94
  29. package/.claude/skills/initializing-kb/SKILL.md +117 -117
  30. package/.claude/skills/instagram/SKILL.md +321 -321
  31. package/.claude/skills/inventory/SKILL.md +328 -328
  32. package/.claude/skills/kol-outreach/SKILL.md +232 -232
  33. package/.claude/skills/kol-outreach/template/campaign/CONFIG.md +60 -60
  34. package/.claude/skills/kol-outreach/template/campaign/KOLS.md +6 -6
  35. package/.claude/skills/kol-outreach/template/campaign/PROGRESS.md +3 -3
  36. package/.claude/skills/kol-outreach/template/campaign/TEMPLATES.md +88 -88
  37. package/.claude/skills/kol-outreach/template/merchant/BRAND.md +36 -36
  38. package/.claude/skills/kol-outreach/template/merchant/CAMPAIGNS.md +6 -6
  39. package/.claude/skills/kol-outreach/template/merchant/MERCHANT_LIMITS.md +16 -16
  40. package/.claude/skills/kol-outreach/template/merchant/PROGRESS.md +4 -4
  41. package/.claude/skills/kol-outreach/template/merchant/README.md +20 -20
  42. package/.claude/skills/linting-the-wiki/SKILL.md +68 -68
  43. package/.claude/skills/logistics/SKILL.md +180 -180
  44. package/.claude/skills/markdown-pdf/SKILL.md +72 -72
  45. package/.claude/skills/merchant/SKILL.md +110 -110
  46. package/.claude/skills/multigrid-poster/SKILL.md +192 -192
  47. package/.claude/skills/multigrid-poster/layouts/2x2.json +34 -34
  48. package/.claude/skills/multigrid-poster/layouts/3x3.json +43 -43
  49. package/.claude/skills/multigrid-poster/scripts/compose.py +116 -116
  50. package/.claude/skills/order/SKILL.md +452 -452
  51. package/.claude/skills/product/SKILL.md +379 -379
  52. package/.claude/skills/product-page/SKILL.md +106 -106
  53. package/.claude/skills/querying-the-wiki/SKILL.md +59 -59
  54. package/.claude/skills/reddit/SKILL.md +277 -277
  55. package/.claude/skills/review/SKILL.md +321 -321
  56. package/.claude/skills/scout/SKILL.md +575 -575
  57. package/.claude/skills/sentinel/SKILL.md +281 -281
  58. package/.claude/skills/shein/SKILL.md +246 -246
  59. package/.claude/skills/shipping/SKILL.md +200 -200
  60. package/.claude/skills/shop-content/SKILL.md +101 -101
  61. package/.claude/skills/shopify/SKILL.md +282 -282
  62. package/.claude/skills/skillify/SKILL.md +114 -114
  63. package/.claude/skills/taobao/SKILL.md +238 -238
  64. package/.claude/skills/tiktok/SKILL.md +381 -381
  65. package/.claude/skills/twitter/SKILL.md +302 -302
  66. package/.claude/skills/updating-related-pages/SKILL.md +65 -65
  67. package/.claude/skills/video-edit/SKILL.md +123 -138
  68. package/.claude/skills/video-gen/SKILL.md +720 -720
  69. package/.claude/skills/video-gen/templates/INDEX.md +78 -78
  70. package/.claude/skills/video-gen/templates/before-after-beauty.md +183 -183
  71. package/.claude/skills/video-gen/templates/drama-fmcg.md +183 -183
  72. package/.claude/skills/video-gen/templates/kol-reaction-food.md +193 -193
  73. package/.claude/skills/video-gen/templates/multi-point-apparel.md +185 -185
  74. package/.claude/skills/video-gen/templates/pain-solution-home.md +184 -184
  75. package/.claude/skills/video-gen/templates/pdp-360-showcase.md +189 -189
  76. package/.claude/skills/video-gen/templates/pdp-feature-highlight.md +182 -182
  77. package/.claude/skills/video-gen/templates/scene-digital.md +183 -183
  78. package/.claude/skills/wechat/SKILL.md +174 -174
  79. package/.claude/skills/xhs/SKILL.md +170 -170
  80. package/README.md +276 -276
  81. package/dist/bin/optima.js +26 -26
  82. package/dist/bin/serve.js +23 -23
  83. package/dist/src/agent.d.ts +1 -1
  84. package/dist/src/agent.js +4 -4
  85. package/dist/src/system-prompt.js +175 -175
  86. package/dist/src/tools/memory.js +10 -10
  87. package/dist/src/ui/headless.js +7 -7
  88. package/package.json +79 -79
  89. package/dist/bin/video-edit.d.ts +0 -3
  90. package/dist/bin/video-edit.d.ts.map +0 -1
  91. package/dist/bin/video-edit.js +0 -153
  92. package/dist/bin/video-edit.js.map +0 -1
package/README.md CHANGED
@@ -1,276 +1,276 @@
1
- # Optima Agent
2
-
3
- 基于 [Claude Agent SDK](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) 的电商运营 AI 助手。
4
-
5
- [![npm version](https://badge.fury.io/js/@optima-chat%2Foptima-agent.svg)](https://www.npmjs.com/package/@optima-chat/optima-agent)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
-
8
- ## 快速开始
9
-
10
- ### 安装
11
-
12
- ```bash
13
- npm install -g @optima-chat/optima-agent@latest
14
- ```
15
-
16
- ### 认证
17
-
18
- ```bash
19
- export ANTHROPIC_API_KEY=your-api-key
20
- ```
21
-
22
- 或使用 Claude Code 的认证(`~/.claude/`)。
23
-
24
- ### 使用
25
-
26
- ```bash
27
- # 交互模式(终端对话)
28
- optima
29
-
30
- # Headless 模式(容器内运行,stdin/stdout JSON)
31
- optima headless
32
-
33
- # 服务器模式(HTTP + WebSocket)
34
- optima serve --port 3000
35
-
36
- # 单次查询
37
- optima -p "查看商品列表"
38
- ```
39
-
40
- ## 功能特性
41
-
42
- ### 核心能力
43
-
44
- - **店铺管理** - 查看和更新店铺信息
45
- - **商品管理** - 创建、编辑、查询商品
46
- - **订单处理** - 发货、退款、订单查询
47
- - **库存管理** - 监控库存、调整数量
48
- - **运费与物流** - 运费配置、运单查询、物流追踪
49
- - **国际化** - 多语言翻译管理
50
- - **店铺配置** - 首页、集合、商品详情页
51
- - **图像/视频/语音** - AI 生成产品图片、视频、TTS/ASR
52
- - **音视频处理** - 视频合成、压缩、裁切、格式转换
53
- - **浏览器自动化** - 网页操作、Workflow 录制与回放
54
- - **广告投放** - Google Ads 管理
55
- - **选品调研** - Amazon 产品分析、1688 供应商sourcing
56
- - **竞品研究** - Shein、TikTok Shop 产品搜索
57
- - **网红营销** - TikTok/Instagram 达人发现与分析
58
- - **数据分析** - 销售数据和趋势
59
- - **评价管理** - 审核、回复、AI 生成评价
60
- - **自动化监控** - 定时规则、巡检、审批
61
- - **Shopify 集成** - 店铺连接、商品/订单/库存同步
62
- - **交互式问答** - 执行任务时向用户提问(架构选择、方案确认等)
63
-
64
- ### 执行模式
65
-
66
- | 模式 | 用途 | 特性 |
67
- |------|------|------|
68
- | Stream | 本地终端交互 | Context 可视化、命令菜单、实时统计 |
69
- | Headless | 容器内运行 | stdin/stdout JSON、多对话管理、会话恢复 |
70
- | Server | 多客户端服务 | WebSocket、完整统计、Abort 支持 |
71
- | 单次查询 | 命令行执行 | 快速查询、支持 JSON 输出 |
72
-
73
- ## 可用 Skills
74
-
75
- | Skill | 用途 |
76
- |-------|------|
77
- | merchant | 店铺信息管理 |
78
- | product | 商品管理 |
79
- | order | 订单处理与发货 |
80
- | inventory | 库存管理与监控 |
81
- | shipping | 运费配置与管理 |
82
- | logistics | 物流运单与追踪 |
83
- | i18n | 国际化翻译 |
84
- | collection | 商品集合管理 |
85
- | homepage | 店铺首页配置 |
86
- | product-page | 商品详情页配置 |
87
- | review | 评价管理与 AI 生成 |
88
- | comfy | 图像/视频/语音生成(TTS/ASR) |
89
- | ffmpeg | 音视频处理(合成、压缩、裁切) |
90
- | browser | 浏览器自动化与 Workflow 录制回放 |
91
- | ads | Google Ads 广告投放 |
92
- | scout | Amazon 选品与 1688 供应商sourcing |
93
- | shein | Shein 产品搜索与快时尚调研 |
94
- | tiktok | TikTok 网红营销与 Shop 产品研究 |
95
- | instagram | Instagram 达人发现与内容分析 |
96
- | shopify | Shopify 店铺集成与同步 |
97
- | bi | 销售数据与趋势分析 |
98
- | sentinel | 自动化监控规则与巡检 |
99
- | markdown-pdf | Markdown 导出 PDF |
100
-
101
- ## 交互式问答 (AskUserQuestion)
102
-
103
- Claude 可以在执行任务时向用户提问,用于:
104
- - **架构选择** - 选择技术栈、库、框架等
105
- - **方案确认** - 多个实现方案,让用户决策
106
- - **需求澄清** - 遇到模糊需求时请求明确
107
-
108
- ### 各模式支持情况
109
-
110
- | 模式 | 支持 | 交互方式 |
111
- |------|------|----------|
112
- | Stream (CLI) | ✅ | 终端菜单(箭头键/Space/Enter) |
113
- | Headless | ✅ | JSON 消息协议(ask_question/answer_question) |
114
- | Server | ✅ | WebSocket 消息协议 |
115
- | 单次查询 | ❌ | 自动拒绝(提示使用交互模式) |
116
-
117
- ### 示例:终端交互
118
-
119
- ```bash
120
- optima
121
-
122
- > 我需要实现用户认证,请帮我选择方案
123
-
124
- 🤔 Claude 需要你的输入
125
-
126
- Auth method
127
- Which authentication method should we use?
128
-
129
- ○ OAuth 2.0
130
- Industry standard, supports multiple providers
131
-
132
- ○ JWT
133
- Stateless, simple to implement
134
-
135
- ● Session
136
- Traditional approach, server-side state
137
-
138
- [取消] [确认] ✓
139
- ```
140
-
141
- ### Headless/Server 消息协议
142
-
143
- **ask_question 事件** (后端 → 前端):
144
- ```json
145
- {
146
- "type": "ask_question",
147
- "conversation_id": "conv_123",
148
- "request_id": "ask_question_xxx",
149
- "questions": [{
150
- "question": "Which method?",
151
- "header": "Auth",
152
- "options": [
153
- {"label": "OAuth 2.0", "description": "Industry standard"},
154
- {"label": "JWT", "description": "Stateless"}
155
- ],
156
- "multiSelect": false
157
- }]
158
- }
159
- ```
160
-
161
- **answer_question 消息** (前端 → 后端):
162
- ```json
163
- {
164
- "type": "answer_question",
165
- "request_id": "ask_question_xxx",
166
- "answers": {
167
- "0": "OAuth 2.0"
168
- }
169
- }
170
- ```
171
-
172
- 详细文档:[docs/ask-user-question-implementation.md](docs/ask-user-question-implementation.md)
173
-
174
- ## 配置
175
-
176
- 项目根目录可选配置:
177
-
178
- **OPTIMA.json** - 配置选项
179
- ```json
180
- {
181
- "model": "claude-sonnet-4-5-20250929",
182
- "maxTurns": 50
183
- }
184
- ```
185
-
186
- **OPTIMA.md** - 自定义 System Prompt
187
- ```markdown
188
- # 项目规则
189
-
190
- - 使用简体中文
191
- - 优先使用现有库存
192
- ```
193
-
194
- ## API 使用
195
-
196
- ```typescript
197
- import { OptimaAgent } from '@optima-chat/optima-agent';
198
-
199
- const agent = new OptimaAgent({
200
- model: 'claude-sonnet-4-5-20250929',
201
- maxTurns: 50,
202
- });
203
-
204
- for await (const event of agent.chat('查看商品列表')) {
205
- if (event.type === 'assistant') {
206
- console.log(event.message);
207
- }
208
- }
209
-
210
- // 重置会话
211
- agent.reset();
212
- ```
213
-
214
- ## 技术架构
215
-
216
- ```
217
- ┌─────────────────────────────────────────────────────────────────┐
218
- │ 用户界面层 │
219
- │ ┌──────────────────┐ ┌──────────────────┐ │
220
- │ │ 终端 CLI │ │ HTTP Server │ │
221
- │ │ (Stream Mode) │ │ (WebSocket) │ │
222
- │ └────────┬─────────┘ └────────┬─────────┘ │
223
- └───────────┼──────────────────────────────────┼──────────────────┘
224
- │ │
225
- └──────────────┬───────────────────┘
226
-
227
- ┌─────────────────────────────────────────────────────────────────┐
228
- │ Optima Agent 核心 │
229
- │ ┌───────────────────────────────────────────────────────────┐ │
230
- │ │ Claude Agent SDK │ │
231
- │ │ • 流式输出 • 上下文管理 • Hooks • 会话恢复 │ │
232
- │ └───────────────────────────────────────────────────────────┘ │
233
- │ │ │
234
- │ ┌──────────────┬──────────┴──────────┬──────────────┐ │
235
- │ │ │ │ │ │
236
- │ ▼ ▼ ▼ ▼ │
237
- │ Skills System Prompt Tools MCP Server │
238
- │ (23个) (引导逻辑) (Bash/Read..) (Memory) │
239
- └──────────────────────┬──────────────────────────────────────────┘
240
-
241
- ┌──────────────┼──────────────┐
242
- ▼ ▼ ▼
243
- ┌─────────────┐ ┌──────────┐ ┌──────────────┐
244
- │ commerce │ │ comfy │ │ google-ads │
245
- │ -cli │ │ -cli │ │ -cli │ ...
246
- │ │ │ │ │ │
247
- │ 商品·订单 │ │ 图像·视频 │ │ 广告投放 │
248
- └─────────────┘ └──────────┘ └──────────────┘
249
- ```
250
-
251
- ### 技术栈
252
-
253
- - **核心**: Claude Agent SDK v0.1.55
254
- - **语言**: TypeScript
255
- - **UI**: 自定义终端渲染
256
- - **工具集成**: 10+ 专业 CLI 工具
257
-
258
- ## 开发
259
-
260
- ```bash
261
- # 安装依赖
262
- npm install
263
-
264
- # 开发模式
265
- npm run dev
266
-
267
- # 构建
268
- npm run build
269
-
270
- # 类型检查
271
- npm run typecheck
272
- ```
273
-
274
- ## License
275
-
276
- MIT
1
+ # Optima Agent
2
+
3
+ 基于 [Claude Agent SDK](https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk) 的电商运营 AI 助手。
4
+
5
+ [![npm version](https://badge.fury.io/js/@optima-chat%2Foptima-agent.svg)](https://www.npmjs.com/package/@optima-chat/optima-agent)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## 快速开始
9
+
10
+ ### 安装
11
+
12
+ ```bash
13
+ npm install -g @optima-chat/optima-agent@latest
14
+ ```
15
+
16
+ ### 认证
17
+
18
+ ```bash
19
+ export ANTHROPIC_API_KEY=your-api-key
20
+ ```
21
+
22
+ 或使用 Claude Code 的认证(`~/.claude/`)。
23
+
24
+ ### 使用
25
+
26
+ ```bash
27
+ # 交互模式(终端对话)
28
+ optima
29
+
30
+ # Headless 模式(容器内运行,stdin/stdout JSON)
31
+ optima headless
32
+
33
+ # 服务器模式(HTTP + WebSocket)
34
+ optima serve --port 3000
35
+
36
+ # 单次查询
37
+ optima -p "查看商品列表"
38
+ ```
39
+
40
+ ## 功能特性
41
+
42
+ ### 核心能力
43
+
44
+ - **店铺管理** - 查看和更新店铺信息
45
+ - **商品管理** - 创建、编辑、查询商品
46
+ - **订单处理** - 发货、退款、订单查询
47
+ - **库存管理** - 监控库存、调整数量
48
+ - **运费与物流** - 运费配置、运单查询、物流追踪
49
+ - **国际化** - 多语言翻译管理
50
+ - **店铺配置** - 首页、集合、商品详情页
51
+ - **图像/视频/语音** - AI 生成产品图片、视频、TTS/ASR
52
+ - **音视频处理** - 视频合成、压缩、裁切、格式转换
53
+ - **浏览器自动化** - 网页操作、Workflow 录制与回放
54
+ - **广告投放** - Google Ads 管理
55
+ - **选品调研** - Amazon 产品分析、1688 供应商sourcing
56
+ - **竞品研究** - Shein、TikTok Shop 产品搜索
57
+ - **网红营销** - TikTok/Instagram 达人发现与分析
58
+ - **数据分析** - 销售数据和趋势
59
+ - **评价管理** - 审核、回复、AI 生成评价
60
+ - **自动化监控** - 定时规则、巡检、审批
61
+ - **Shopify 集成** - 店铺连接、商品/订单/库存同步
62
+ - **交互式问答** - 执行任务时向用户提问(架构选择、方案确认等)
63
+
64
+ ### 执行模式
65
+
66
+ | 模式 | 用途 | 特性 |
67
+ |------|------|------|
68
+ | Stream | 本地终端交互 | Context 可视化、命令菜单、实时统计 |
69
+ | Headless | 容器内运行 | stdin/stdout JSON、多对话管理、会话恢复 |
70
+ | Server | 多客户端服务 | WebSocket、完整统计、Abort 支持 |
71
+ | 单次查询 | 命令行执行 | 快速查询、支持 JSON 输出 |
72
+
73
+ ## 可用 Skills
74
+
75
+ | Skill | 用途 |
76
+ |-------|------|
77
+ | merchant | 店铺信息管理 |
78
+ | product | 商品管理 |
79
+ | order | 订单处理与发货 |
80
+ | inventory | 库存管理与监控 |
81
+ | shipping | 运费配置与管理 |
82
+ | logistics | 物流运单与追踪 |
83
+ | i18n | 国际化翻译 |
84
+ | collection | 商品集合管理 |
85
+ | homepage | 店铺首页配置 |
86
+ | product-page | 商品详情页配置 |
87
+ | review | 评价管理与 AI 生成 |
88
+ | comfy | 图像/视频/语音生成(TTS/ASR) |
89
+ | ffmpeg | 音视频处理(合成、压缩、裁切) |
90
+ | browser | 浏览器自动化与 Workflow 录制回放 |
91
+ | ads | Google Ads 广告投放 |
92
+ | scout | Amazon 选品与 1688 供应商sourcing |
93
+ | shein | Shein 产品搜索与快时尚调研 |
94
+ | tiktok | TikTok 网红营销与 Shop 产品研究 |
95
+ | instagram | Instagram 达人发现与内容分析 |
96
+ | shopify | Shopify 店铺集成与同步 |
97
+ | bi | 销售数据与趋势分析 |
98
+ | sentinel | 自动化监控规则与巡检 |
99
+ | markdown-pdf | Markdown 导出 PDF |
100
+
101
+ ## 交互式问答 (AskUserQuestion)
102
+
103
+ Claude 可以在执行任务时向用户提问,用于:
104
+ - **架构选择** - 选择技术栈、库、框架等
105
+ - **方案确认** - 多个实现方案,让用户决策
106
+ - **需求澄清** - 遇到模糊需求时请求明确
107
+
108
+ ### 各模式支持情况
109
+
110
+ | 模式 | 支持 | 交互方式 |
111
+ |------|------|----------|
112
+ | Stream (CLI) | ✅ | 终端菜单(箭头键/Space/Enter) |
113
+ | Headless | ✅ | JSON 消息协议(ask_question/answer_question) |
114
+ | Server | ✅ | WebSocket 消息协议 |
115
+ | 单次查询 | ❌ | 自动拒绝(提示使用交互模式) |
116
+
117
+ ### 示例:终端交互
118
+
119
+ ```bash
120
+ optima
121
+
122
+ > 我需要实现用户认证,请帮我选择方案
123
+
124
+ 🤔 Claude 需要你的输入
125
+
126
+ Auth method
127
+ Which authentication method should we use?
128
+
129
+ ○ OAuth 2.0
130
+ Industry standard, supports multiple providers
131
+
132
+ ○ JWT
133
+ Stateless, simple to implement
134
+
135
+ ● Session
136
+ Traditional approach, server-side state
137
+
138
+ [取消] [确认] ✓
139
+ ```
140
+
141
+ ### Headless/Server 消息协议
142
+
143
+ **ask_question 事件** (后端 → 前端):
144
+ ```json
145
+ {
146
+ "type": "ask_question",
147
+ "conversation_id": "conv_123",
148
+ "request_id": "ask_question_xxx",
149
+ "questions": [{
150
+ "question": "Which method?",
151
+ "header": "Auth",
152
+ "options": [
153
+ {"label": "OAuth 2.0", "description": "Industry standard"},
154
+ {"label": "JWT", "description": "Stateless"}
155
+ ],
156
+ "multiSelect": false
157
+ }]
158
+ }
159
+ ```
160
+
161
+ **answer_question 消息** (前端 → 后端):
162
+ ```json
163
+ {
164
+ "type": "answer_question",
165
+ "request_id": "ask_question_xxx",
166
+ "answers": {
167
+ "0": "OAuth 2.0"
168
+ }
169
+ }
170
+ ```
171
+
172
+ 详细文档:[docs/ask-user-question-implementation.md](docs/ask-user-question-implementation.md)
173
+
174
+ ## 配置
175
+
176
+ 项目根目录可选配置:
177
+
178
+ **OPTIMA.json** - 配置选项
179
+ ```json
180
+ {
181
+ "model": "claude-sonnet-4-5-20250929",
182
+ "maxTurns": 50
183
+ }
184
+ ```
185
+
186
+ **OPTIMA.md** - 自定义 System Prompt
187
+ ```markdown
188
+ # 项目规则
189
+
190
+ - 使用简体中文
191
+ - 优先使用现有库存
192
+ ```
193
+
194
+ ## API 使用
195
+
196
+ ```typescript
197
+ import { OptimaAgent } from '@optima-chat/optima-agent';
198
+
199
+ const agent = new OptimaAgent({
200
+ model: 'claude-sonnet-4-5-20250929',
201
+ maxTurns: 50,
202
+ });
203
+
204
+ for await (const event of agent.chat('查看商品列表')) {
205
+ if (event.type === 'assistant') {
206
+ console.log(event.message);
207
+ }
208
+ }
209
+
210
+ // 重置会话
211
+ agent.reset();
212
+ ```
213
+
214
+ ## 技术架构
215
+
216
+ ```
217
+ ┌─────────────────────────────────────────────────────────────────┐
218
+ │ 用户界面层 │
219
+ │ ┌──────────────────┐ ┌──────────────────┐ │
220
+ │ │ 终端 CLI │ │ HTTP Server │ │
221
+ │ │ (Stream Mode) │ │ (WebSocket) │ │
222
+ │ └────────┬─────────┘ └────────┬─────────┘ │
223
+ └───────────┼──────────────────────────────────┼──────────────────┘
224
+ │ │
225
+ └──────────────┬───────────────────┘
226
+
227
+ ┌─────────────────────────────────────────────────────────────────┐
228
+ │ Optima Agent 核心 │
229
+ │ ┌───────────────────────────────────────────────────────────┐ │
230
+ │ │ Claude Agent SDK │ │
231
+ │ │ • 流式输出 • 上下文管理 • Hooks • 会话恢复 │ │
232
+ │ └───────────────────────────────────────────────────────────┘ │
233
+ │ │ │
234
+ │ ┌──────────────┬──────────┴──────────┬──────────────┐ │
235
+ │ │ │ │ │ │
236
+ │ ▼ ▼ ▼ ▼ │
237
+ │ Skills System Prompt Tools MCP Server │
238
+ │ (23个) (引导逻辑) (Bash/Read..) (Memory) │
239
+ └──────────────────────┬──────────────────────────────────────────┘
240
+
241
+ ┌──────────────┼──────────────┐
242
+ ▼ ▼ ▼
243
+ ┌─────────────┐ ┌──────────┐ ┌──────────────┐
244
+ │ commerce │ │ comfy │ │ google-ads │
245
+ │ -cli │ │ -cli │ │ -cli │ ...
246
+ │ │ │ │ │ │
247
+ │ 商品·订单 │ │ 图像·视频 │ │ 广告投放 │
248
+ └─────────────┘ └──────────┘ └──────────────┘
249
+ ```
250
+
251
+ ### 技术栈
252
+
253
+ - **核心**: Claude Agent SDK v0.1.55
254
+ - **语言**: TypeScript
255
+ - **UI**: 自定义终端渲染
256
+ - **工具集成**: 10+ 专业 CLI 工具
257
+
258
+ ## 开发
259
+
260
+ ```bash
261
+ # 安装依赖
262
+ npm install
263
+
264
+ # 开发模式
265
+ npm run dev
266
+
267
+ # 构建
268
+ npm run build
269
+
270
+ # 类型检查
271
+ npm run typecheck
272
+ ```
273
+
274
+ ## License
275
+
276
+ MIT
@@ -6,32 +6,32 @@ import { startServer } from "../src/server/index.js";
6
6
  import { startDockerHeadlessMode } from "../src/ui/headless.js";
7
7
  import { VERSION } from "../src/version.js";
8
8
  function printHelp() {
9
- console.log(`
10
- Optima Agent - 电商运营 AI 助手
11
-
12
- 用法:
13
- optima 启动交互模式
14
- optima headless 启动 Headless 模式 (stdin/stdout JSON)
15
- optima serve [选项] 启动服务器模式
16
- optima -p "..." 单次查询
17
-
18
- 选项:
19
- -p, --prompt <text> 执行单次查询
20
- -f, --format <format> 输出格式: text (默认), json, stream-json
21
- --cwd <path> 工作目录
22
- -h, --help 显示帮助
23
- -v, --version 显示版本
24
-
25
- 服务器模式选项:
26
- --port <number> 端口号 (默认: 3000)
27
- --token <string> 认证 token
28
-
29
- 示例:
30
- optima # 交互模式
31
- optima headless # Headless 模式(容器内使用)
32
- optima serve --port 8080 --token "secret" # 服务器模式
33
- optima -p "查看商品列表" # 单次查询
34
- optima -p "帮我查看待发货订单" --format json # JSON 输出
9
+ console.log(`
10
+ Optima Agent - 电商运营 AI 助手
11
+
12
+ 用法:
13
+ optima 启动交互模式
14
+ optima headless 启动 Headless 模式 (stdin/stdout JSON)
15
+ optima serve [选项] 启动服务器模式
16
+ optima -p "..." 单次查询
17
+
18
+ 选项:
19
+ -p, --prompt <text> 执行单次查询
20
+ -f, --format <format> 输出格式: text (默认), json, stream-json
21
+ --cwd <path> 工作目录
22
+ -h, --help 显示帮助
23
+ -v, --version 显示版本
24
+
25
+ 服务器模式选项:
26
+ --port <number> 端口号 (默认: 3000)
27
+ --token <string> 认证 token
28
+
29
+ 示例:
30
+ optima # 交互模式
31
+ optima headless # Headless 模式(容器内使用)
32
+ optima serve --port 8080 --token "secret" # 服务器模式
33
+ optima -p "查看商品列表" # 单次查询
34
+ optima -p "帮我查看待发货订单" --format json # JSON 输出
35
35
  `);
36
36
  }
37
37
  function printVersion() {
package/dist/bin/serve.js CHANGED
@@ -2,29 +2,29 @@
2
2
  import { parseArgs } from "node:util";
3
3
  import { startServer } from "../src/server/index.js";
4
4
  function printHelp() {
5
- console.log(`
6
- Optima Agent Server - WebSocket 服务器模式
7
-
8
- 用法:
9
- optima serve [选项]
10
-
11
- 选项:
12
- --port <number> 端口号 (默认: 3000)
13
- --token <string> 认证 token
14
- --cwd <path> 工作目录
15
- -h, --help 显示帮助
16
-
17
- 示例:
18
- optima serve
19
- optima serve --port 8080
20
- optima serve --port 8080 --token "secret-token"
21
-
22
- WebSocket 连接:
23
- ws://localhost:3000/ws
24
- ws://localhost:3000/ws?token=secret-token
25
-
26
- 健康检查:
27
- curl http://localhost:3000/health
5
+ console.log(`
6
+ Optima Agent Server - WebSocket 服务器模式
7
+
8
+ 用法:
9
+ optima serve [选项]
10
+
11
+ 选项:
12
+ --port <number> 端口号 (默认: 3000)
13
+ --token <string> 认证 token
14
+ --cwd <path> 工作目录
15
+ -h, --help 显示帮助
16
+
17
+ 示例:
18
+ optima serve
19
+ optima serve --port 8080
20
+ optima serve --port 8080 --token "secret-token"
21
+
22
+ WebSocket 连接:
23
+ ws://localhost:3000/ws
24
+ ws://localhost:3000/ws?token=secret-token
25
+
26
+ 健康检查:
27
+ curl http://localhost:3000/health
28
28
  `);
29
29
  }
30
30
  function main() {