team-anya-cli 0.1.0
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/README.md +38 -0
- package/anya/prompts/execution-guides/git-delivery.md +38 -0
- package/anya/prompts/execution-guides/testing-and-self-heal.md +28 -0
- package/anya/prompts/protocols/brief-assembly.md +55 -0
- package/anya/prompts/protocols/report.md +175 -0
- package/anya/prompts/protocols/review.md +90 -0
- package/anya/prompts/task-claude-md.template.md +32 -0
- package/apps/server/dist/broker/cc-broker.js +257 -0
- package/apps/server/dist/cli.js +296 -0
- package/apps/server/dist/config.js +76 -0
- package/apps/server/dist/daemon.js +51 -0
- package/apps/server/dist/gateway/chat-sync.js +135 -0
- package/apps/server/dist/gateway/command-router.js +114 -0
- package/apps/server/dist/gateway/commands/cancel.js +32 -0
- package/apps/server/dist/gateway/commands/help.js +16 -0
- package/apps/server/dist/gateway/commands/index.js +26 -0
- package/apps/server/dist/gateway/commands/restart.js +34 -0
- package/apps/server/dist/gateway/commands/status.js +34 -0
- package/apps/server/dist/gateway/commands/tasks.js +33 -0
- package/apps/server/dist/gateway/feishu-sender.js +346 -0
- package/apps/server/dist/gateway/feishu-ws.js +254 -0
- package/apps/server/dist/gateway/http.js +994 -0
- package/apps/server/dist/gateway/media-downloader.js +149 -0
- package/apps/server/dist/gateway/message-events.js +10 -0
- package/apps/server/dist/gateway/message-intake.js +50 -0
- package/apps/server/dist/gateway/message-queue.js +104 -0
- package/apps/server/dist/gateway/session-reader.js +142 -0
- package/apps/server/dist/gateway/ws-push.js +115 -0
- package/apps/server/dist/loid/brain.js +104 -0
- package/apps/server/dist/loid/clarifier.js +162 -0
- package/apps/server/dist/loid/context-builder.js +413 -0
- package/apps/server/dist/loid/mcp-server.js +104 -0
- package/apps/server/dist/loid/memory-settler.js +189 -0
- package/apps/server/dist/loid/opportunity-manager.js +148 -0
- package/apps/server/dist/loid/profile-updater.js +179 -0
- package/apps/server/dist/loid/reporter.js +148 -0
- package/apps/server/dist/loid/schemas.js +117 -0
- package/apps/server/dist/loid/self-calibrator.js +314 -0
- package/apps/server/dist/loid/session-manager.js +217 -0
- package/apps/server/dist/loid/session.js +271 -0
- package/apps/server/dist/loid/worktree-manager.js +191 -0
- package/apps/server/dist/main.js +337 -0
- package/apps/server/dist/tracing/index.js +2 -0
- package/apps/server/dist/tracing/trace-context.js +92 -0
- package/apps/server/dist/types/message.js +2 -0
- package/apps/server/dist/yor/yor-mcp-server.js +104 -0
- package/apps/server/dist/yor/yor-orchestrator.js +233 -0
- package/apps/web/dist/assets/index-CHIT0Dya.css +1 -0
- package/apps/web/dist/assets/index-CJzAjoVH.js +798 -0
- package/apps/web/dist/index.html +13 -0
- package/package.json +42 -0
- package/packages/cc-client/dist/claude-code-backend.js +664 -0
- package/packages/cc-client/dist/index.js +2 -0
- package/packages/cc-client/package.json +11 -0
- package/packages/core/dist/constants.js +59 -0
- package/packages/core/dist/errors.js +35 -0
- package/packages/core/dist/index.js +7 -0
- package/packages/core/dist/office-init.js +97 -0
- package/packages/core/dist/scope/checker.js +114 -0
- package/packages/core/dist/scope/defaults.js +40 -0
- package/packages/core/dist/scope/index.js +3 -0
- package/packages/core/dist/state-machine.js +85 -0
- package/packages/core/dist/types/audit.js +12 -0
- package/packages/core/dist/types/backend.js +2 -0
- package/packages/core/dist/types/commitment.js +17 -0
- package/packages/core/dist/types/communication.js +18 -0
- package/packages/core/dist/types/index.js +8 -0
- package/packages/core/dist/types/opportunity.js +27 -0
- package/packages/core/dist/types/org.js +26 -0
- package/packages/core/dist/types/task.js +46 -0
- package/packages/core/package.json +10 -0
- package/packages/db/dist/client.js +69 -0
- package/packages/db/dist/index.js +603 -0
- package/packages/db/dist/schema/audit-events.js +13 -0
- package/packages/db/dist/schema/cc-sessions.js +14 -0
- package/packages/db/dist/schema/chats.js +33 -0
- package/packages/db/dist/schema/commitments.js +18 -0
- package/packages/db/dist/schema/communication-events.js +14 -0
- package/packages/db/dist/schema/index.js +12 -0
- package/packages/db/dist/schema/message-log.js +20 -0
- package/packages/db/dist/schema/opportunities.js +23 -0
- package/packages/db/dist/schema/org.js +36 -0
- package/packages/db/dist/schema/projects.js +23 -0
- package/packages/db/dist/schema/tasks.js +46 -0
- package/packages/db/dist/schema/trace-spans.js +19 -0
- package/packages/db/package.json +12 -0
- package/packages/db/src/migrations/0000_simple_magneto.sql +148 -0
- package/packages/db/src/migrations/0001_nifty_morph.sql +42 -0
- package/packages/db/src/migrations/0002_common_joshua_kane.sql +20 -0
- package/packages/db/src/migrations/0003_add_cc_sessions.sql +13 -0
- package/packages/db/src/migrations/0004_jittery_triathlon.sql +1 -0
- package/packages/db/src/migrations/meta/0000_snapshot.json +987 -0
- package/packages/db/src/migrations/meta/0001_snapshot.json +1280 -0
- package/packages/db/src/migrations/meta/0002_snapshot.json +1417 -0
- package/packages/db/src/migrations/meta/0004_snapshot.json +1505 -0
- package/packages/db/src/migrations/meta/_journal.json +41 -0
- package/packages/mcp-tools/dist/index.js +41 -0
- package/packages/mcp-tools/dist/layer1/audit-append.js +38 -0
- package/packages/mcp-tools/dist/layer1/audit-query.js +51 -0
- package/packages/mcp-tools/dist/layer1/memory-brief.js +168 -0
- package/packages/mcp-tools/dist/layer1/memory-context.js +124 -0
- package/packages/mcp-tools/dist/layer1/memory-digest.js +126 -0
- package/packages/mcp-tools/dist/layer1/memory-forget.js +108 -0
- package/packages/mcp-tools/dist/layer1/memory-learn.js +63 -0
- package/packages/mcp-tools/dist/layer1/memory-recall.js +287 -0
- package/packages/mcp-tools/dist/layer1/memory-reflect.js +80 -0
- package/packages/mcp-tools/dist/layer1/memory-remember.js +119 -0
- package/packages/mcp-tools/dist/layer1/memory-search.js +263 -0
- package/packages/mcp-tools/dist/layer1/memory-write.js +21 -0
- package/packages/mcp-tools/dist/layer1/org-lookup.js +47 -0
- package/packages/mcp-tools/dist/layer1/project-get.js +28 -0
- package/packages/mcp-tools/dist/layer1/project-list.js +20 -0
- package/packages/mcp-tools/dist/layer1/report-daily.js +68 -0
- package/packages/mcp-tools/dist/layer1/task-get.js +29 -0
- package/packages/mcp-tools/dist/layer1/task-update.js +34 -0
- package/packages/mcp-tools/dist/layer2/loid/decision-log.js +15 -0
- package/packages/mcp-tools/dist/layer2/loid/decision-no-action.js +15 -0
- package/packages/mcp-tools/dist/layer2/loid/delivery-create-pr.js +30 -0
- package/packages/mcp-tools/dist/layer2/loid/delivery-share.js +12 -0
- package/packages/mcp-tools/dist/layer2/loid/delivery-submit.js +77 -0
- package/packages/mcp-tools/dist/layer2/loid/delivery-upload.js +18 -0
- package/packages/mcp-tools/dist/layer2/loid/project-remove.js +16 -0
- package/packages/mcp-tools/dist/layer2/loid/project-upsert.js +33 -0
- package/packages/mcp-tools/dist/layer2/loid/task-dispatch.js +177 -0
- package/packages/mcp-tools/dist/layer2/loid/task-lookup.js +38 -0
- package/packages/mcp-tools/dist/layer2/loid/yor-approve.js +8 -0
- package/packages/mcp-tools/dist/layer2/loid/yor-kill.js +7 -0
- package/packages/mcp-tools/dist/layer2/loid/yor-rework.js +7 -0
- package/packages/mcp-tools/dist/layer2/loid/yor-spawn.js +15 -0
- package/packages/mcp-tools/dist/layer2/loid/yor-status.js +8 -0
- package/packages/mcp-tools/dist/layer2/yor/task-block.js +11 -0
- package/packages/mcp-tools/dist/layer2/yor/task-deliver.js +35 -0
- package/packages/mcp-tools/dist/layer2/yor/task-progress.js +21 -0
- package/packages/mcp-tools/dist/layer3/adapters/feishu-adapter.js +191 -0
- package/packages/mcp-tools/dist/layer3/adapters/types.js +28 -0
- package/packages/mcp-tools/dist/layer3/channel-receive.js +11 -0
- package/packages/mcp-tools/dist/layer3/channel-send.js +90 -0
- package/packages/mcp-tools/dist/layer3/file-upload.js +44 -0
- package/packages/mcp-tools/dist/registry.js +779 -0
- package/packages/mcp-tools/package.json +13 -0
- package/workspace/.claude/settings.local.json +9 -0
- package/workspace/.mcp.json +12 -0
- package/workspace/CHARTER.md +73 -0
- package/workspace/CLAUDE.md +49 -0
- package/workspace/PROTOCOL.md +126 -0
- package/workspace/TOOLS.md +464 -0
- package/workspace/audit/.gitkeep +0 -0
- package/workspace/loid/CLAUDE.md +12 -0
- package/workspace/loid/PLAYBOOK.md +198 -0
- package/workspace/loid/PROFILE.md +78 -0
- package/workspace/memory/commitments/.gitkeep +0 -0
- package/workspace/memory/execution/.gitkeep +0 -0
- package/workspace/memory/people/.gitkeep +0 -0
- package/workspace/memory/projects/.gitkeep +0 -0
- package/workspace/memory/self/.gitkeep +0 -0
- package/workspace/reference/identity/.gitkeep +0 -0
- package/workspace/reference/org/escalation.yaml +24 -0
- package/workspace/reference/org/ownership.yaml +28 -0
- package/workspace/reports/.gitkeep +0 -0
- package/workspace/yor/CLAUDE.md +22 -0
- package/workspace/yor/PLAYBOOK.md +73 -0
- package/workspace/yor/PROFILE.md +52 -0
- package/workspace/yor/SELF-HEAL.md +39 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { insertAuditEvent, insertMessageLog } from '@team-anya/db';
|
|
2
|
+
/** 默认通道(当前只支持飞书) */
|
|
3
|
+
const DEFAULT_SCHEME = 'feishu';
|
|
4
|
+
/**
|
|
5
|
+
* 向飞书群发消息
|
|
6
|
+
*
|
|
7
|
+
* target 直接填群聊 ID(如 oc_xxx)。
|
|
8
|
+
* 支持发送文件、@ 用户和回复消息。
|
|
9
|
+
*/
|
|
10
|
+
export async function channelSend(deps, input) {
|
|
11
|
+
const { db, channelRegistry, logger } = deps;
|
|
12
|
+
const scheme = DEFAULT_SCHEME;
|
|
13
|
+
const chatTarget = input.target;
|
|
14
|
+
const adapter = channelRegistry.get(scheme);
|
|
15
|
+
if (!adapter) {
|
|
16
|
+
const error = `通道 ${scheme} 未注册(已注册: ${channelRegistry.getSchemes().join(', ')})`;
|
|
17
|
+
logger?.error(`[anya:pipeline] channel.send: ${error}`);
|
|
18
|
+
return { sent: false, error };
|
|
19
|
+
}
|
|
20
|
+
const sendOptions = {
|
|
21
|
+
replyTo: input.reply_to,
|
|
22
|
+
mentions: input.mentions,
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
let result;
|
|
26
|
+
if (input.file) {
|
|
27
|
+
if (!adapter.sendFile) {
|
|
28
|
+
const error = `通道 ${scheme} 不支持发送文件`;
|
|
29
|
+
logger?.error(`[anya:pipeline] channel.send: ${error}`);
|
|
30
|
+
return { sent: false, error };
|
|
31
|
+
}
|
|
32
|
+
result = await adapter.sendFile(chatTarget, {
|
|
33
|
+
filePath: input.file.file_path,
|
|
34
|
+
fileName: input.file.file_name,
|
|
35
|
+
fileType: input.file.file_type,
|
|
36
|
+
duration: input.file.duration,
|
|
37
|
+
}, input.message, sendOptions);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
result = await adapter.send(chatTarget, input.message, sendOptions);
|
|
41
|
+
}
|
|
42
|
+
// 记录出站消息
|
|
43
|
+
try {
|
|
44
|
+
insertMessageLog(db, {
|
|
45
|
+
direction: 'outbound',
|
|
46
|
+
source_type: scheme,
|
|
47
|
+
source_ref: result.id,
|
|
48
|
+
sender: 'anya',
|
|
49
|
+
receiver: chatTarget,
|
|
50
|
+
chat_id: chatTarget,
|
|
51
|
+
chat_type: 'group',
|
|
52
|
+
content: input.file ? `[文件] ${input.file.file_name ?? input.file.file_path} ${input.message}` : input.message,
|
|
53
|
+
message_type: 'message',
|
|
54
|
+
related_task_id: input.task_id ?? null,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
logger?.error('[anya:pipeline] channel.send: 记录 message_log 失败:', err);
|
|
59
|
+
}
|
|
60
|
+
// 审计日志
|
|
61
|
+
insertAuditEvent(db, {
|
|
62
|
+
event_type: 'channel_send',
|
|
63
|
+
actor: 'loid',
|
|
64
|
+
task_id: input.task_id ?? undefined,
|
|
65
|
+
summary: `通过 ${scheme} 发消息: ${input.message.slice(0, 100)}`,
|
|
66
|
+
detail: JSON.stringify({
|
|
67
|
+
target: chatTarget,
|
|
68
|
+
has_file: !!input.file,
|
|
69
|
+
has_mentions: !!input.mentions?.length,
|
|
70
|
+
reply_to: input.reply_to ?? null,
|
|
71
|
+
sent: true,
|
|
72
|
+
}),
|
|
73
|
+
});
|
|
74
|
+
deps.onMessageSent?.(chatTarget);
|
|
75
|
+
logger?.info(`[anya:pipeline] [Loid] channel.send (${scheme}${input.file ? ', file' : ''}): "${input.message.slice(0, 80)}"`);
|
|
76
|
+
return { sent: true, message_id: result.id };
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
logger?.error(`[anya:pipeline] channel.send 失败:`, err);
|
|
80
|
+
insertAuditEvent(db, {
|
|
81
|
+
event_type: 'channel_send_failed',
|
|
82
|
+
actor: 'loid',
|
|
83
|
+
task_id: input.task_id ?? undefined,
|
|
84
|
+
summary: `通道发送失败: ${String(err)}`,
|
|
85
|
+
detail: JSON.stringify({ target: chatTarget, error: String(err) }),
|
|
86
|
+
});
|
|
87
|
+
return { sent: false, error: String(err) };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=channel-send.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { insertAuditEvent } from '@team-anya/db';
|
|
2
|
+
/**
|
|
3
|
+
* file.upload - 通用文件上传
|
|
4
|
+
*
|
|
5
|
+
* 与通道无关。当前使用本地文件复制实现。
|
|
6
|
+
* 上传到 $ANYA_HOME/uploads/ 目录,返回本地路径作为 URL。
|
|
7
|
+
*/
|
|
8
|
+
export async function fileUpload(deps, input) {
|
|
9
|
+
const fs = await import('node:fs');
|
|
10
|
+
const path = await import('node:path');
|
|
11
|
+
const srcPath = input.file_path;
|
|
12
|
+
const fileName = input.file_name || path.basename(srcPath);
|
|
13
|
+
// 检查源文件是否存在
|
|
14
|
+
if (!fs.existsSync(srcPath)) {
|
|
15
|
+
throw new Error(`文件不存在: ${srcPath}`);
|
|
16
|
+
}
|
|
17
|
+
const stat = fs.statSync(srcPath);
|
|
18
|
+
if (!stat.isFile()) {
|
|
19
|
+
throw new Error(`路径不是文件: ${srcPath}`);
|
|
20
|
+
}
|
|
21
|
+
// 确保上传目录存在
|
|
22
|
+
fs.mkdirSync(deps.uploadDir, { recursive: true });
|
|
23
|
+
// 生成唯一文件名避免冲突
|
|
24
|
+
const timestamp = Date.now();
|
|
25
|
+
const uniqueName = `${timestamp}-${fileName}`;
|
|
26
|
+
const destPath = path.join(deps.uploadDir, uniqueName);
|
|
27
|
+
// 复制文件
|
|
28
|
+
fs.copyFileSync(srcPath, destPath);
|
|
29
|
+
const url = destPath; // 本地路径即 URL
|
|
30
|
+
deps.logger?.info(`[anya:pipeline] file.upload: ${fileName} (${stat.size} bytes) → ${destPath}`);
|
|
31
|
+
// 审计日志
|
|
32
|
+
insertAuditEvent(deps.db, {
|
|
33
|
+
event_type: 'file_upload',
|
|
34
|
+
actor: 'loid',
|
|
35
|
+
summary: `上传文件: ${fileName} (${stat.size} bytes)`,
|
|
36
|
+
detail: JSON.stringify({ src: srcPath, dest: destPath, size: stat.size }),
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
url,
|
|
40
|
+
file_name: fileName,
|
|
41
|
+
file_size: stat.size,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=file-upload.js.map
|