@yeaft/webchat-agent 0.1.105 → 0.1.107

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.105",
3
+ "version": "0.1.107",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/roleplay-dir.js CHANGED
@@ -25,7 +25,7 @@ import { getRolePlayMessages } from './roleplay-i18n.js';
25
25
  const TEAM_ROLES = {
26
26
  dev: ['pm', 'dev', 'reviewer', 'tester'],
27
27
  writing: ['editor', 'writer', 'proofreader'],
28
- trading: ['analyst', 'strategist', 'risk-manager'],
28
+ trading: ['quant', 'strategist', 'risk', 'macro'],
29
29
  video: ['director', 'writer', 'producer'],
30
30
  custom: ['pm', 'dev', 'reviewer', 'tester'], // default same as dev
31
31
  };
package/roleplay-i18n.js CHANGED
@@ -21,7 +21,7 @@ const messages = {
21
21
  - 适合轻量级协作和快速迭代`,
22
22
  workConventions: '# 工作约定',
23
23
  workConventionsContent: `- 文档产出写入 .roleplay/context/ 目录
24
- - 代码修改使用项目路径的绝对路径
24
+ - 文件操作使用项目路径的绝对路径
25
25
  - 每个角色专注自己的职责,不越界
26
26
  - **Plan mode 自动退出**:可以进入 plan mode 梳理思路和写计划,但计划写完后必须立即调用 ExitPlanMode 自动退出并直接开始执行,不要等待用户审批。只有在方案有重大歧义、需要用户做选择时才停下来确认`,
27
27
  crewRelation: '# 与 .crew 的关系',
@@ -117,14 +117,25 @@ const messages = {
117
117
  风格:严谨细致,注重可读性。`,
118
118
  },
119
119
  // Trading team
120
+ quant: {
121
+ heading: '## 📊 量化分析师-西蒙斯 (quant)',
122
+ content: `你是量化分析师-西蒙斯。团队的数据引擎。
123
+ - 使用 Bash 工具运行 Python 脚本做数据分析
124
+ - 输出量化信号、关键价位、技术指标
125
+ - 可随时被要求换参数重新跑数据
126
+ - 数据格式化为表格或结构化文本
127
+
128
+ 风格:纯数学家,用数据和概率说话。`,
129
+ },
120
130
  strategist: {
121
- heading: '## 📋 策略师 (strategist)',
122
- content: `你是策略师。你的职责:
123
- - 综合技术分析和宏观研究做出交易决策
124
- - 管理整体仓位和风险敞口
125
- - 协调团队分析方向
131
+ heading: '## 📐 策略师-索罗斯 (strategist)',
132
+ content: `你是策略师-索罗斯。团队的决策核心。
133
+ - 综合量化数据和宏观分析,形成投资策略
134
+ - 明确核心假设、验证信号和证伪条件
135
+ - 决定仓位大小和进出场时机
136
+ - 可以要求任何角色提供更多数据
126
137
 
127
- 风格:冷静理性,注重概率思维。`,
138
+ 风格:反身性思维,基于数据决策。`,
128
139
  },
