@yeaft/webchat-agent 0.0.106 → 0.0.108
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/crew.js +17 -12
- package/package.json +1 -1
package/crew.js
CHANGED
|
@@ -22,6 +22,11 @@ import ctx from './context.js';
|
|
|
22
22
|
|
|
23
23
|
const execFile = promisify(execFileCb);
|
|
24
24
|
|
|
25
|
+
/** Format role label: "icon displayName" or just "displayName" if no icon */
|
|
26
|
+
function roleLabel(r) {
|
|
27
|
+
return r.icon ? `${r.icon} ${r.displayName}` : r.displayName;
|
|
28
|
+
}
|
|
29
|
+
|
|
25
30
|
// =====================================================================
|
|
26
31
|
// Data Structures
|
|
27
32
|
// =====================================================================
|
|
@@ -643,7 +648,7 @@ export async function addRoleToSession(msg) {
|
|
|
643
648
|
// 发送系统消息
|
|
644
649
|
sendCrewOutput(session, 'system', 'system', {
|
|
645
650
|
type: 'assistant',
|
|
646
|
-
message: { role: 'assistant', content: [{ type: 'text', text: `${r
|
|
651
|
+
message: { role: 'assistant', content: [{ type: 'text', text: `${roleLabel(r)} 加入了群聊` }] }
|
|
647
652
|
});
|
|
648
653
|
}
|
|
649
654
|
|
|
@@ -709,7 +714,7 @@ export async function removeRoleFromSession(msg) {
|
|
|
709
714
|
|
|
710
715
|
sendCrewOutput(session, 'system', 'system', {
|
|
711
716
|
type: 'assistant',
|
|
712
|
-
message: { role: 'assistant', content: [{ type: 'text', text: `${role
|
|
717
|
+
message: { role: 'assistant', content: [{ type: 'text', text: `${roleLabel(role)} 离开了群聊` }] }
|
|
713
718
|
});
|
|
714
719
|
|
|
715
720
|
sendStatusUpdate(session);
|
|
@@ -775,7 +780,7 @@ ${projectDir}
|
|
|
775
780
|
所有代码操作请使用此绝对路径。
|
|
776
781
|
|
|
777
782
|
# 团队成员
|
|
778
|
-
${roles.length > 0 ? roles.map(r => `- ${r
|
|
783
|
+
${roles.length > 0 ? roles.map(r => `- ${roleLabel(r)}(${r.name}): ${r.description}${r.isDecisionMaker ? ' (决策者)' : ''}`).join('\n') : '_暂无成员_'}
|
|
779
784
|
|
|
780
785
|
# 工作约定
|
|
781
786
|
- 文档产出写入 context/ 目录
|
|
@@ -796,7 +801,7 @@ _团队共同维护,记录重要的共识、决策和信息。_
|
|
|
796
801
|
async function writeRoleClaudeMd(sharedDir, role) {
|
|
797
802
|
const roleDir = join(sharedDir, 'roles', role.name);
|
|
798
803
|
|
|
799
|
-
let claudeMd = `# 角色: ${role
|
|
804
|
+
let claudeMd = `# 角色: ${roleLabel(role)}
|
|
800
805
|
${role.claudeMd || role.description}
|
|
801
806
|
`;
|
|
802
807
|
|
|
@@ -941,7 +946,7 @@ function buildRoleSystemPrompt(role, session) {
|
|
|
941
946
|
你正在一个 AI 团队中工作。${session.goal ? `项目目标是: ${session.goal}` : '等待用户提出任务或问题。'}
|
|
942
947
|
|
|
943
948
|
团队成员:
|
|
944
|
-
${allRoles.map(r => `- ${r
|
|
949
|
+
${allRoles.map(r => `- ${roleLabel(r)}: ${r.description}${r.isDecisionMaker ? ' (决策者)' : ''}`).join('\n')}`;
|
|
945
950
|
|
|
946
951
|
const hasMultiInstance = allRoles.some(r => r.groupIndex > 0);
|
|
947
952
|
|
|
@@ -958,7 +963,7 @@ summary: <简要说明要传递什么>
|
|
|
958
963
|
\`\`\`
|
|
959
964
|
|
|
960
965
|
可用的路由目标:
|
|
961
|
-
${routeTargets.map(r => `- ${r.name}: ${r
|
|
966
|
+
${routeTargets.map(r => `- ${r.name}: ${roleLabel(r)} — ${r.description}`).join('\n')}
|
|
962
967
|
- human: 人工(只在决策者也无法决定时使用)
|
|
963
968
|
|
|
964
969
|
注意:
|
|
@@ -1063,8 +1068,8 @@ summary: 请实现注册页面,包括邮箱验证
|
|
|
1063
1068
|
if (rev && test) {
|
|
1064
1069
|
prompt += `\n\n# 开发组绑定
|
|
1065
1070
|
你属于开发组 ${gi}。你的搭档:
|
|
1066
|
-
- 审查者: ${rev
|
|
1067
|
-
- 测试: ${test
|
|
1071
|
+
- 审查者: ${roleLabel(rev)} (${rev.name})
|
|
1072
|
+
- 测试: ${roleLabel(test)} (${test.name})
|
|
1068
1073
|
|
|
1069
1074
|
开发完成后,请同时发两个 ROUTE 块分别给 ${rev.name} 和 ${test.name}:
|
|
1070
1075
|
|
|
@@ -1099,7 +1104,7 @@ function buildInitialTask(goal, firstRole, allRoles) {
|
|
|
1099
1104
|
完成后,通过 ROUTE 块将结果传递给下一个合适的角色。
|
|
1100
1105
|
|
|
1101
1106
|
团队中可用的角色:
|
|
1102
|
-
${allRoles.map(r => `- ${r.
|
|
1107
|
+
${allRoles.map(r => `- ${r.name}: ${roleLabel(r)} - ${r.description}`).join('\n')}`;
|
|
1103
1108
|
}
|
|
1104
1109
|
|
|
1105
1110
|
// =====================================================================
|
|
@@ -1359,7 +1364,7 @@ async function executeRoute(session, fromRole, route) {
|
|
|
1359
1364
|
*/
|
|
1360
1365
|
function buildRoutePrompt(fromRole, summary, session) {
|
|
1361
1366
|
const fromRoleConfig = session.roles.get(fromRole);
|
|
1362
|
-
const fromName = fromRoleConfig ?
|
|
1367
|
+
const fromName = fromRoleConfig ? roleLabel(fromRoleConfig) : fromRole;
|
|
1363
1368
|
return `来自 ${fromName} 的消息:\n${summary}\n\n请开始你的工作。完成后通过 ROUTE 块传递给下一个角色。`;
|
|
1364
1369
|
}
|
|
1365
1370
|
|
|
@@ -1426,7 +1431,7 @@ export async function handleCrewHumanInput(msg) {
|
|
|
1426
1431
|
// 注意:不在这里发送人的消息到 Web(前端已本地添加,避免重复)
|
|
1427
1432
|
// 但需要记录到 uiMessages 用于恢复时重放
|
|
1428
1433
|
session.uiMessages.push({
|
|
1429
|
-
role: 'human', roleIcon: '
|
|
1434
|
+
role: 'human', roleIcon: '', roleName: '你',
|
|
1430
1435
|
type: 'text', content,
|
|
1431
1436
|
timestamp: Date.now()
|
|
1432
1437
|
});
|
|
@@ -1688,7 +1693,7 @@ function sendCrewMessage(msg) {
|
|
|
1688
1693
|
*/
|
|
1689
1694
|
function sendCrewOutput(session, roleName, outputType, rawMessage, extra = {}) {
|
|
1690
1695
|
const role = session.roles.get(roleName);
|
|
1691
|
-
const roleIcon = role?.icon ||
|
|
1696
|
+
const roleIcon = role?.icon || '';
|
|
1692
1697
|
const displayName = role?.displayName || roleName;
|
|
1693
1698
|
|
|
1694
1699
|
// 从 roleState 获取当前 task 信息
|