dsh-annual-activity 1.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/LICENSE +21 -0
- package/README.md +177 -0
- package/cordis.patch.yml +15 -0
- package/lib/client.js +836 -0
- package/lib/index.d.ts +91 -0
- package/lib/index.js +889 -0
- package/package.json +59 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全年活跃记录 (dsh-annual-activity) — host half type declarations.
|
|
3
|
+
*
|
|
4
|
+
* 纯本地的活跃度统计引擎:扫描 $DSH_HOME/sessions 下的历史会话日志,按本地日历日
|
|
5
|
+
* 聚合活跃天 / 轮次 / 工具调用 / Token,并通过 webServer 暴露只读 HTTP 路由。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** 一天的活跃记录(`level` 由「轮次」主口径决定,0-4)。 */
|
|
9
|
+
export interface ActivityDay {
|
|
10
|
+
/** 本地日历日 'YYYY-MM-DD' */
|
|
11
|
+
day: string
|
|
12
|
+
/** 当天有活动的会话数(去重) */
|
|
13
|
+
activeSessions: number
|
|
14
|
+
turns: number
|
|
15
|
+
steps: number
|
|
16
|
+
userMessages: number
|
|
17
|
+
toolCalls: number
|
|
18
|
+
inputTokens: number
|
|
19
|
+
outputTokens: number
|
|
20
|
+
/** 输入 + 输出(缓存读取不计入,另见 tooltip) */
|
|
21
|
+
tokens: number
|
|
22
|
+
level: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** 活跃等级定义(Host 下发,保证色块深度与口径一致)。 */
|
|
26
|
+
export interface ActivityLevel {
|
|
27
|
+
level: number
|
|
28
|
+
label: string
|
|
29
|
+
min: number
|
|
30
|
+
/** null = 无上限 */
|
|
31
|
+
max: number | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** 某年的派生统计。 */
|
|
35
|
+
export interface ActivityYearStats {
|
|
36
|
+
year: number
|
|
37
|
+
activeDays: number
|
|
38
|
+
/** 活跃率分母:当前年 = 已过天数,历史年 = 全年天数 */
|
|
39
|
+
totalDays: number
|
|
40
|
+
rate: number
|
|
41
|
+
/** 当前周连登(周一为一周起点,上周仍有记录则视为未断) */
|
|
42
|
+
weekStreak: number
|
|
43
|
+
longestWeekStreak: number
|
|
44
|
+
longestDayStreak: number
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 会话摘要(用于面板补充信息,按最近活跃倒序,最多 400 条)。 */
|
|
48
|
+
export interface ActivitySessionSummary {
|
|
49
|
+
id: string
|
|
50
|
+
title: string
|
|
51
|
+
project: string
|
|
52
|
+
createdAt: number
|
|
53
|
+
lastActive: number
|
|
54
|
+
turns: number
|
|
55
|
+
tokens: number
|
|
56
|
+
activeDays: number
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** `GET /activity/pull` 的响应体。 */
|
|
60
|
+
export interface ActivityPayload {
|
|
61
|
+
version: string
|
|
62
|
+
seq: number
|
|
63
|
+
today: string
|
|
64
|
+
currentYear: number
|
|
65
|
+
years: number[]
|
|
66
|
+
yearStats: Record<string, ActivityYearStats>
|
|
67
|
+
/** 本次响应选中的年份 */
|
|
68
|
+
year: number
|
|
69
|
+
/** 选中年份的日明细(有界) */
|
|
70
|
+
days: ActivityDay[]
|
|
71
|
+
stats: ActivityYearStats | null
|
|
72
|
+
levels: ActivityLevel[]
|
|
73
|
+
sessions: ActivitySessionSummary[]
|
|
74
|
+
sessionCount: number
|
|
75
|
+
projects: number
|
|
76
|
+
totalTurns: number
|
|
77
|
+
totalTokens: number
|
|
78
|
+
scannedAt: number
|
|
79
|
+
scanMs: number
|
|
80
|
+
scanErrors: number
|
|
81
|
+
timeZone: string
|
|
82
|
+
scanning: boolean
|
|
83
|
+
lastError: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 插件名(bundle id)。 */
|
|
87
|
+
export declare const name: 'dsh-annual-activity'
|
|
88
|
+
/** 依赖服务:webServer 注册路由,timer 提供周期任务。 */
|
|
89
|
+
export declare const inject: readonly ['timer', 'webServer']
|
|
90
|
+
/** Cordis 插件入口。 */
|
|
91
|
+
export declare function apply(ctx: unknown): void
|