129
140
  analyst: {
130
141
  heading: '## 📊 技术分析师 (analyst)',
@@ -136,22 +147,24 @@ const messages = {
136
147
  风格:数据驱动,图表说话。`,
137
148
  },
138
149
  macro: {
139
- heading: '## 🌐 宏观研究员 (macro)',
140
- content: `你是宏观研究员。你的职责:
141
- - 分析宏观经济数据和政策
142
- - 评估市场情绪和资金流向
143
- - 提供宏观背景判断
150
+ heading: '## 🌐 宏观研究员-达里奥 (macro)',
151
+ content: `你是宏观研究员-达里奥。团队的宏观视野。
152
+ - 分析宏观经济数据、央行政策、债务周期
153
+ - 输出周期定位、关键驱动因子、情景分析
154
+ - 评估跨资产联动关系
155
+ - 可要求量化分析师跑宏观相关数据
144
156
 
145
- 风格:视野开阔,善于关联不同市场。`,
157
+ 风格:把经济看成机器,有因果链条。`,
146
158
  },
147
159
  risk: {
148
- heading: '## 🛡️ 风控 (risk)',
149
- content: `你是风控。你的职责:
150
- - 审查交易方案的风险
151
- - 设定止损和仓位限制
152
- - 监控已有持仓风险
160
+ heading: '## 🛡️ 风控官-塔勒布 (risk)',
161
+ content: `你是风控官-塔勒布。团队的生存保障。
162
+ - 压力测试策略,评估尾部风险
163
+ - 检查仓位合规(单笔≤2%,总敞口≤10%)
164
+ - 审核止损和对冲方案
165
+ - 风险不可接受时直接打回
153
166
 
154
- 风格:保守谨慎,底线思维。`,
167
+ 风格:反脆弱思维,尾部风险偏执狂。`,
155
168
  },
156
169
  trader: {
157
170
  heading: '## 💰 交易员 (trader)',
@@ -250,10 +263,18 @@ taskTitle: {任务标题}(可选)
250
263
  2. **作者** 根据大纲撰写内容
251
264
  3. **审校** 检查逻辑一致性、事实准确性和文字质量(不通过 → 返回作者修改)
252
265
  4. **编辑** 验收最终成果`,
253
- tradingWorkflow: `1. **分析师** 研究市场,输出技术分析和关键价位
254
- 2. **策略师** 综合分析,制定投资策略和仓位方案
255
- 3. **风控官** 压力测试策略,评估尾部风险(不通过 返回策略师调整)
256
- 4. **策略师** 确认最终方案并总结`,
266
+ tradingWorkflow: `1. 用户提出分析需求
267
+ 2. **量化分析师** 执行脚本/获取数据,输出量化信号和分析结果
268
+ 3. **策略师** **宏观研究员** 分析数据,各自给出观点
269
+ 4. **策略师** 综合各方分析,形成初步策略方案
270
+ 5. **风控官** 压力测试策略(不通过 → 返回策略师调整)
271
+ 6. 多角色可以相互讨论、质疑、补充(不必严格线性流转)
272
+ 7. **策略师** 确认最终方案,输出结构化交易建议
273
+
274
+ 关键原则:
275
+ - 量化分析师可以随时被要求重新跑数据或换参数
276
+ - 任何角色都可以 ROUTE 给任何角色提问/质疑
277
+ - 工作流强调"基于数据的迭代优化"`,
257
278
  videoWorkflow: `1. **导演** 确定主题、情绪基调和视觉风格
258
279
  2. **编剧** 构思故事线,撰写分段脚本
259
280
  3. **制片** 审核可行性,生成最终 prompt 序列(不通过 → 返回编剧调整)
@@ -279,7 +300,7 @@ Differences from Crew (multi-process, each role has its own Claude instance):
279
300
  - Suitable for lightweight collaboration and rapid iteration`,
280
301
  workConventions: '# Work Conventions',
281
302
  workConventionsContent: `- Write documentation output to .roleplay/context/ directory
282
- - Use absolute project path for code changes
303
+ - Use absolute project path for file operations
283
304
  - Each role focuses on its own responsibilities`,
284
305
  crewRelation: '# Relationship with .crew',
285
306
  crewRelationContent: `- .roleplay/context/ can read .crew/context/ content
@@ -370,15 +391,26 @@ Style: Sharp writing, good at using details to move people.`,
370
391
  - Confirm content aligns with overall direction
371
392
 
372
393
  Style: Rigorous and detailed, focused on readability.`,
394
+ },
395
+ quant: {
396
+ heading: '## 📊 Quant-Simons (quant)',
397
+ content: `You are Quant-Simons. The team's data engine.
398
+ - Use Bash tool to run Python scripts for data analysis
399
+ - Output quantitative signals, key levels, technical indicators
400
+ - Can be asked to re-run with different parameters at any time
401
+ - Format data as tables or structured text
402
+
403
+ Style: pure mathematician, speaks in data and probability.`,
373
404
  },
374
405
  strategist: {
375
- heading: '## 📋 Strategist (strategist)',
376
- content: `You are the Strategist. Your responsibilities:
377
- - Synthesize technical analysis and macro research for trading decisions
378
- - Manage overall positions and risk exposure
379
- - Coordinate team analysis direction
406
+ heading: '## 📐 Strategist-Soros (strategist)',
407
+ content: `You are Strategist-Soros. The team's decision core.
408
+ - Synthesize quantitative data and macro analysis into investment strategies
409
+ - Define core hypothesis, validation signals, and falsification conditions
410
+ - Determine position sizing and entry/exit timing
411
+ - Can request any role to provide more data
380
412
 
381
- Style: Calm and rational, probability-focused thinking.`,
413
+ Style: reflexivity thinking, data-driven decisions.`,
382
414
  },
383
415
  analyst: {
384
416
  heading: '## 📊 Technical Analyst (analyst)',
@@ -390,22 +422,24 @@ Style: Calm and rational, probability-focused thinking.`,
390
422
  Style: Data-driven, charts speak.`,
391
423
  },
392
424
  macro: {
393
- heading: '## 🌐 Macro Researcher (macro)',
394
- content: `You are the Macro Researcher. Your responsibilities:
395
- - Analyze macroeconomic data and policies
396
- - Assess market sentiment and fund flows
397
- - Provide macro context judgment
425
+ heading: '## 🌐 Macro-Researcher-Dalio (macro)',
426
+ content: `You are Macro-Researcher-Dalio. The team's macro perspective.
427
+ - Analyze macroeconomic data, central bank policies, debt cycles
428
+ - Output cycle positioning, key drivers, scenario analysis
429
+ - Assess cross-asset correlations
430
+ - Can request quant to run macro-related data analysis
398
431
 
399
- Style: Broad perspective, good at connecting different markets.`,
432
+ Style: sees the economy as a machine with causal chains.`,
400
433
  },
401
434
  risk: {
402
- heading: '## 🛡️ Risk Manager (risk)',
403
- content: `You are the Risk Manager. Your responsibilities:
404
- - Review trading plan risks
405
- - Set stop-loss and position limits
406
- - Monitor existing position risk
435
+ heading: '## 🛡️ Risk-Officer-Taleb (risk)',
436
+ content: `You are Risk-Officer-Taleb. The team's survival guarantee.
437
+ - Stress-test strategies, assess tail risks
438
+ - Verify position compliance (single trade ≤2%, total exposure ≤10%)
439
+ - Review stop-loss and hedging plans
440
+ - Reject strategies with unacceptable risk
407
441
 
408
- Style: Conservative, bottom-line thinking.`,
442
+ Style: antifragile thinking, tail risk obsessive.`,
409
443
  },
410
444
  trader: {
411
445
  heading: '## 💰 Trader (trader)',
@@ -503,10 +537,18 @@ Rules:
503
537
  2. **Writer** writes content based on outline
504
538
  3. **Proofreader** checks logical consistency, factual accuracy, and writing quality (if fails → back to Writer)
505
539
  4. **Editor** final acceptance of deliverables`,
506
- tradingWorkflow: `1. **Analyst** researches market, outputs technical analysis and key levels
507
- 2. **Strategist** synthesizes analysis, formulates investment strategy and position plan
508
- 3. **Risk Manager** stress-tests strategy, assesses tail risks (if fails → back to Strategist)
509
- 4. **Strategist** confirms final plan and summarizes`,
540
+ tradingWorkflow: `1. User submits analysis request
541
+ 2. **Quant** executes scripts/fetches data, outputs quantitative signals and analysis results
542
+ 3. **Strategist** and **Macro Researcher** analyze data, each provides perspective
543
+ 4. **Strategist** synthesizes all analyses into preliminary strategy
544
+ 5. **Risk Officer** stress-tests strategy (if fails → back to Strategist for adjustment)
545
+ 6. Roles can freely discuss, challenge, and supplement each other (not strictly linear)
546
+ 7. **Strategist** confirms final plan, outputs structured trading recommendation
547
+
548
+ Key principles:
549
+ - Quant can be asked to re-run data or change parameters at any time
550
+ - Any role can ROUTE to any other role to ask questions or challenge
551
+ - Workflow emphasizes "data-driven iterative optimization"`,
510
552
  videoWorkflow: `1. **Director** establishes theme, emotional tone, and visual style
511
553
  2. **Screenwriter** conceives storyline, writes segmented script
512
554
  3. **Producer** reviews feasibility, generates final prompt sequence (if fails → back to Screenwriter)
package/roleplay.js CHANGED
@@ -325,8 +325,8 @@ export function buildRolePlaySystemPrompt(config) {
325
325
  const workflow = getWorkflow(teamType, roles, isZh);
326
326
 
327
327
  const prompt = isZh
328
- ? buildZhPrompt(roleList, workflow)
329
- : buildEnPrompt(roleList, workflow);
328
+ ? buildZhPrompt(roleList, workflow, teamType)
329
+ : buildEnPrompt(roleList, workflow, teamType);
330
330
 
331
331
  // Append .crew context if available
332
332
  if (crewContext) {
@@ -339,7 +339,18 @@ export function buildRolePlaySystemPrompt(config) {
339
339
  return prompt.trim();
340
340
  }
341
341
 
342
- function buildZhPrompt(roleList, workflow) {
342
+ function buildZhPrompt(roleList, workflow, teamType) {
343
+ const isDevTeam = teamType === 'dev' || teamType === 'custom';
344
+
345
+ const outputRules = isDevTeam
346
+ ? `- 不要在回复开头添加角色名称或"XX视角"等标题,对话界面已经显示了角色信息,直接以角色身份开始回复内容
347
+ - 代码修改使用工具(Read, Edit, Write 等),不要在聊天中贴大段代码
348
+ - 每个角色专注做自己的事,不要代替其他角色
349
+ - Review 和 Test 角色如果发现问题,必须切回 Dev 修复后再继续`
350
+ : `- 不要在回复开头添加角色名称或"XX视角"等标题,对话界面已经显示了角色信息,直接以角色身份开始回复内容
351
+ - 每个角色专注做自己的事,不要代替其他角色
352
+ - 角色之间可以自由讨论和质疑,鼓励迭代优化`;
353
+
343
354
  return `
344
355
  # 多角色协作模式
345
356
 
@@ -396,10 +407,7 @@ ${workflow}
396
407
 
397
408
  ## 输出格式
398
409
 
399
- - 不要在回复开头添加角色名称或"XX视角"等标题,对话界面已经显示了角色信息,直接以角色身份开始回复内容
400
- - 代码修改使用工具(Read, Edit, Write 等),不要在聊天中贴大段代码
401
- - 每个角色专注做自己的事,不要代替其他角色
402
- - Review 和 Test 角色如果发现问题,必须切回 Dev 修复后再继续
410
+ ${outputRules}
403
411
 
404
412
  ## 语言
405
413
 
@@ -407,7 +415,18 @@ ${workflow}
407
415
  `;
408
416
  }
409
417
 
410
- function buildEnPrompt(roleList, workflow) {
418
+ function buildEnPrompt(roleList, workflow, teamType) {
419
+ const isDevTeam = teamType === 'dev' || teamType === 'custom';
420
+
421
+ const outputRules = isDevTeam
422
+ ? `- Do not add role names or titles like "XX's perspective" at the beginning of responses; the chat UI already displays role information — start directly with the role's content
423
+ - Use tools (Read, Edit, Write, etc.) for code changes, don't paste large code blocks in chat
424
+ - Each role focuses on its own responsibility, don't do other roles' jobs
425
+ - If Review or Test finds issues, must switch back to Dev to fix before continuing`
426
+ : `- Do not add role names or titles like "XX's perspective" at the beginning of responses; the chat UI already displays role information — start directly with the role's content
427
+ - Each role focuses on its own responsibility, don't do other roles' jobs
428
+ - Roles can freely discuss and challenge each other, iterative optimization is encouraged`;
429
+
411
430
  return `
412
431
  # Multi-Role Collaboration Mode
413
432
 
@@ -464,10 +483,7 @@ Each role switch must include clear handoff information from the previous role:
464
483
 
465
484
  ## Output Format
466
485
 
467
- - Do not add role names or titles like "XX's perspective" at the beginning of responses; the chat UI already displays role information — start directly with the role's content
468
- - Use tools (Read, Edit, Write, etc.) for code changes, don't paste large code blocks in chat
469
- - Each role focuses on its own responsibility, don't do other roles' jobs
470
- - If Review or Test finds issues, must switch back to Dev to fix before continuing
486
+ ${outputRules}
471
487
 
472
488
  ## Language
473
489
 
@@ -550,22 +566,51 @@ function buildWritingWorkflow(roleNames, isZh) {
550
566
  }
551
567
 
552
568
  function buildTradingWorkflow(roleNames, isZh) {
553
- const hasAnalyst = roleNames.includes('analyst');
569
+ const hasQuant = roleNames.includes('quant');
554
570
  const hasStrategist = roleNames.includes('strategist');
555
- const hasRiskManager = roleNames.includes('risk-manager');
571
+ const hasRisk = roleNames.includes('risk');
572
+ const hasMacro = roleNames.includes('macro');
556
573
 
557
574
  const steps = [];
558
575
 
559
576
  if (isZh) {
560
- if (hasAnalyst) steps.push(`${steps.length + 1}. **分析师** 研究市场,输出技术分析和关键价位`);
561
- if (hasStrategist) steps.push(`${steps.length + 1}. **策略师** 综合分析,制定投资策略和仓位方案`);
562
- if (hasRiskManager) steps.push(`${steps.length + 1}. **风控官** 压力测试策略,评估尾部风险(不通过 → 返回策略师调整)`);
563
- if (hasStrategist) steps.push(`${steps.length + 1}. **策略师** 确认最终方案并总结`);
577
+ steps.push(`${steps.length + 1}. 用户提出分析需求`);
578
+ if (hasQuant) steps.push(`${steps.length + 1}. **量化分析师** 执行脚本/获取数据,输出量化信号和分析结果`);
579
+ if (hasStrategist && hasMacro) {
580
+ steps.push(`${steps.length + 1}. **策略师** 和 **宏观研究员** 分析数据,各自给出观点`);
581
+ } else if (hasStrategist) {
582
+ steps.push(`${steps.length + 1}. **策略师** 分析数据,给出观点`);
583
+ } else if (hasMacro) {
584
+ steps.push(`${steps.length + 1}. **宏观研究员** 分析数据,给出观点`);
585
+ }
586
+ if (hasStrategist) steps.push(`${steps.length + 1}. **策略师** 综合各方分析,形成初步策略方案`);
587
+ if (hasRisk) steps.push(`${steps.length + 1}. **风控官** 压力测试策略(不通过 → 返回策略师调整)`);
588
+ steps.push(`${steps.length + 1}. 多角色可以相互讨论、质疑、补充(不必严格线性流转)`);
589
+ if (hasStrategist) steps.push(`${steps.length + 1}. **策略师** 确认最终方案,输出结构化交易建议`);
590
+ steps.push('');
591
+ steps.push('关键原则:');
592
+ if (hasQuant) steps.push('- 量化分析师可以随时被要求重新跑数据或换参数');
593
+ steps.push('- 任何角色都可以 ROUTE 给任何角色提问/质疑');
594
+ steps.push('- 工作流强调"基于数据的迭代优化"');
564
595
  } else {
565
- if (hasAnalyst) steps.push(`${steps.length + 1}. **Analyst** researches market, outputs technical analysis and key levels`);
566
- if (hasStrategist) steps.push(`${steps.length + 1}. **Strategist** synthesizes analysis, formulates investment strategy and position plan`);
567
- if (hasRiskManager) steps.push(`${steps.length + 1}. **Risk Manager** stress-tests strategy, assesses tail risks (if fails → back to Strategist)`);
568
- if (hasStrategist) steps.push(`${steps.length + 1}. **Strategist** confirms final plan and summarizes`);
596
+ steps.push(`${steps.length + 1}. User submits analysis request`);
597
+ if (hasQuant) steps.push(`${steps.length + 1}. **Quant** executes scripts/fetches data, outputs quantitative signals`);
598
+ if (hasStrategist && hasMacro) {
599
+ steps.push(`${steps.length + 1}. **Strategist** and **Macro Researcher** analyze data, each provides perspective`);
600
+ } else if (hasStrategist) {
601
+ steps.push(`${steps.length + 1}. **Strategist** analyzes data, provides perspective`);
602
+ } else if (hasMacro) {
603
+ steps.push(`${steps.length + 1}. **Macro Researcher** analyzes data, provides perspective`);
604
+ }
605
+ if (hasStrategist) steps.push(`${steps.length + 1}. **Strategist** synthesizes all analyses into preliminary strategy`);
606
+ if (hasRisk) steps.push(`${steps.length + 1}. **Risk Officer** stress-tests strategy (if fails → back to Strategist)`);
607
+ steps.push(`${steps.length + 1}. Roles can freely discuss, challenge, and supplement (not strictly linear)`);
608
+ if (hasStrategist) steps.push(`${steps.length + 1}. **Strategist** confirms final plan, outputs structured recommendation`);
609
+ steps.push('');
610
+ steps.push('Key principles:');
611
+ if (hasQuant) steps.push('- Quant can be asked to re-run data or change parameters at any time');
612
+ steps.push('- Any role can ROUTE to any other role to ask questions or challenge');
613
+ steps.push('- Workflow emphasizes "data-driven iterative optimization"');
569
614
  }
570
615
 
571
616
  return steps.join('\n');