team-anya-cli 0.1.8 → 1.0.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 (168) hide show
  1. package/README.md +1 -37
  2. package/package.json +6 -37
  3. package/anya/prompts/execution-guides/git-delivery.md +0 -38
  4. package/anya/prompts/execution-guides/testing-and-self-heal.md +0 -28
  5. package/anya/prompts/protocols/brief-assembly.md +0 -55
  6. package/anya/prompts/protocols/report.md +0 -175
  7. package/anya/prompts/protocols/review.md +0 -90
  8. package/anya/prompts/task-claude-md.template.md +0 -32
  9. package/apps/server/dist/broker/cc-broker.js +0 -261
  10. package/apps/server/dist/cli.js +0 -296
  11. package/apps/server/dist/config.js +0 -76
  12. package/apps/server/dist/daemon.js +0 -51
  13. package/apps/server/dist/franky/context-builder.js +0 -160
  14. package/apps/server/dist/franky/franky-mcp-server.js +0 -107
  15. package/apps/server/dist/franky/franky-orchestrator.js +0 -450
  16. package/apps/server/dist/franky/index.js +0 -5
  17. package/apps/server/dist/franky/topic-router.js +0 -16
  18. package/apps/server/dist/gateway/chat-sync.js +0 -135
  19. package/apps/server/dist/gateway/command-router.js +0 -114
  20. package/apps/server/dist/gateway/commands/cancel.js +0 -32
  21. package/apps/server/dist/gateway/commands/help.js +0 -16
  22. package/apps/server/dist/gateway/commands/index.js +0 -26
  23. package/apps/server/dist/gateway/commands/restart.js +0 -34
  24. package/apps/server/dist/gateway/commands/status.js +0 -34
  25. package/apps/server/dist/gateway/commands/tasks.js +0 -33
  26. package/apps/server/dist/gateway/feishu-sender.js +0 -410
  27. package/apps/server/dist/gateway/feishu-ws.js +0 -256
  28. package/apps/server/dist/gateway/http.js +0 -1019
  29. package/apps/server/dist/gateway/media-downloader.js +0 -149
  30. package/apps/server/dist/gateway/message-events.js +0 -10
  31. package/apps/server/dist/gateway/message-intake.js +0 -67
  32. package/apps/server/dist/gateway/message-queue.js +0 -118
  33. package/apps/server/dist/gateway/session-reader.js +0 -142
  34. package/apps/server/dist/gateway/ws-push.js +0 -115
  35. package/apps/server/dist/loid/brain.js +0 -105
  36. package/apps/server/dist/loid/clarifier.js +0 -162
  37. package/apps/server/dist/loid/context-builder.js +0 -413
  38. package/apps/server/dist/loid/mcp-server.js +0 -106
  39. package/apps/server/dist/loid/memory-settler.js +0 -189
  40. package/apps/server/dist/loid/opportunity-manager.js +0 -148
  41. package/apps/server/dist/loid/profile-updater.js +0 -179
  42. package/apps/server/dist/loid/reporter.js +0 -148
  43. package/apps/server/dist/loid/schemas.js +0 -117
  44. package/apps/server/dist/loid/self-calibrator.js +0 -314
  45. package/apps/server/dist/loid/session-manager.js +0 -301
  46. package/apps/server/dist/loid/session.js +0 -271
  47. package/apps/server/dist/loid/worktree-manager.js +0 -191
  48. package/apps/server/dist/main.js +0 -393
  49. package/apps/server/dist/tracing/index.js +0 -2
  50. package/apps/server/dist/tracing/trace-context.js +0 -92
  51. package/apps/server/dist/types/message.js +0 -2
  52. package/apps/server/dist/yor/yor-mcp-server.js +0 -104
  53. package/apps/server/dist/yor/yor-orchestrator.js +0 -233
  54. package/apps/web/dist/assets/index-BiiEB0qZ.css +0 -1
  55. package/apps/web/dist/assets/index-D1AK5ZEE.js +0 -798
  56. package/apps/web/dist/index.html +0 -13
  57. package/packages/cc-client/dist/claude-code-backend.js +0 -664
  58. package/packages/cc-client/dist/index.js +0 -2
  59. package/packages/cc-client/package.json +0 -11
  60. package/packages/core/dist/constants.js +0 -59
  61. package/packages/core/dist/errors.js +0 -35
  62. package/packages/core/dist/index.js +0 -7
  63. package/packages/core/dist/office-init.js +0 -101
  64. package/packages/core/dist/scope/checker.js +0 -114
  65. package/packages/core/dist/scope/defaults.js +0 -55
  66. package/packages/core/dist/scope/index.js +0 -3
  67. package/packages/core/dist/state-machine.js +0 -85
  68. package/packages/core/dist/types/audit.js +0 -12
  69. package/packages/core/dist/types/backend.js +0 -2
  70. package/packages/core/dist/types/commitment.js +0 -17
  71. package/packages/core/dist/types/communication.js +0 -18
  72. package/packages/core/dist/types/index.js +0 -8
  73. package/packages/core/dist/types/opportunity.js +0 -27
  74. package/packages/core/dist/types/org.js +0 -26
  75. package/packages/core/dist/types/task.js +0 -46
  76. package/packages/core/package.json +0 -10
  77. package/packages/db/dist/client.js +0 -69
  78. package/packages/db/dist/index.js +0 -691
  79. package/packages/db/dist/schema/audit-events.js +0 -13
  80. package/packages/db/dist/schema/cc-sessions.js +0 -14
  81. package/packages/db/dist/schema/chats.js +0 -33
  82. package/packages/db/dist/schema/commitments.js +0 -18
  83. package/packages/db/dist/schema/communication-events.js +0 -14
  84. package/packages/db/dist/schema/index.js +0 -13
  85. package/packages/db/dist/schema/message-log.js +0 -20
  86. package/packages/db/dist/schema/opportunities.js +0 -23
  87. package/packages/db/dist/schema/org.js +0 -36
  88. package/packages/db/dist/schema/projects.js +0 -23
  89. package/packages/db/dist/schema/tasks.js +0 -48
  90. package/packages/db/dist/schema/topics.js +0 -20
  91. package/packages/db/dist/schema/trace-spans.js +0 -19
  92. package/packages/db/package.json +0 -12
  93. package/packages/db/src/migrations/0000_baseline.sql +0 -251
  94. package/packages/db/src/migrations/meta/_journal.json +0 -13
  95. package/packages/mcp-tools/dist/index.js +0 -41
  96. package/packages/mcp-tools/dist/layer1/audit-append.js +0 -38
  97. package/packages/mcp-tools/dist/layer1/audit-query.js +0 -51
  98. package/packages/mcp-tools/dist/layer1/memory-brief.js +0 -168
  99. package/packages/mcp-tools/dist/layer1/memory-context.js +0 -124
  100. package/packages/mcp-tools/dist/layer1/memory-digest.js +0 -126
  101. package/packages/mcp-tools/dist/layer1/memory-forget.js +0 -108
  102. package/packages/mcp-tools/dist/layer1/memory-learn.js +0 -63
  103. package/packages/mcp-tools/dist/layer1/memory-recall.js +0 -287
  104. package/packages/mcp-tools/dist/layer1/memory-reflect.js +0 -80
  105. package/packages/mcp-tools/dist/layer1/memory-remember.js +0 -119
  106. package/packages/mcp-tools/dist/layer1/memory-search.js +0 -263
  107. package/packages/mcp-tools/dist/layer1/memory-write.js +0 -21
  108. package/packages/mcp-tools/dist/layer1/org-lookup.js +0 -47
  109. package/packages/mcp-tools/dist/layer1/project-get.js +0 -28
  110. package/packages/mcp-tools/dist/layer1/project-list.js +0 -20
  111. package/packages/mcp-tools/dist/layer1/report-daily.js +0 -68
  112. package/packages/mcp-tools/dist/layer1/task-get.js +0 -29
  113. package/packages/mcp-tools/dist/layer1/task-update.js +0 -34
  114. package/packages/mcp-tools/dist/layer2/franky/topic-checkpoint.js +0 -43
  115. package/packages/mcp-tools/dist/layer2/franky/topic-escalate.js +0 -19
  116. package/packages/mcp-tools/dist/layer2/loid/decision-log.js +0 -15
  117. package/packages/mcp-tools/dist/layer2/loid/decision-no-action.js +0 -15
  118. package/packages/mcp-tools/dist/layer2/loid/delivery-create-pr.js +0 -30
  119. package/packages/mcp-tools/dist/layer2/loid/delivery-share.js +0 -12
  120. package/packages/mcp-tools/dist/layer2/loid/delivery-submit.js +0 -77
  121. package/packages/mcp-tools/dist/layer2/loid/delivery-upload.js +0 -18
  122. package/packages/mcp-tools/dist/layer2/loid/project-remove.js +0 -16
  123. package/packages/mcp-tools/dist/layer2/loid/project-upsert.js +0 -33
  124. package/packages/mcp-tools/dist/layer2/loid/task-dispatch.js +0 -196
  125. package/packages/mcp-tools/dist/layer2/loid/task-lookup.js +0 -38
  126. package/packages/mcp-tools/dist/layer2/loid/topic-close.js +0 -22
  127. package/packages/mcp-tools/dist/layer2/loid/topic-create.js +0 -56
  128. package/packages/mcp-tools/dist/layer2/loid/yor-approve.js +0 -8
  129. package/packages/mcp-tools/dist/layer2/loid/yor-kill.js +0 -7
  130. package/packages/mcp-tools/dist/layer2/loid/yor-rework.js +0 -7
  131. package/packages/mcp-tools/dist/layer2/loid/yor-spawn.js +0 -15
  132. package/packages/mcp-tools/dist/layer2/loid/yor-status.js +0 -8
  133. package/packages/mcp-tools/dist/layer2/yor/task-block.js +0 -11
  134. package/packages/mcp-tools/dist/layer2/yor/task-deliver.js +0 -35
  135. package/packages/mcp-tools/dist/layer2/yor/task-progress.js +0 -21
  136. package/packages/mcp-tools/dist/layer3/adapters/feishu-adapter.js +0 -192
  137. package/packages/mcp-tools/dist/layer3/adapters/types.js +0 -28
  138. package/packages/mcp-tools/dist/layer3/channel-receive.js +0 -11
  139. package/packages/mcp-tools/dist/layer3/channel-send.js +0 -91
  140. package/packages/mcp-tools/dist/layer3/file-upload.js +0 -44
  141. package/packages/mcp-tools/dist/registry.js +0 -871
  142. package/packages/mcp-tools/package.json +0 -13
  143. package/workspace/.claude/settings.local.json +0 -9
  144. package/workspace/.mcp.json +0 -12
  145. package/workspace/CHARTER.md +0 -76
  146. package/workspace/CLAUDE.md +0 -58
  147. package/workspace/PROTOCOL.md +0 -160
  148. package/workspace/TOOLS.md +0 -470
  149. package/workspace/audit/.gitkeep +0 -0
  150. package/workspace/franky/CLAUDE.md +0 -37
  151. package/workspace/franky/PLAYBOOK.md +0 -215
  152. package/workspace/franky/PROFILE.md +0 -80
  153. package/workspace/loid/CLAUDE.md +0 -12
  154. package/workspace/loid/PLAYBOOK.md +0 -198
  155. package/workspace/loid/PROFILE.md +0 -78
  156. package/workspace/memory/commitments/.gitkeep +0 -0
  157. package/workspace/memory/execution/.gitkeep +0 -0
  158. package/workspace/memory/people/.gitkeep +0 -0
  159. package/workspace/memory/projects/.gitkeep +0 -0
  160. package/workspace/memory/self/.gitkeep +0 -0
  161. package/workspace/reference/identity/.gitkeep +0 -0
  162. package/workspace/reference/org/escalation.yaml +0 -24
  163. package/workspace/reference/org/ownership.yaml +0 -28
  164. package/workspace/reports/.gitkeep +0 -0
  165. package/workspace/yor/CLAUDE.md +0 -22
  166. package/workspace/yor/PLAYBOOK.md +0 -73
  167. package/workspace/yor/PROFILE.md +0 -52
  168. package/workspace/yor/SELF-HEAL.md +0 -39
