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,33 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
import { orgMembers } from './org.js';
|
|
4
|
+
// chats 表 — 群聊实体
|
|
5
|
+
export const chats = sqliteTable('chats', {
|
|
6
|
+
chat_id: text('chat_id').primaryKey(), // 飞书 oc_xxx
|
|
7
|
+
platform: text('platform').notNull().default('feishu'),
|
|
8
|
+
name: text('name'),
|
|
9
|
+
description: text('description'),
|
|
10
|
+
avatar: text('avatar'), // 群头像 URL
|
|
11
|
+
owner_id: text('owner_id'), // 群主 open_id
|
|
12
|
+
chat_mode: text('chat_mode'), // group / topic
|
|
13
|
+
chat_type: text('chat_type'), // private / public
|
|
14
|
+
chat_tag: text('chat_tag'), // inner / tenant / department / meeting
|
|
15
|
+
chat_status: text('chat_status').default('normal'), // normal / dissolved
|
|
16
|
+
external: integer('external').default(0), // 是否外部群 0/1
|
|
17
|
+
tenant_key: text('tenant_key'),
|
|
18
|
+
user_count: integer('user_count'),
|
|
19
|
+
bot_count: integer('bot_count'),
|
|
20
|
+
metadata: text('metadata'), // JSON 扩展
|
|
21
|
+
first_seen_at: text('first_seen_at').notNull().default(sql `(datetime('now'))`),
|
|
22
|
+
last_synced_at: text('last_synced_at'),
|
|
23
|
+
updated_at: text('updated_at').notNull().default(sql `(datetime('now'))`),
|
|
24
|
+
});
|
|
25
|
+
// chat_members 关联表 — 群 ↔ 人 多对多
|
|
26
|
+
export const chatMembers = sqliteTable('chat_members', {
|
|
27
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
28
|
+
chat_id: text('chat_id').notNull().references(() => chats.chat_id),
|
|
29
|
+
member_id: text('member_id').notNull().references(() => orgMembers.member_id),
|
|
30
|
+
role: text('role').default('member'), // owner / admin / member
|
|
31
|
+
synced_at: text('synced_at').notNull().default(sql `(datetime('now'))`),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=chats.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated 此模块已废弃,改为 Agent 自主判断/使用 memory 系统。
|
|
3
|
+
* 保留此文件仅为兼容历史数据,新代码请勿使用。
|
|
4
|
+
*/
|
|
5
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
6
|
+
import { sql } from 'drizzle-orm';
|
|
7
|
+
import { tasks } from './tasks.js';
|
|
8
|
+
export const commitments = sqliteTable('commitments', {
|
|
9
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
10
|
+
task_id: text('task_id').notNull().references(() => tasks.task_id),
|
|
11
|
+
promised_to: text('promised_to').notNull(),
|
|
12
|
+
promise: text('promise').notNull(),
|
|
13
|
+
deadline: text('deadline'),
|
|
14
|
+
status: text('status').notNull().default('active'),
|
|
15
|
+
break_reason: text('break_reason'),
|
|
16
|
+
promised_at: text('promised_at').notNull().default(sql `(datetime('now'))`),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=commitments.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const communicationEvents = sqliteTable('communication_events', {
|
|
4
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
5
|
+
source_type: text('source_type').notNull(),
|
|
6
|
+
source_ref: text('source_ref'),
|
|
7
|
+
intent_level: integer('intent_level').notNull(),
|
|
8
|
+
sender: text('sender'),
|
|
9
|
+
summary: text('summary').notNull(),
|
|
10
|
+
raw_content_path: text('raw_content_path'),
|
|
11
|
+
opportunity_id: text('opportunity_id'),
|
|
12
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=communication-events.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './tasks.js';
|
|
2
|
+
export * from './commitments.js';
|
|
3
|
+
export * from './opportunities.js';
|
|
4
|
+
export * from './audit-events.js';
|
|
5
|
+
export * from './communication-events.js';
|
|
6
|
+
export * from './message-log.js';
|
|
7
|
+
export * from './org.js';
|
|
8
|
+
export * from './chats.js';
|
|
9
|
+
export * from './trace-spans.js';
|
|
10
|
+
export * from './projects.js';
|
|
11
|
+
export * from './cc-sessions.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const messageLog = sqliteTable('message_log', {
|
|
4
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
5
|
+
direction: text('direction').notNull(), // 'inbound' | 'outbound'
|
|
6
|
+
source_type: text('source_type').notNull(), // 'feishu'
|
|
7
|
+
source_ref: text('source_ref'), // 飞书 message_id
|
|
8
|
+
sender: text('sender'),
|
|
9
|
+
receiver: text('receiver'),
|
|
10
|
+
chat_id: text('chat_id'), // 群聊 ID 或私聊对方 ID
|
|
11
|
+
chat_type: text('chat_type'), // 'group' | 'p2p'
|
|
12
|
+
content: text('content').notNull(),
|
|
13
|
+
message_type: text('message_type'), // 'text' | 'card' | 'clarification' | 'alert' | 'report' | 'task_done'
|
|
14
|
+
intent_level: integer('intent_level'),
|
|
15
|
+
related_task_id: text('related_task_id'),
|
|
16
|
+
metadata: text('metadata'), // JSON
|
|
17
|
+
trace_id: text('trace_id'),
|
|
18
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=message-log.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated 此模块已废弃,改为 Agent 自主判断/使用 memory 系统。
|
|
3
|
+
* 保留此文件仅为兼容历史数据,新代码请勿使用。
|
|
4
|
+
*/
|
|
5
|
+
import { sqliteTable, text, real } from 'drizzle-orm/sqlite-core';
|
|
6
|
+
import { sql } from 'drizzle-orm';
|
|
7
|
+
import { tasks } from './tasks.js';
|
|
8
|
+
export const opportunities = sqliteTable('opportunities', {
|
|
9
|
+
id: text('id').primaryKey(),
|
|
10
|
+
status: text('status').notNull().default('detected'),
|
|
11
|
+
source_ref: text('source_ref'),
|
|
12
|
+
summary: text('summary').notNull(),
|
|
13
|
+
// 评分
|
|
14
|
+
score_impact: real('score_impact'),
|
|
15
|
+
score_urgency: real('score_urgency'),
|
|
16
|
+
score_feasibility: real('score_feasibility'),
|
|
17
|
+
score_permission: real('score_permission'),
|
|
18
|
+
total_score: real('total_score'),
|
|
19
|
+
converted_task_id: text('converted_task_id').references(() => tasks.task_id),
|
|
20
|
+
detected_at: text('detected_at').notNull().default(sql `(datetime('now'))`),
|
|
21
|
+
claimed_at: text('claimed_at'),
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=opportunities.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const orgMembers = sqliteTable('org_members', {
|
|
4
|
+
member_id: text('member_id').primaryKey(),
|
|
5
|
+
name: text('name').notNull(),
|
|
6
|
+
role: text('role'),
|
|
7
|
+
team: text('team'),
|
|
8
|
+
timezone: text('timezone'),
|
|
9
|
+
profile_path: text('profile_path'),
|
|
10
|
+
response_pattern: text('response_pattern'),
|
|
11
|
+
platform: text('platform').default('feishu'),
|
|
12
|
+
union_id: text('union_id'),
|
|
13
|
+
user_id: text('user_id'), // 飞书租户内 ID
|
|
14
|
+
en_name: text('en_name'),
|
|
15
|
+
email: text('email'),
|
|
16
|
+
employee_no: text('employee_no'),
|
|
17
|
+
avatar_url: text('avatar_url'),
|
|
18
|
+
metadata: text('metadata'), // JSON 扩展
|
|
19
|
+
last_synced_at: text('last_synced_at'),
|
|
20
|
+
updated_at: text('updated_at').notNull().default(sql `(datetime('now'))`),
|
|
21
|
+
});
|
|
22
|
+
export const orgOwnership = sqliteTable('org_ownership', {
|
|
23
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
24
|
+
scope: text('scope').notNull(),
|
|
25
|
+
target: text('target').notNull(),
|
|
26
|
+
member_id: text('member_id').notNull().references(() => orgMembers.member_id),
|
|
27
|
+
role: text('role').notNull().default('owner'),
|
|
28
|
+
});
|
|
29
|
+
export const orgEscalationRules = sqliteTable('org_escalation_rules', {
|
|
30
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
31
|
+
scope: text('scope').notNull().default('global'),
|
|
32
|
+
after_minutes: integer('after_minutes').notNull(),
|
|
33
|
+
action: text('action').notNull(),
|
|
34
|
+
targets: text('targets').notNull(), // JSON 数组字符串
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=org.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const projects = sqliteTable('projects', {
|
|
4
|
+
project_id: text('project_id').primaryKey(),
|
|
5
|
+
name: text('name').notNull(),
|
|
6
|
+
description: text('description'),
|
|
7
|
+
platform: text('platform').default('github'), // github | gitlab | local
|
|
8
|
+
claude_md: text('claude_md'),
|
|
9
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
10
|
+
updated_at: text('updated_at').notNull().default(sql `(datetime('now'))`),
|
|
11
|
+
deleted_at: text('deleted_at'), // null = 活跃,有值 = 已软删除
|
|
12
|
+
});
|
|
13
|
+
// project_repos 关联表 — 项目 ↔ 仓库 一对多
|
|
14
|
+
export const projectRepos = sqliteTable('project_repos', {
|
|
15
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
16
|
+
project_id: text('project_id').notNull().references(() => projects.project_id),
|
|
17
|
+
name: text('name').notNull(), // 仓库名,也是子目录名
|
|
18
|
+
git_url: text('git_url'), // 远程仓库地址,用于自动 clone
|
|
19
|
+
repo_path: text('repo_path'), // 主仓库绝对路径
|
|
20
|
+
default_branch: text('default_branch').default('main'),
|
|
21
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const tasks = sqliteTable('tasks', {
|
|
4
|
+
task_id: text('task_id').primaryKey(),
|
|
5
|
+
title: text('title').notNull(),
|
|
6
|
+
status: text('status').notNull().default('NEW'),
|
|
7
|
+
// 来源
|
|
8
|
+
source_type: text('source_type').notNull(),
|
|
9
|
+
source_ref: text('source_ref'),
|
|
10
|
+
created_by: text('created_by'), // 任务创建者(人名或 'loid')
|
|
11
|
+
source_chat_id: text('source_chat_id'), // 触发任务的聊天 ID
|
|
12
|
+
// 需求定义
|
|
13
|
+
objective: text('objective'),
|
|
14
|
+
acceptance_criteria: text('acceptance_criteria'), // JSON 数组字符串
|
|
15
|
+
context: text('context'),
|
|
16
|
+
// 执行信息
|
|
17
|
+
project_id: text('project_id'),
|
|
18
|
+
assignee: text('assignee'),
|
|
19
|
+
branch: text('branch'),
|
|
20
|
+
pr_url: text('pr_url'),
|
|
21
|
+
// 重试与阻塞
|
|
22
|
+
retry_count: integer('retry_count').notNull().default(0),
|
|
23
|
+
max_retries: integer('max_retries').notNull().default(3),
|
|
24
|
+
blocked_reason: text('blocked_reason'),
|
|
25
|
+
blocked_since: text('blocked_since'),
|
|
26
|
+
// 执行指引
|
|
27
|
+
execution_guidance: text('execution_guidance'),
|
|
28
|
+
// CC 会话
|
|
29
|
+
cc_session_id: text('cc_session_id'),
|
|
30
|
+
// 文件路径
|
|
31
|
+
workspace_path: text('workspace_path'),
|
|
32
|
+
// 时间戳
|
|
33
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
34
|
+
updated_at: text('updated_at').notNull().default(sql `(datetime('now'))`),
|
|
35
|
+
});
|
|
36
|
+
export const taskClarifications = sqliteTable('task_clarifications', {
|
|
37
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
38
|
+
task_id: text('task_id').notNull().references(() => tasks.task_id),
|
|
39
|
+
question: text('question').notNull(),
|
|
40
|
+
answer: text('answer'),
|
|
41
|
+
asked_by: text('asked_by').notNull().default('loid'),
|
|
42
|
+
answered_by: text('answered_by'),
|
|
43
|
+
asked_at: text('asked_at').notNull().default(sql `(datetime('now'))`),
|
|
44
|
+
answered_at: text('answered_at'),
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=tasks.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { sqliteTable, text, integer, real } from 'drizzle-orm/sqlite-core';
|
|
2
|
+
import { sql } from 'drizzle-orm';
|
|
3
|
+
export const traceSpans = sqliteTable('trace_spans', {
|
|
4
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
5
|
+
trace_id: text('trace_id').notNull(),
|
|
6
|
+
span_id: text('span_id').notNull(),
|
|
7
|
+
parent_span_id: text('parent_span_id'),
|
|
8
|
+
operation: text('operation').notNull(),
|
|
9
|
+
status: text('status').notNull().default('in_progress'), // 'in_progress' | 'success' | 'error'
|
|
10
|
+
started_at: text('started_at').notNull(),
|
|
11
|
+
ended_at: text('ended_at'),
|
|
12
|
+
duration_ms: real('duration_ms'),
|
|
13
|
+
input: text('input'), // JSON
|
|
14
|
+
output: text('output'), // JSON
|
|
15
|
+
error: text('error'),
|
|
16
|
+
metadata: text('metadata'), // JSON
|
|
17
|
+
created_at: text('created_at').notNull().default(sql `(datetime('now'))`),
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=trace-spans.js.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
CREATE TABLE `audit_events` (
|
|
2
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
+
`event_type` text NOT NULL,
|
|
4
|
+
`actor` text NOT NULL,
|
|
5
|
+
`task_id` text,
|
|
6
|
+
`summary` text NOT NULL,
|
|
7
|
+
`detail` text,
|
|
8
|
+
`file_ref` text,
|
|
9
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
CREATE TABLE `commitments` (
|
|
13
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
14
|
+
`task_id` text NOT NULL,
|
|
15
|
+
`promised_to` text NOT NULL,
|
|
16
|
+
`promise` text NOT NULL,
|
|
17
|
+
`deadline` text,
|
|
18
|
+
`status` text DEFAULT 'active' NOT NULL,
|
|
19
|
+
`break_reason` text,
|
|
20
|
+
`promised_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
21
|
+
FOREIGN KEY (`task_id`) REFERENCES `tasks`(`task_id`) ON UPDATE no action ON DELETE no action
|
|
22
|
+
);
|
|
23
|
+
--> statement-breakpoint
|
|
24
|
+
CREATE TABLE `communication_events` (
|
|
25
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
26
|
+
`source_type` text NOT NULL,
|
|
27
|
+
`source_ref` text,
|
|
28
|
+
`intent_level` integer NOT NULL,
|
|
29
|
+
`sender` text,
|
|
30
|
+
`summary` text NOT NULL,
|
|
31
|
+
`raw_content_path` text,
|
|
32
|
+
`opportunity_id` text,
|
|
33
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
|
34
|
+
);
|
|
35
|
+
--> statement-breakpoint
|
|
36
|
+
CREATE TABLE `task_clarifications` (
|
|
37
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
38
|
+
`task_id` text NOT NULL,
|
|
39
|
+
`question` text NOT NULL,
|
|
40
|
+
`answer` text,
|
|
41
|
+
`asked_by` text DEFAULT 'loid' NOT NULL,
|
|
42
|
+
`answered_by` text,
|
|
43
|
+
`asked_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
44
|
+
`answered_at` text,
|
|
45
|
+
FOREIGN KEY (`task_id`) REFERENCES `tasks`(`task_id`) ON UPDATE no action ON DELETE no action
|
|
46
|
+
);
|
|
47
|
+
--> statement-breakpoint
|
|
48
|
+
CREATE TABLE `tasks` (
|
|
49
|
+
`task_id` text PRIMARY KEY NOT NULL,
|
|
50
|
+
`title` text NOT NULL,
|
|
51
|
+
`status` text DEFAULT 'NEW' NOT NULL,
|
|
52
|
+
`source_type` text NOT NULL,
|
|
53
|
+
`source_ref` text,
|
|
54
|
+
`objective` text,
|
|
55
|
+
`acceptance_criteria` text,
|
|
56
|
+
`context` text,
|
|
57
|
+
`project_id` text,
|
|
58
|
+
`assignee` text,
|
|
59
|
+
`branch` text,
|
|
60
|
+
`pr_url` text,
|
|
61
|
+
`retry_count` integer DEFAULT 0 NOT NULL,
|
|
62
|
+
`max_retries` integer DEFAULT 3 NOT NULL,
|
|
63
|
+
`blocked_reason` text,
|
|
64
|
+
`blocked_since` text,
|
|
65
|
+
`execution_guidance` text,
|
|
66
|
+
`workspace_path` text,
|
|
67
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
68
|
+
`updated_at` text DEFAULT (datetime('now')) NOT NULL
|
|
69
|
+
);
|
|
70
|
+
--> statement-breakpoint
|
|
71
|
+
CREATE TABLE `opportunities` (
|
|
72
|
+
`id` text PRIMARY KEY NOT NULL,
|
|
73
|
+
`status` text DEFAULT 'detected' NOT NULL,
|
|
74
|
+
`source_ref` text,
|
|
75
|
+
`summary` text NOT NULL,
|
|
76
|
+
`score_impact` real,
|
|
77
|
+
`score_urgency` real,
|
|
78
|
+
`score_feasibility` real,
|
|
79
|
+
`score_permission` real,
|
|
80
|
+
`total_score` real,
|
|
81
|
+
`converted_task_id` text,
|
|
82
|
+
`detected_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
83
|
+
`claimed_at` text,
|
|
84
|
+
FOREIGN KEY (`converted_task_id`) REFERENCES `tasks`(`task_id`) ON UPDATE no action ON DELETE no action
|
|
85
|
+
);
|
|
86
|
+
--> statement-breakpoint
|
|
87
|
+
CREATE TABLE `message_log` (
|
|
88
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
89
|
+
`direction` text NOT NULL,
|
|
90
|
+
`source_type` text NOT NULL,
|
|
91
|
+
`source_ref` text,
|
|
92
|
+
`sender` text,
|
|
93
|
+
`receiver` text,
|
|
94
|
+
`chat_id` text,
|
|
95
|
+
`chat_type` text,
|
|
96
|
+
`content` text NOT NULL,
|
|
97
|
+
`message_type` text,
|
|
98
|
+
`intent_level` integer,
|
|
99
|
+
`related_task_id` text,
|
|
100
|
+
`metadata` text,
|
|
101
|
+
`trace_id` text,
|
|
102
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
|
103
|
+
);
|
|
104
|
+
--> statement-breakpoint
|
|
105
|
+
CREATE TABLE `org_escalation_rules` (
|
|
106
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
107
|
+
`scope` text DEFAULT 'global' NOT NULL,
|
|
108
|
+
`after_minutes` integer NOT NULL,
|
|
109
|
+
`action` text NOT NULL,
|
|
110
|
+
`targets` text NOT NULL
|
|
111
|
+
);
|
|
112
|
+
--> statement-breakpoint
|
|
113
|
+
CREATE TABLE `org_members` (
|
|
114
|
+
`member_id` text PRIMARY KEY NOT NULL,
|
|
115
|
+
`name` text NOT NULL,
|
|
116
|
+
`role` text,
|
|
117
|
+
`team` text,
|
|
118
|
+
`timezone` text,
|
|
119
|
+
`profile_path` text,
|
|
120
|
+
`response_pattern` text,
|
|
121
|
+
`updated_at` text DEFAULT (datetime('now')) NOT NULL
|
|
122
|
+
);
|
|
123
|
+
--> statement-breakpoint
|
|
124
|
+
CREATE TABLE `org_ownership` (
|
|
125
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
126
|
+
`scope` text NOT NULL,
|
|
127
|
+
`target` text NOT NULL,
|
|
128
|
+
`member_id` text NOT NULL,
|
|
129
|
+
`role` text DEFAULT 'owner' NOT NULL,
|
|
130
|
+
FOREIGN KEY (`member_id`) REFERENCES `org_members`(`member_id`) ON UPDATE no action ON DELETE no action
|
|
131
|
+
);
|
|
132
|
+
--> statement-breakpoint
|
|
133
|
+
CREATE TABLE `trace_spans` (
|
|
134
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
135
|
+
`trace_id` text NOT NULL,
|
|
136
|
+
`span_id` text NOT NULL,
|
|
137
|
+
`parent_span_id` text,
|
|
138
|
+
`operation` text NOT NULL,
|
|
139
|
+
`status` text DEFAULT 'in_progress' NOT NULL,
|
|
140
|
+
`started_at` text NOT NULL,
|
|
141
|
+
`ended_at` text,
|
|
142
|
+
`duration_ms` real,
|
|
143
|
+
`input` text,
|
|
144
|
+
`output` text,
|
|
145
|
+
`error` text,
|
|
146
|
+
`metadata` text,
|
|
147
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL
|
|
148
|
+
);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
CREATE TABLE `chat_members` (
|
|
2
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
+
`chat_id` text NOT NULL,
|
|
4
|
+
`member_id` text NOT NULL,
|
|
5
|
+
`role` text DEFAULT 'member',
|
|
6
|
+
`synced_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
7
|
+
FOREIGN KEY (`chat_id`) REFERENCES `chats`(`chat_id`) ON UPDATE no action ON DELETE no action,
|
|
8
|
+
FOREIGN KEY (`member_id`) REFERENCES `org_members`(`member_id`) ON UPDATE no action ON DELETE no action
|
|
9
|
+
);
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
CREATE TABLE `chats` (
|
|
12
|
+
`chat_id` text PRIMARY KEY NOT NULL,
|
|
13
|
+
`platform` text DEFAULT 'feishu' NOT NULL,
|
|
14
|
+
`name` text,
|
|
15
|
+
`description` text,
|
|
16
|
+
`avatar` text,
|
|
17
|
+
`owner_id` text,
|
|
18
|
+
`chat_mode` text,
|
|
19
|
+
`chat_type` text,
|
|
20
|
+
`chat_tag` text,
|
|
21
|
+
`chat_status` text DEFAULT 'normal',
|
|
22
|
+
`external` integer DEFAULT 0,
|
|
23
|
+
`tenant_key` text,
|
|
24
|
+
`user_count` integer,
|
|
25
|
+
`bot_count` integer,
|
|
26
|
+
`metadata` text,
|
|
27
|
+
`first_seen_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
28
|
+
`last_synced_at` text,
|
|
29
|
+
`updated_at` text DEFAULT (datetime('now')) NOT NULL
|
|
30
|
+
);
|
|
31
|
+
--> statement-breakpoint
|
|
32
|
+
ALTER TABLE `tasks` ADD `created_by` text;--> statement-breakpoint
|
|
33
|
+
ALTER TABLE `tasks` ADD `source_chat_id` text;--> statement-breakpoint
|
|
34
|
+
ALTER TABLE `org_members` ADD `platform` text DEFAULT 'feishu';--> statement-breakpoint
|
|
35
|
+
ALTER TABLE `org_members` ADD `union_id` text;--> statement-breakpoint
|
|
36
|
+
ALTER TABLE `org_members` ADD `user_id` text;--> statement-breakpoint
|
|
37
|
+
ALTER TABLE `org_members` ADD `en_name` text;--> statement-breakpoint
|
|
38
|
+
ALTER TABLE `org_members` ADD `email` text;--> statement-breakpoint
|
|
39
|
+
ALTER TABLE `org_members` ADD `employee_no` text;--> statement-breakpoint
|
|
40
|
+
ALTER TABLE `org_members` ADD `avatar_url` text;--> statement-breakpoint
|
|
41
|
+
ALTER TABLE `org_members` ADD `metadata` text;--> statement-breakpoint
|
|
42
|
+
ALTER TABLE `org_members` ADD `last_synced_at` text;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
CREATE TABLE `project_repos` (
|
|
2
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
+
`project_id` text NOT NULL,
|
|
4
|
+
`name` text NOT NULL,
|
|
5
|
+
`git_url` text,
|
|
6
|
+
`repo_path` text,
|
|
7
|
+
`default_branch` text DEFAULT 'main',
|
|
8
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
9
|
+
FOREIGN KEY (`project_id`) REFERENCES `projects`(`project_id`) ON UPDATE no action ON DELETE no action
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
CREATE TABLE `projects` (
|
|
13
|
+
`project_id` text PRIMARY KEY NOT NULL,
|
|
14
|
+
`name` text NOT NULL,
|
|
15
|
+
`description` text,
|
|
16
|
+
`platform` text DEFAULT 'github',
|
|
17
|
+
`claude_md` text,
|
|
18
|
+
`created_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
19
|
+
`updated_at` text DEFAULT (datetime('now')) NOT NULL
|
|
20
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE `cc_sessions` (
|
|
2
|
+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
3
|
+
`session_id` text NOT NULL,
|
|
4
|
+
`role` text NOT NULL,
|
|
5
|
+
`instance_id` text,
|
|
6
|
+
`task_id` text,
|
|
7
|
+
`chat_id` text,
|
|
8
|
+
`project_path` text,
|
|
9
|
+
`started_at` text DEFAULT (datetime('now')) NOT NULL,
|
|
10
|
+
`ended_at` text
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
ALTER TABLE `tasks` ADD `cc_session_id` text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE `projects` ADD `deleted_at` text;
|