@koinzhang/paseo-plugin-activity 0.6.0 → 0.7.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/CHANGELOG.md +35 -1
- package/README.md +14 -7
- package/client/activity-heatmap.tsx +115 -74
- package/client/agent-creations.tsx +97 -88
- package/client/attention-pill.tsx +16 -5
- package/client/attention-popover.tsx +19 -23
- package/client/design-tokens.test.ts +39 -0
- package/client/design-tokens.ts +168 -0
- package/client/formatted-time.tsx +4 -4
- package/client/global-surface.tsx +236 -268
- package/client/header-button.ts +136 -0
- package/client/hourly-activity-timeline.tsx +136 -103
- package/client/panel-visibility.test.ts +25 -0
- package/client/panel-visibility.ts +45 -0
- package/client/panel.tsx +83 -108
- package/client/provider-dropdown.tsx +131 -0
- package/client/provider-filter.test.ts +17 -13
- package/client/provider-filter.ts +5 -7
- package/client/rank-color.ts +3 -3
- package/client/ranking-bars.tsx +291 -0
- package/client/ui.tsx +339 -0
- package/client/usage-popover.tsx +62 -134
- package/client/usage-stats.tsx +29 -11
- package/client/use-agent-turn-end.ts +2 -1
- package/client/use-app-language.ts +17 -0
- package/client/web.ts +73 -18
- package/client/workspace/agent-row.tsx +18 -25
- package/client/workspace/agents-section.tsx +23 -20
- package/client/workspace/constants.ts +6 -6
- package/client/workspace/display-menu.tsx +5 -4
- package/client/workspace/filters.test.ts +1 -1
- package/client/workspace/filters.ts +4 -2
- package/client/workspace/panel.tsx +89 -103
- package/client/workspace/rank-section.tsx +36 -62
- package/client/workspace/terminals-section.tsx +13 -9
- package/index.client.tsx +40 -20
- package/index.server.ts +53 -51
- package/package.json +2 -2
- package/paseo-plugin.json +2 -1
- package/server/agents.ts +20 -2
- package/server/background-sync.ts +34 -4
- package/server/handlers-query.test.ts +27 -1
- package/server/handlers.ts +75 -31
- package/server/ingest.test.ts +8 -0
- package/server/messages.test.ts +96 -1
- package/server/prompt-dedupe.ts +52 -0
- package/server/rpc-cache.test.ts +74 -0
- package/server/rpc-cache.ts +48 -0
- package/server/store.test.ts +122 -0
- package/server/store.ts +313 -19
- package/server/ttl-cache.ts +3 -0
- package/shared/activity.test.ts +36 -0
- package/shared/activity.ts +37 -0
- package/shared/classify.test.ts +1 -10
- package/shared/classify.ts +3 -10
- package/shared/format.ts +10 -7
- package/shared/i18n.test.ts +34 -0
- package/shared/i18n.ts +363 -0
- package/shared/insights.test.ts +120 -81
- package/shared/insights.ts +124 -63
- package/shared/usage.test.ts +121 -0
- package/shared/usage.ts +191 -2
package/shared/activity.ts
CHANGED
|
@@ -32,6 +32,26 @@ function addDays(date: Date, days: number): Date {
|
|
|
32
32
|
|
|
33
33
|
export type HeatmapMode = "daily" | "weekly" | "cumulative";
|
|
34
34
|
|
|
35
|
+
/** Chart metric switch (070); `sessions` = agent creations, `prompts` = user messages. */
|
|
36
|
+
export type ActivityMetric = "sessions" | "prompts" | "skills" | "mcp";
|
|
37
|
+
|
|
38
|
+
export const ACTIVITY_METRICS: readonly ActivityMetric[] = ["sessions", "prompts", "skills", "mcp"];
|
|
39
|
+
|
|
40
|
+
export function metricValue(
|
|
41
|
+
value: { agents: number; messages: number; skills: number; mcp: number },
|
|
42
|
+
metric: ActivityMetric,
|
|
43
|
+
): number {
|
|
44
|
+
if (metric === "sessions") return value.agents;
|
|
45
|
+
if (metric === "prompts") return value.messages;
|
|
46
|
+
return metric === "skills" ? value.skills : value.mcp;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Next / previous metric in `ACTIVITY_METRICS`, wrapping around. */
|
|
50
|
+
export function stepMetric(metric: ActivityMetric, delta: number): ActivityMetric {
|
|
51
|
+
const count = ACTIVITY_METRICS.length;
|
|
52
|
+
return ACTIVITY_METRICS[(ACTIVITY_METRICS.indexOf(metric) + delta + count * 2) % count] ?? "sessions";
|
|
53
|
+
}
|
|
54
|
+
|
|
35
55
|
export function buildActivityCalendar(days: readonly ActivityDay[], mode: HeatmapMode, _from?: string, today = new Date(), locale = "en") {
|
|
36
56
|
const end = startOfLocalDay(today);
|
|
37
57
|
// 52 natural weeks (Sunday-start) ending with the week containing today (058):
|
|
@@ -236,6 +256,23 @@ export function buildAgentCreationBuckets(
|
|
|
236
256
|
return buckets;
|
|
237
257
|
}
|
|
238
258
|
|
|
259
|
+
/**
|
|
260
|
+
* One bucket per local day over the same window as `buildAgentCreationBuckets`,
|
|
261
|
+
* valued by `metric` from `usage.activity-by-day` (070). No provider slices:
|
|
262
|
+
* only session creations carry a per-provider breakdown.
|
|
263
|
+
*/
|
|
264
|
+
export function buildDailyMetricBuckets(
|
|
265
|
+
days: readonly ActivityDay[],
|
|
266
|
+
metric: ActivityMetric,
|
|
267
|
+
options: { from: string; today?: Date },
|
|
268
|
+
): CreationBucket[] {
|
|
269
|
+
const byDay = new Map(days.map((day) => [day.date, metricValue(day, metric)]));
|
|
270
|
+
return buildAgentCreationBuckets([], options).map((bucket) => ({
|
|
271
|
+
...bucket,
|
|
272
|
+
count: byDay.get(bucket.key) ?? 0,
|
|
273
|
+
}));
|
|
274
|
+
}
|
|
275
|
+
|
|
239
276
|
/**
|
|
240
277
|
* Providers across the whole window, ranked by total creations (051). Drives
|
|
241
278
|
* the stable stack order and colour assignment; tooltip rows use
|
package/shared/classify.test.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
classifyToolCall,
|
|
5
5
|
matchSkillFile,
|
|
6
6
|
normalizeProvider,
|
|
7
|
-
brandProviderId,
|
|
8
7
|
} from "./classify.ts";
|
|
9
8
|
|
|
10
9
|
describe("normalizeProvider", () => {
|
|
@@ -13,20 +12,12 @@ describe("normalizeProvider", () => {
|
|
|
13
12
|
assert.equal(normalizeProvider("opencode"), "opencode");
|
|
14
13
|
assert.equal(normalizeProvider("codex"), "codex");
|
|
15
14
|
assert.equal(normalizeProvider("pi"), "pi");
|
|
16
|
-
assert.equal(normalizeProvider("omp"), "
|
|
15
|
+
assert.equal(normalizeProvider("omp"), "omp");
|
|
17
16
|
assert.equal(normalizeProvider("cursor"), "cursor");
|
|
18
17
|
assert.equal(normalizeProvider("codebuddy-code"), "codebuddy");
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
20
|
|
|
22
|
-
describe("brandProviderId", () => {
|
|
23
|
-
it("keeps omp distinct from pi for chart colour", () => {
|
|
24
|
-
assert.equal(brandProviderId("omp"), "omp");
|
|
25
|
-
assert.equal(brandProviderId("pi"), "pi");
|
|
26
|
-
assert.equal(brandProviderId("claude/opus"), "claude");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
21
|
describe("matchSkillFile", () => {
|
|
31
22
|
it("extracts skill name from common agent config roots", () => {
|
|
32
23
|
assert.equal(
|
package/shared/classify.ts
CHANGED
|
@@ -118,21 +118,14 @@ export function normalizeProvider(provider: string): string {
|
|
|
118
118
|
if (head === "claude" || head.startsWith("claude")) return "claude";
|
|
119
119
|
if (head === "opencode") return "opencode";
|
|
120
120
|
if (head === "codex") return "codex";
|
|
121
|
-
if (head === "pi"
|
|
121
|
+
if (head === "pi") return "pi";
|
|
122
|
+
// Oh My Pi is its own Paseo provider (manifest id `omp`), not a Pi alias (071).
|
|
123
|
+
if (head === "omp") return "omp";
|
|
122
124
|
if (head === "cursor") return "cursor";
|
|
123
125
|
if (head === "codebuddy" || head === "codebuddy-code") return "codebuddy";
|
|
124
126
|
return head;
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
/**
|
|
128
|
-
* Chart / brand colour identity. Same as `normalizeProvider`, except Oh My Pi
|
|
129
|
-
* (`omp`) stays distinct from Pi so the creations histogram can colour them apart.
|
|
130
|
-
*/
|
|
131
|
-
export function brandProviderId(provider: string): string {
|
|
132
|
-
const head = (provider.split("/")[0] ?? provider).toLowerCase();
|
|
133
|
-
if (head === "omp") return "omp";
|
|
134
|
-
return normalizeProvider(provider);
|
|
135
|
-
}
|
|
136
129
|
|
|
137
130
|
function expandHome(path: string, homeDir?: string): string {
|
|
138
131
|
if (homeDir && path.startsWith("~/")) {
|
package/shared/format.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { messagesFor } from "./i18n.ts";
|
|
2
|
+
|
|
1
3
|
/** Format stored ISO timestamps for UI / export in the local timezone + locale. */
|
|
2
4
|
export function formatLocalDateTime(
|
|
3
5
|
iso: string | null | undefined,
|
|
@@ -61,14 +63,15 @@ export function formatCount(value: number): string {
|
|
|
61
63
|
return String(value);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
/** Compact
|
|
65
|
-
export function formatDuration(ms: number): string {
|
|
66
|
+
/** Compact duration for agent lifetimes (049); units follow the app language (066). */
|
|
67
|
+
export function formatDuration(ms: number, locale = "en"): string {
|
|
66
68
|
if (!Number.isFinite(ms) || ms < 0) return "—";
|
|
67
|
-
|
|
68
|
-
if (ms <
|
|
69
|
+
const m = messagesFor(locale).duration;
|
|
70
|
+
if (ms < MINUTE_MS) return m.underMinute;
|
|
71
|
+
if (ms < HOUR_MS) return m.minutes(Math.floor(ms / MINUTE_MS));
|
|
69
72
|
const hours = ms / HOUR_MS;
|
|
70
|
-
if (hours < 48) return
|
|
73
|
+
if (hours < 48) return m.hours(Number(hours.toFixed(1)));
|
|
71
74
|
const days = ms / DAY_MS;
|
|
72
|
-
if (days < 60) return
|
|
73
|
-
return
|
|
75
|
+
if (days < 60) return m.days(Number(days.toFixed(1)));
|
|
76
|
+
return m.months(Number((days / 30.44).toFixed(1)));
|
|
74
77
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import test from "node:test";
|
|
3
|
+
import { formatDuration } from "./format.ts";
|
|
4
|
+
import { messagesFor, resolveAppLanguage } from "./i18n.ts";
|
|
5
|
+
|
|
6
|
+
test("resolveAppLanguage honors an explicit Paseo setting", () => {
|
|
7
|
+
assert.equal(resolveAppLanguage("zh-CN", ["en-US"]), "zh-CN");
|
|
8
|
+
assert.equal(resolveAppLanguage("ja", ["zh-CN"]), "ja");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test("resolveAppLanguage maps system to the OS preference", () => {
|
|
12
|
+
assert.equal(resolveAppLanguage("system", ["zh-TW", "en"]), "zh-CN");
|
|
13
|
+
assert.equal(resolveAppLanguage("system", ["pt-PT"]), "pt-BR");
|
|
14
|
+
assert.equal(resolveAppLanguage("system", ["de-DE", "ko-KR"]), "ko");
|
|
15
|
+
assert.equal(resolveAppLanguage("system", ["de-DE"]), "en");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("resolveAppLanguage treats missing or unknown settings like system", () => {
|
|
19
|
+
assert.equal(resolveAppLanguage(undefined, []), "en");
|
|
20
|
+
assert.equal(resolveAppLanguage("klingon", ["zh-CN"]), "zh-CN");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("messagesFor returns zh-CN copy and falls back to English", () => {
|
|
24
|
+
assert.equal(messagesFor("zh-CN").common.retry, "重试");
|
|
25
|
+
assert.equal(messagesFor("zh-CN").common.lastUsed("3 分钟前"), "最近 3 分钟前");
|
|
26
|
+
assert.equal(messagesFor("fr").common.retry, messagesFor("en").common.retry);
|
|
27
|
+
assert.equal(messagesFor("en").workspace.state.subagents(1), "1 subagent");
|
|
28
|
+
assert.equal(messagesFor("en").workspace.state.subagents(2), "2 subagents");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("formatDuration uses the locale's units", () => {
|
|
32
|
+
assert.equal(formatDuration(5 * 60_000, "en"), "5 min");
|
|
33
|
+
assert.equal(formatDuration(5 * 60_000, "zh-CN"), "5 分钟");
|
|
34
|
+
});
|
package/shared/i18n.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activity UI copy (066). The host SDK does not expose the app language; the
|
|
3
|
+
* client reads the Paseo `language` setting (see `client/web.ts`) and resolves
|
|
4
|
+
* it here. Catalogs are factories so counts format with the same locale.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Languages the Paseo app offers in Settings → Language (besides `system`). */
|
|
8
|
+
export const APP_LANGUAGES = ["ar", "en", "es", "fr", "ja", "ko", "pt-BR", "ru", "zh-CN"] as const;
|
|
9
|
+
export type AppLanguage = (typeof APP_LANGUAGES)[number];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the app `language` setting to a supported tag: an explicit choice wins;
|
|
13
|
+
* `system` / unknown walks the OS preferences by exact tag, then base language.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveAppLanguage(
|
|
16
|
+
setting: string | null | undefined,
|
|
17
|
+
systemLanguages: readonly string[] = [],
|
|
18
|
+
): AppLanguage {
|
|
19
|
+
const explicit = matchLanguage(setting ?? "");
|
|
20
|
+
if (explicit && setting !== "system") return explicit;
|
|
21
|
+
for (const candidate of systemLanguages) {
|
|
22
|
+
const match = matchLanguage(candidate);
|
|
23
|
+
if (match) return match;
|
|
24
|
+
}
|
|
25
|
+
return "en";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function matchLanguage(tag: string): AppLanguage | null {
|
|
29
|
+
const lower = tag.trim().toLowerCase();
|
|
30
|
+
if (!lower || lower === "system") return null;
|
|
31
|
+
const exact = APP_LANGUAGES.find((lang) => lang.toLowerCase() === lower);
|
|
32
|
+
if (exact) return exact;
|
|
33
|
+
const base = lower.split(/[-_]/)[0];
|
|
34
|
+
if (base === "zh") return "zh-CN";
|
|
35
|
+
if (base === "pt") return "pt-BR";
|
|
36
|
+
return APP_LANGUAGES.find((lang) => lang.toLowerCase() === base) ?? null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
type Formatters = { num: (value: number) => string };
|
|
40
|
+
|
|
41
|
+
function en({ num }: Formatters) {
|
|
42
|
+
const count = (value: number, one: string, many: string) =>
|
|
43
|
+
`${num(value)} ${value === 1 ? one : many}`;
|
|
44
|
+
return {
|
|
45
|
+
common: {
|
|
46
|
+
activity: "Activity",
|
|
47
|
+
skills: "Skills",
|
|
48
|
+
mcp: "MCP",
|
|
49
|
+
agents: "Agents",
|
|
50
|
+
sessions: "Sessions",
|
|
51
|
+
prompts: "Prompts",
|
|
52
|
+
loading: "Loading…",
|
|
53
|
+
retry: "Retry",
|
|
54
|
+
loadFailed: "Couldn't load activity",
|
|
55
|
+
today: "Today",
|
|
56
|
+
now: "Now",
|
|
57
|
+
noSkillOrMcp: "No skill or MCP calls yet",
|
|
58
|
+
lastUsed: (time: string) => `Last ${time}`,
|
|
59
|
+
failed: (value: number) => `${num(value)} failed`,
|
|
60
|
+
openConversation: (label: string) => `Open conversation ${label}`,
|
|
61
|
+
openSkillFile: (name: string) => `Open ${name} SKILL.md`,
|
|
62
|
+
openSkillInPanel: "Open SKILL.md in panel",
|
|
63
|
+
showSkills: "Show skills",
|
|
64
|
+
showMcp: "Show MCP",
|
|
65
|
+
agentOnly: "Activity is only available for an agent",
|
|
66
|
+
},
|
|
67
|
+
units: {
|
|
68
|
+
agents: (value: number) => count(value, "agent", "agents"),
|
|
69
|
+
sessions: (value: number) => count(value, "session", "sessions"),
|
|
70
|
+
prompts: (value: number) => count(value, "prompt", "prompts"),
|
|
71
|
+
skills: (value: number) => count(value, "skill", "skills"),
|
|
72
|
+
mcp: (value: number) => `${num(value)} MCP`,
|
|
73
|
+
calls: (value: number) => count(value, "call", "calls"),
|
|
74
|
+
days: (value: number) => count(value, "day", "days"),
|
|
75
|
+
},
|
|
76
|
+
duration: {
|
|
77
|
+
underMinute: "<1 min",
|
|
78
|
+
minutes: (value: number) => `${num(value)} min`,
|
|
79
|
+
hours: (value: number) => `${num(value)} h`,
|
|
80
|
+
days: (value: number) => `${num(value)} days`,
|
|
81
|
+
months: (value: number) => `${num(value)} months`,
|
|
82
|
+
},
|
|
83
|
+
kpi: {
|
|
84
|
+
sessions: "Sessions",
|
|
85
|
+
prompts: "Prompts",
|
|
86
|
+
topProvider: "Top provider",
|
|
87
|
+
topModel: "Top model",
|
|
88
|
+
previous7Days: "vs prev. 7d",
|
|
89
|
+
previous7DaysBare: "prev. 7d",
|
|
90
|
+
skillCalls: "Skill calls",
|
|
91
|
+
mcpCalls: "MCP calls",
|
|
92
|
+
shellCalls: "Shell calls",
|
|
93
|
+
fileReads: "File reads",
|
|
94
|
+
fileWrites: "File writes",
|
|
95
|
+
toolsExplored: "Tools explored",
|
|
96
|
+
},
|
|
97
|
+
insights: {
|
|
98
|
+
title: "Activity insights",
|
|
99
|
+
activeDays: "Active days",
|
|
100
|
+
busiestDay: "Busiest day",
|
|
101
|
+
workspaces: "Workspaces",
|
|
102
|
+
codingVsChat: "Coding vs chat",
|
|
103
|
+
longestStreak: "Longest streak",
|
|
104
|
+
peakWeekday: "Peak weekday",
|
|
105
|
+
multiTurnSessions: "Multi-turn sessions",
|
|
106
|
+
avgSessionDuration: "Avg session duration",
|
|
107
|
+
codingShare: (pct: number) => `${num(pct)}% coding`,
|
|
108
|
+
},
|
|
109
|
+
global: {
|
|
110
|
+
allProviders: "All",
|
|
111
|
+
providerLabel: "Provider",
|
|
112
|
+
selectProvider: "Select provider",
|
|
113
|
+
closeProviderMenu: "Close provider menu",
|
|
114
|
+
metrics: { sessions: "Sessions", prompts: "Prompts", skills: "Skill calls", mcp: "MCP calls" },
|
|
115
|
+
previousMetric: "Previous metric",
|
|
116
|
+
nextMetric: "Next metric",
|
|
117
|
+
providerRanking: { title: "Providers", empty: "No provider activity yet" },
|
|
118
|
+
projectRanking: { title: "Projects", empty: "No project activity yet", other: "Other" },
|
|
119
|
+
ranking: { showMore: (value: number) => `Show ${num(value)} more`, showLess: "Show less" },
|
|
120
|
+
rankTitle: { skills: "Most used skills", mcp: "Most used MCP", models: "Most used models" },
|
|
121
|
+
rankEmpty: { skills: "No skills yet", mcp: "No MCP yet", models: "No models yet" },
|
|
122
|
+
rankShow: {
|
|
123
|
+
skills: "Show most used skills",
|
|
124
|
+
mcp: "Show most used MCP",
|
|
125
|
+
models: "Show most used models",
|
|
126
|
+
},
|
|
127
|
+
emptyTitle: "No usage yet",
|
|
128
|
+
emptyHint: "Sessions, prompts, skill and MCP calls will show up here",
|
|
129
|
+
},
|
|
130
|
+
heatmap: {
|
|
131
|
+
title: "Activity Calendar",
|
|
132
|
+
highlightMonth: (month: string) => `Highlight ${month}`,
|
|
133
|
+
weekContaining: (date: string) => `Week containing ${date}`,
|
|
134
|
+
through: (date: string) => `Through ${date}`,
|
|
135
|
+
},
|
|
136
|
+
creations: {
|
|
137
|
+
title: "Daily Activity",
|
|
138
|
+
empty: (days: number) => `No activity in the last ${num(days)} days`,
|
|
139
|
+
},
|
|
140
|
+
timeline: {
|
|
141
|
+
title: "Hourly Activity",
|
|
142
|
+
empty: "No activity yet",
|
|
143
|
+
},
|
|
144
|
+
workspace: {
|
|
145
|
+
empty: "No activity in this workspace yet",
|
|
146
|
+
searchPlaceholder: "Search agents",
|
|
147
|
+
searchLabel: "Search agents by title",
|
|
148
|
+
openSearch: "Search agents",
|
|
149
|
+
closeSearch: "Close agent search",
|
|
150
|
+
displayOptions: "Agent display options",
|
|
151
|
+
closeDisplayOptions: "Close agent display options",
|
|
152
|
+
noFilters: "No filters selected",
|
|
153
|
+
noMatches: "No matching agents",
|
|
154
|
+
previousPage: "Previous agents page",
|
|
155
|
+
nextPage: "Next agents page",
|
|
156
|
+
terminals: "Terminals",
|
|
157
|
+
showOutput: (name: string) => `Show output of ${name}`,
|
|
158
|
+
hideOutput: (name: string) => `Hide output of ${name}`,
|
|
159
|
+
closeTerminal: (name: string) => `Close ${name}`,
|
|
160
|
+
noOutput: "No output",
|
|
161
|
+
showTimeline: (title: string) => `Show ${title} as a timeline`,
|
|
162
|
+
showRanked: (title: string) => `Show ${title} ranked by calls`,
|
|
163
|
+
archive: (label: string) => `Archive ${label}`,
|
|
164
|
+
unarchive: (label: string) => `Unarchive ${label}`,
|
|
165
|
+
state: {
|
|
166
|
+
running: "running",
|
|
167
|
+
subagents: (value: number) => count(value, "subagent", "subagents"),
|
|
168
|
+
permissions: (value: number) => count(value, "pending permission", "pending permissions"),
|
|
169
|
+
failed: "failed",
|
|
170
|
+
finished: "turn finished, unread",
|
|
171
|
+
},
|
|
172
|
+
menu: { sort: "Sort", group: "Group", show: "Show", status: "Status", lifecycle: "Lifecycle" },
|
|
173
|
+
options: {
|
|
174
|
+
sort: { updated: "Updated", created: "Created", name: "Name", messages: "Prompts", status: "Status" },
|
|
175
|
+
group: { none: "None", provider: "Provider", status: "Status" },
|
|
176
|
+
show: { provider: "Provider", calls: "Calls", messages: "Prompts", updated: "Updated", prompt: "Latest prompt" },
|
|
177
|
+
status: { active: "Active", archived: "Archived" },
|
|
178
|
+
lifecycle: { idle: "Idle", running: "Running", error: "Error", closed: "Closed" },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
attention: {
|
|
182
|
+
title: "Needs attention",
|
|
183
|
+
empty: "No other agents need attention",
|
|
184
|
+
agentOnly: "Attention is only available for an agent",
|
|
185
|
+
},
|
|
186
|
+
commands: {
|
|
187
|
+
agentActivity: "Agent Activity",
|
|
188
|
+
workspaceActivity: "Workspace Activity",
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export type Messages = ReturnType<typeof en>;
|
|
194
|
+
|
|
195
|
+
function zhCN({ num }: Formatters): Messages {
|
|
196
|
+
return {
|
|
197
|
+
common: {
|
|
198
|
+
activity: "Activity",
|
|
199
|
+
skills: "Skill",
|
|
200
|
+
mcp: "MCP",
|
|
201
|
+
agents: "Agent",
|
|
202
|
+
sessions: "会话",
|
|
203
|
+
prompts: "提示词",
|
|
204
|
+
loading: "加载中…",
|
|
205
|
+
retry: "重试",
|
|
206
|
+
loadFailed: "无法加载 Activity",
|
|
207
|
+
today: "今天",
|
|
208
|
+
now: "现在",
|
|
209
|
+
noSkillOrMcp: "还没有 Skill 或 MCP 调用",
|
|
210
|
+
lastUsed: (time: string) => `最近 ${time}`,
|
|
211
|
+
failed: (value: number) => `${num(value)} 次失败`,
|
|
212
|
+
openConversation: (label: string) => `打开会话 ${label}`,
|
|
213
|
+
openSkillFile: (name: string) => `打开 ${name} 的 SKILL.md`,
|
|
214
|
+
openSkillInPanel: "在面板中打开 SKILL.md",
|
|
215
|
+
showSkills: "显示 Skill",
|
|
216
|
+
showMcp: "显示 MCP",
|
|
217
|
+
agentOnly: "Activity 仅适用于 Agent",
|
|
218
|
+
},
|
|
219
|
+
units: {
|
|
220
|
+
agents: (value: number) => `${num(value)} 个 Agent`,
|
|
221
|
+
sessions: (value: number) => `${num(value)} 个会话`,
|
|
222
|
+
prompts: (value: number) => `${num(value)} 条提示词`,
|
|
223
|
+
skills: (value: number) => `${num(value)} 次 Skill`,
|
|
224
|
+
mcp: (value: number) => `${num(value)} 次 MCP`,
|
|
225
|
+
calls: (value: number) => `${num(value)} 次调用`,
|
|
226
|
+
days: (value: number) => `${num(value)} 天`,
|
|
227
|
+
},
|
|
228
|
+
duration: {
|
|
229
|
+
underMinute: "<1 分钟",
|
|
230
|
+
minutes: (value: number) => `${num(value)} 分钟`,
|
|
231
|
+
hours: (value: number) => `${num(value)} 小时`,
|
|
232
|
+
days: (value: number) => `${num(value)} 天`,
|
|
233
|
+
months: (value: number) => `${num(value)} 个月`,
|
|
234
|
+
},
|
|
235
|
+
kpi: {
|
|
236
|
+
sessions: "会话",
|
|
237
|
+
prompts: "提示词",
|
|
238
|
+
topProvider: "常用 Provider",
|
|
239
|
+
topModel: "常用模型",
|
|
240
|
+
previous7Days: "较前 7 天",
|
|
241
|
+
previous7DaysBare: "前 7 天",
|
|
242
|
+
skillCalls: "Skill 调用",
|
|
243
|
+
mcpCalls: "MCP 调用",
|
|
244
|
+
shellCalls: "Shell 调用",
|
|
245
|
+
fileReads: "文件读取",
|
|
246
|
+
fileWrites: "文件写入",
|
|
247
|
+
toolsExplored: "用过的工具",
|
|
248
|
+
},
|
|
249
|
+
insights: {
|
|
250
|
+
title: "Activity 洞察",
|
|
251
|
+
activeDays: "活跃天数",
|
|
252
|
+
busiestDay: "最忙的一天",
|
|
253
|
+
workspaces: "工作区",
|
|
254
|
+
codingVsChat: "编码 vs 对话",
|
|
255
|
+
longestStreak: "最长连续",
|
|
256
|
+
peakWeekday: "最活跃星期",
|
|
257
|
+
multiTurnSessions: "多轮会话",
|
|
258
|
+
avgSessionDuration: "平均会话时长",
|
|
259
|
+
codingShare: (pct: number) => `${num(pct)}% 编码`,
|
|
260
|
+
},
|
|
261
|
+
global: {
|
|
262
|
+
allProviders: "全部",
|
|
263
|
+
providerLabel: "Provider",
|
|
264
|
+
selectProvider: "选择 Provider",
|
|
265
|
+
closeProviderMenu: "关闭 Provider 菜单",
|
|
266
|
+
metrics: { sessions: "会话", prompts: "提示词", skills: "Skill 调用", mcp: "MCP 调用" },
|
|
267
|
+
previousMetric: "上一个指标",
|
|
268
|
+
nextMetric: "下一个指标",
|
|
269
|
+
providerRanking: { title: "Provider", empty: "还没有 Provider 活动" },
|
|
270
|
+
projectRanking: { title: "项目", empty: "还没有项目活动", other: "其他" },
|
|
271
|
+
ranking: { showMore: (value: number) => `展开剩余 ${num(value)} 项`, showLess: "收起" },
|
|
272
|
+
rankTitle: { skills: "常用 Skill", mcp: "常用 MCP", models: "常用模型" },
|
|
273
|
+
rankEmpty: { skills: "还没有 Skill", mcp: "还没有 MCP", models: "还没有模型" },
|
|
274
|
+
rankShow: { skills: "显示常用 Skill", mcp: "显示常用 MCP", models: "显示常用模型" },
|
|
275
|
+
emptyTitle: "还没有使用记录",
|
|
276
|
+
emptyHint: "会话、提示词、Skill 和 MCP 调用会显示在这里",
|
|
277
|
+
},
|
|
278
|
+
heatmap: {
|
|
279
|
+
title: "活动日历",
|
|
280
|
+
highlightMonth: (month: string) => `高亮 ${month}`,
|
|
281
|
+
weekContaining: (date: string) => `${date} 所在周`,
|
|
282
|
+
through: (date: string) => `截至 ${date}`,
|
|
283
|
+
},
|
|
284
|
+
creations: {
|
|
285
|
+
title: "每日活动",
|
|
286
|
+
empty: (days: number) => `最近 ${num(days)} 天没有活动`,
|
|
287
|
+
},
|
|
288
|
+
timeline: {
|
|
289
|
+
title: "每小时活动",
|
|
290
|
+
empty: "还没有活动",
|
|
291
|
+
},
|
|
292
|
+
workspace: {
|
|
293
|
+
empty: "此工作区还没有活动",
|
|
294
|
+
searchPlaceholder: "搜索 Agent",
|
|
295
|
+
searchLabel: "按标题搜索 Agent",
|
|
296
|
+
openSearch: "搜索 Agent",
|
|
297
|
+
closeSearch: "关闭 Agent 搜索",
|
|
298
|
+
displayOptions: "Agent 显示选项",
|
|
299
|
+
closeDisplayOptions: "关闭 Agent 显示选项",
|
|
300
|
+
noFilters: "未选择筛选条件",
|
|
301
|
+
noMatches: "没有匹配的 Agent",
|
|
302
|
+
previousPage: "上一页 Agent",
|
|
303
|
+
nextPage: "下一页 Agent",
|
|
304
|
+
terminals: "终端",
|
|
305
|
+
showOutput: (name: string) => `显示 ${name} 的输出`,
|
|
306
|
+
hideOutput: (name: string) => `隐藏 ${name} 的输出`,
|
|
307
|
+
closeTerminal: (name: string) => `关闭 ${name}`,
|
|
308
|
+
noOutput: "无输出",
|
|
309
|
+
showTimeline: (title: string) => `以时间线显示 ${title}`,
|
|
310
|
+
showRanked: (title: string) => `按调用次数排序 ${title}`,
|
|
311
|
+
archive: (label: string) => `归档 ${label}`,
|
|
312
|
+
unarchive: (label: string) => `取消归档 ${label}`,
|
|
313
|
+
state: {
|
|
314
|
+
running: "运行中",
|
|
315
|
+
subagents: (value: number) => `${num(value)} 个子 Agent`,
|
|
316
|
+
permissions: (value: number) => `${num(value)} 个待处理权限`,
|
|
317
|
+
failed: "失败",
|
|
318
|
+
finished: "本轮已完成,未读",
|
|
319
|
+
},
|
|
320
|
+
menu: { sort: "排序", group: "分组", show: "显示", status: "状态", lifecycle: "生命周期" },
|
|
321
|
+
options: {
|
|
322
|
+
sort: { updated: "更新时间", created: "创建时间", name: "名称", messages: "提示词", status: "状态" },
|
|
323
|
+
group: { none: "无", provider: "Provider", status: "状态" },
|
|
324
|
+
show: { provider: "Provider", calls: "调用", messages: "提示词", updated: "更新时间", prompt: "最新提示词" },
|
|
325
|
+
status: { active: "活跃", archived: "已归档" },
|
|
326
|
+
lifecycle: { idle: "空闲", running: "运行中", error: "错误", closed: "已关闭" },
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
attention: {
|
|
330
|
+
title: "需要关注",
|
|
331
|
+
empty: "没有其他需要关注的 Agent",
|
|
332
|
+
agentOnly: "仅在 Agent 中可用",
|
|
333
|
+
},
|
|
334
|
+
commands: {
|
|
335
|
+
agentActivity: "Agent Activity",
|
|
336
|
+
workspaceActivity: "工作区 Activity",
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
const CATALOGS: Partial<Record<AppLanguage, (fmt: Formatters) => Messages>> = {
|
|
342
|
+
en,
|
|
343
|
+
"zh-CN": zhCN,
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const cache = new Map<string, Messages>();
|
|
347
|
+
|
|
348
|
+
/** Copy for `locale`; languages without a catalog fall back to English text. */
|
|
349
|
+
export function messagesFor(locale: string = "en"): Messages {
|
|
350
|
+
const cached = cache.get(locale);
|
|
351
|
+
if (cached) return cached;
|
|
352
|
+
const lang = resolveAppLanguage(locale);
|
|
353
|
+
const factory = CATALOGS[lang] ?? en;
|
|
354
|
+
let numberLocale = locale;
|
|
355
|
+
try {
|
|
356
|
+
numberLocale = Intl.getCanonicalLocales(locale)[0] ?? "en";
|
|
357
|
+
} catch {
|
|
358
|
+
numberLocale = "en";
|
|
359
|
+
}
|
|
360
|
+
const messages = factory({ num: (value) => value.toLocaleString(numberLocale) });
|
|
361
|
+
cache.set(locale, messages);
|
|
362
|
+
return messages;
|
|
363
|
+
}
|