@@ -1,114 +0,0 @@
1
- // ── CommandRouter ──
2
- export class CommandRouter {
3
- commands = new Map();
4
- deps;
5
- constructor(deps) {
6
- this.deps = deps;
7
- }
8
- register(cmd) {
9
- this.commands.set(cmd.name, cmd);
10
- for (const alias of cmd.aliases) {
11
- this.commands.set(alias, cmd);
12
- }
13
- }
14
- getCommands() {
15
- const seen = new Set();
16
- const result = [];
17
- for (const cmd of this.commands.values()) {
18
- if (!seen.has(cmd.name)) {
19
- seen.add(cmd.name);
20
- result.push(cmd);
21
- }
22
- }
23
- return result;
24
- }
25
- /**
26
- * 尝试处理消息。返回 true 表示已拦截(不需要送 Loid)。
27
- */
28
- async tryHandle(message) {
29
- const parsed = this.parseCommand(message);
30
- if (!parsed)
31
- return false;
32
- const { commandName, args } = parsed;
33
- const cmd = this.commands.get(commandName);
34
- if (!cmd)
35
- return false;
36
- const logger = this.deps.logger;
37
- logger?.info(`[CommandRouter] 匹配命令: /${cmd.name} (category: ${cmd.category})`);
38
- // pass-through:标记 metadata 后继续送 Loid
39
- if (cmd.category === 'pass-through') {
40
- if (!message.metadata)
41
- message.metadata = {};
42
- message.metadata._command = cmd.name;
43
- message.metadata._commandArgs = args;
44
- return false;
45
- }
46
- // intercepted / control:执行 handler 并直接回复
47
- try {
48
- const ctx = {
49
- message,
50
- args,
51
- db: this.deps.db,
52
- broker: this.deps.broker,
53
- router: this,
54
- onRestart: this.deps.onRestart,
55
- };
56
- const result = await cmd.handler(ctx);
57
- if (result) {
58
- await this.sendResponse(message, result);
59
- }
60
- }
61
- catch (err) {
62
- logger?.error(`[CommandRouter] 命令执行失败 (/${cmd.name}):`, err);
63
- await this.sendResponse(message, {
64
- text: `命令执行出错: ${err instanceof Error ? err.message : String(err)}`,
65
- });
66
- }
67
- return true;
68
- }
69
- /**
70
- * 解析消息中的命令名和参数。
71
- * 群聊需要 mentionsAnya,私聊直接匹配。
72
- */
73
- parseCommand(message) {
74
- let text = message.content.trim();
75
- // 群聊:需要 @Anya
76
- if (!message.isDirectMessage) {
77
- if (!message.mentionsAnya)
78
- return null;
79
- // 去掉 @mention 前缀(飞书格式通常是 @_user_1 或已被替换为空)
80
- text = text.replace(/^@\S+\s*/, '').trim();
81
- }
82
- // 匹配 /command 格式
83
- const slashMatch = text.match(/^\/(\S+)(?:\s+(.*))?$/s);
84
- if (slashMatch) {
85
- return { commandName: slashMatch[1].toLowerCase(), args: (slashMatch[2] ?? '').trim() };
86
- }
87
- // 裸词匹配:仅对已注册命令名/别名生效
88
- const firstWord = text.split(/\s+/)[0]?.toLowerCase();
89
- if (firstWord && this.commands.has(firstWord)) {
90
- const rest = text.slice(firstWord.length).trim();
91
- return { commandName: firstWord, args: rest };
92
- }
93
- return null;
94
- }
95
- async sendResponse(message, result) {
96
- const sender = this.deps.feishuSender;
97
- const messageId = message.metadata?.message_id;
98
- try {
99
- if (messageId) {
100
- await sender.sendReply({ text: result.text, replyToMessageId: messageId });
101
- }
102
- else if (message.chatId) {
103
- await sender.sendText({ receiveIdType: 'chat_id', receiveId: message.chatId, text: result.text });
104
- }
105
- else if (message.sender) {
106
- await sender.sendText({ receiveIdType: 'open_id', receiveId: message.sender, text: result.text });
107
- }
108
- }
109
- catch (err) {
110
- this.deps.logger?.error('[CommandRouter] 发送回复失败:', err);
111
- }
112
- }
113
- }
114
- //# sourceMappingURL=command-router.js.map
@@ -1,32 +0,0 @@
1
- import { getTask, updateTask, insertAuditEvent } from '@team-anya/db';
2
- import { TaskStatus, validateTransition } from '@team-anya/core';
3
- export const cancelCommand = {
4
- name: 'cancel',
5
- aliases: ['取消'],
6
- category: 'control',
7
- description: '取消任务(/cancel <task_id>)',
8
- handler: async (ctx) => {
9
- const taskId = ctx.args.trim();
10
- if (!taskId) {
11
- return { text: '请指定任务 ID,例如: /cancel ANYA-20260224-001' };
12
- }
13
- const task = getTask(ctx.db, taskId);
14
- if (!task) {
15
- return { text: `任务 ${taskId} 不存在` };
16
- }
17
- const currentStatus = task.status;
18
- if (!validateTransition(currentStatus, TaskStatus.CANCELLED)) {
19
- return { text: `任务 ${taskId} 当前状态为 ${currentStatus},无法取消` };
20
- }
21
- updateTask(ctx.db, taskId, { status: TaskStatus.CANCELLED });
22
- insertAuditEvent(ctx.db, {
23
- event_type: 'command_invoked',
24
- actor: ctx.message.senderName ?? ctx.message.sender ?? 'unknown',
25
- summary: `取消任务 ${taskId}`,
26
- task_id: taskId,
27
- detail: JSON.stringify({ command: 'cancel', from: currentStatus, to: TaskStatus.CANCELLED }),
28
- });
29
- return { text: `任务 ${taskId} 已取消(${currentStatus} → CANCELLED)` };
30
- },
31
- };
32
- //# sourceMappingURL=cancel.js.map
@@ -1,16 +0,0 @@
1
- export const helpCommand = {
2
- name: 'help',
3
- aliases: ['h', '帮助'],
4
- category: 'intercepted',
5
- description: '显示命令列表',
6
- handler: async (ctx) => {
7
- const commands = ctx.router.getCommands();
8
- const lines = ['📋 可用命令:', ''];
9
- for (const cmd of commands) {
10
- const aliases = cmd.aliases.length > 0 ? ` (${cmd.aliases.join(', ')})` : '';
11
- lines.push(`/${cmd.name}${aliases} — ${cmd.description}`);
12
- }
13
- return { text: lines.join('\n') };
14
- },
15
- };
16
- //# sourceMappingURL=help.js.map
@@ -1,26 +0,0 @@
1
- import { helpCommand } from './help.js';
2
- import { statusCommand } from './status.js';
3
- import { tasksCommand } from './tasks.js';
4
- import { cancelCommand } from './cancel.js';
5
- import { restartCommand } from './restart.js';
6
- // pass-through 命令(仅标记 metadata,透传给 Loid)
7
- const passThrough = (name, description) => ({
8
- name,
9
- aliases: [],
10
- category: 'pass-through',
11
- description,
12
- handler: async () => null,
13
- });
14
- export function registerBuiltinCommands(router) {
15
- // 直接处理
16
- router.register(helpCommand);
17
- router.register(statusCommand);
18
- router.register(tasksCommand);
19
- router.register(cancelCommand);
20
- router.register(restartCommand);
21
- // 透传 Loid
22
- router.register(passThrough('task', '显式创建任务(透传 Loid)'));
23
- router.register(passThrough('report', '生成报告(透传 Loid)'));
24
- router.register(passThrough('review', '审核交付(透传 Loid)'));
25
- }
26
- //# sourceMappingURL=index.js.map
@@ -1,34 +0,0 @@
1
- export const restartCommand = {
2
- name: 'restart',
3
- aliases: ['重启'],
4
- category: 'control',
5
- description: '重启所有 Claude Code 实例(安装 skills 后需要重启生效)',
6
- handler: async (ctx) => {
7
- if (!ctx.onRestart) {
8
- return { text: '重启功能未配置' };
9
- }
10
- // 列出当前实例
11
- const instances = ctx.broker.status();
12
- const activeCount = instances.filter(i => i.state !== 'disposed').length;
13
- if (activeCount === 0) {
14
- return { text: '当前没有活跃的 CC 实例,无需重启' };
15
- }
16
- // 检查正在执行任务的 Yor 实例
17
- const executingYor = instances.filter(i => i.role === 'yor' && i.state === 'executing');
18
- let warning = '';
19
- if (executingYor.length > 0) {
20
- const taskIds = executingYor.map(i => i.taskId ?? i.id).join(', ');
21
- warning = `\n\n⚠️ 注意: ${executingYor.length} 个 Yor 实例正在执行任务 (${taskIds}),已强制终止`;
22
- }
23
- const result = await ctx.onRestart();
24
- const lines = [
25
- '🔄 CC 实例已全部重启',
26
- '',
27
- `已释放实例: ${result.disposed} 个`,
28
- 'Loid 会话将在下次收到消息时自动重建',
29
- 'Yor 实例将在下次派工时重新创建',
30
- ];
31
- return { text: lines.join('\n') + warning };
32
- },
33
- };
34
- //# sourceMappingURL=restart.js.map
@@ -1,34 +0,0 @@
1
- import { getTaskCountByStatus } from '@team-anya/db';
2
- export const statusCommand = {
3
- name: 'status',
4
- aliases: ['s', '状态'],
5
- category: 'intercepted',
6
- description: '系统状态概览',
7
- handler: async (ctx) => {
8
- const counts = getTaskCountByStatus(ctx.db);
9
- const total = Object.values(counts).reduce((a, b) => a + b, 0);
10
- const yorInstances = ctx.broker.getInstancesByRole('yor');
11
- const activeYorCount = yorInstances.length;
12
- const lines = ['📊 系统状态', ''];
13
- lines.push(`任务总数: ${total}`);
14
- if (total > 0) {
15
- const statusLabels = {
16
- NEW: '新建',
17
- NEED_CLARIFICATION: '待澄清',
18
- READY: '就绪',
19
- IN_PROGRESS: '执行中',
20
- DELIVERING: '交付中',
21
- DONE: '已完成',
22
- BLOCKED: '已阻塞',
23
- CANCELLED: '已取消',
24
- };
25
- for (const [status, count] of Object.entries(counts)) {
26
- const label = statusLabels[status] ?? status;
27
- lines.push(` ${label}: ${count}`);
28
- }
29
- }
30
- lines.push(`\n活跃 Yor 实例: ${activeYorCount}`);
31
- return { text: lines.join('\n') };
32
- },
33
- };
34
- //# sourceMappingURL=status.js.map
@@ -1,33 +0,0 @@
1
- import { getAllTasks, getTasksByChatId, getTasksByStatus } from '@team-anya/db';
2
- const MAX_DISPLAY = 15;
3
- export const tasksCommand = {
4
- name: 'tasks',
5
- aliases: ['t', '任务'],
6
- category: 'intercepted',
7
- description: '任务列表(支持状态过滤:/tasks in_progress)',
8
- handler: async (ctx) => {
9
- const statusFilter = ctx.args.toUpperCase().trim();
10
- let taskList;
11
- if (statusFilter) {
12
- taskList = getTasksByStatus(ctx.db, statusFilter);
13
- }
14
- else if (!ctx.message.isDirectMessage && ctx.message.chatId) {
15
- taskList = getTasksByChatId(ctx.db, ctx.message.chatId);
16
- }
17
- else {
18
- taskList = getAllTasks(ctx.db);
19
- }
20
- if (taskList.length === 0) {
21
- const hint = statusFilter ? `(状态: ${statusFilter})` : '';
22
- return { text: `暂无任务${hint}` };
23
- }
24
- const displayed = taskList.slice(0, MAX_DISPLAY);
25
- const lines = [`📝 任务列表(共 ${taskList.length} 条${taskList.length > MAX_DISPLAY ? `,显示前 ${MAX_DISPLAY} 条` : ''}):`, ''];
26
- for (const task of displayed) {
27
- const status = task.status.padEnd(18);
28
- lines.push(`${task.task_id} ${status} ${task.title ?? '(无标题)'}`);
29
- }
30
- return { text: lines.join('\n') };
31
- },
32
- };
33
- //# sourceMappingURL=tasks.js.map