@linxiraos/pi-stats 1.0.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 +276 -0
- package/README.md +82 -0
- package/build.ts +95 -0
- package/dist/client/index.css +1 -0
- package/dist/client/index.html +24 -0
- package/dist/client/index.js +257 -0
- package/dist/client/styles.css +1695 -0
- package/dist/types/aggregator.d.ts +98 -0
- package/dist/types/client/App.d.ts +1 -0
- package/dist/types/client/api.d.ts +22 -0
- package/dist/types/client/app/AppLayout.d.ts +16 -0
- package/dist/types/client/app/NavRail.d.ts +7 -0
- package/dist/types/client/app/RangeControl.d.ts +7 -0
- package/dist/types/client/app/SyncButton.d.ts +14 -0
- package/dist/types/client/app/ThemeToggle.d.ts +1 -0
- package/dist/types/client/app/TopBar.d.ts +15 -0
- package/dist/types/client/app/routes.d.ts +12 -0
- package/dist/types/client/components/AgentTokenShare.d.ts +5 -0
- package/dist/types/client/components/chart-shared.d.ts +173 -0
- package/dist/types/client/components/models-table-shared.d.ts +175 -0
- package/dist/types/client/components/range-meta.d.ts +21 -0
- package/dist/types/client/data/charts.d.ts +1 -0
- package/dist/types/client/data/formatters.d.ts +8 -0
- package/dist/types/client/data/useHashRoute.d.ts +8 -0
- package/dist/types/client/data/useResource.d.ts +13 -0
- package/dist/types/client/data/view-models.d.ts +74 -0
- package/dist/types/client/index.d.ts +2 -0
- package/dist/types/client/routes/BehaviorRoute.d.ts +7 -0
- package/dist/types/client/routes/CostsRoute.d.ts +7 -0
- package/dist/types/client/routes/ErrorsRoute.d.ts +8 -0
- package/dist/types/client/routes/GainRoute.d.ts +7 -0
- package/dist/types/client/routes/ModelsRoute.d.ts +7 -0
- package/dist/types/client/routes/OverviewRoute.d.ts +8 -0
- package/dist/types/client/routes/ProjectsRoute.d.ts +7 -0
- package/dist/types/client/routes/ProvidersRoute.d.ts +7 -0
- package/dist/types/client/routes/RequestsRoute.d.ts +8 -0
- package/dist/types/client/routes/ToolsRoute.d.ts +7 -0
- package/dist/types/client/routes/index.d.ts +10 -0
- package/dist/types/client/types.d.ts +63 -0
- package/dist/types/client/ui/AsyncBoundary.d.ts +12 -0
- package/dist/types/client/ui/DataTable.d.ts +17 -0
- package/dist/types/client/ui/EmptyState.d.ts +7 -0
- package/dist/types/client/ui/ErrorState.d.ts +6 -0
- package/dist/types/client/ui/JsonBlock.d.ts +7 -0
- package/dist/types/client/ui/MetricCluster.d.ts +5 -0
- package/dist/types/client/ui/Panel.d.ts +7 -0
- package/dist/types/client/ui/RequestDrawer.d.ts +5 -0
- package/dist/types/client/ui/SegmentedControl.d.ts +12 -0
- package/dist/types/client/ui/Skeleton.d.ts +8 -0
- package/dist/types/client/ui/StatusPill.d.ts +7 -0
- package/dist/types/client/ui/index.d.ts +11 -0
- package/dist/types/client/useSystemTheme.d.ts +11 -0
- package/dist/types/db.d.ts +159 -0
- package/dist/types/embedded-client.d.ts +18 -0
- package/dist/types/gain-aggregator.d.ts +26 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/parser.d.ts +53 -0
- package/dist/types/port-conflict.d.ts +14 -0
- package/dist/types/server.d.ts +12 -0
- package/dist/types/shared-types.d.ts +403 -0
- package/dist/types/sync-worker.d.ts +31 -0
- package/dist/types/types.d.ts +164 -0
- package/dist/types/usage-windows.d.ts +45 -0
- package/dist/types/user-metrics.d.ts +81 -0
- package/package.json +94 -0
- package/src/aggregator.ts +615 -0
- package/src/client/App.tsx +112 -0
- package/src/client/api.ts +118 -0
- package/src/client/app/AppLayout.tsx +93 -0
- package/src/client/app/NavRail.tsx +44 -0
- package/src/client/app/RangeControl.tsx +39 -0
- package/src/client/app/SyncButton.tsx +75 -0
- package/src/client/app/ThemeToggle.tsx +37 -0
- package/src/client/app/TopBar.tsx +73 -0
- package/src/client/app/routes.ts +86 -0
- package/src/client/components/AgentTokenShare.tsx +68 -0
- package/src/client/components/chart-shared.tsx +257 -0
- package/src/client/components/models-table-shared.tsx +255 -0
- package/src/client/components/range-meta.ts +73 -0
- package/src/client/css.d.ts +1 -0
- package/src/client/data/charts.ts +14 -0
- package/src/client/data/formatters.ts +45 -0
- package/src/client/data/useHashRoute.ts +88 -0
- package/src/client/data/useResource.ts +154 -0
- package/src/client/data/view-models.ts +259 -0
- package/src/client/index.tsx +10 -0
- package/src/client/routes/BehaviorRoute.tsx +623 -0
- package/src/client/routes/CostsRoute.tsx +234 -0
- package/src/client/routes/ErrorsRoute.tsx +118 -0
- package/src/client/routes/GainRoute.tsx +226 -0
- package/src/client/routes/ModelsRoute.tsx +430 -0
- package/src/client/routes/OverviewRoute.tsx +342 -0
- package/src/client/routes/ProjectsRoute.tsx +163 -0
- package/src/client/routes/ProvidersRoute.tsx +492 -0
- package/src/client/routes/RequestsRoute.tsx +123 -0
- package/src/client/routes/ToolsRoute.tsx +463 -0
- package/src/client/routes/index.ts +10 -0
- package/src/client/styles.css +1384 -0
- package/src/client/types.ts +80 -0
- package/src/client/ui/AsyncBoundary.tsx +54 -0
- package/src/client/ui/DataTable.tsx +122 -0
- package/src/client/ui/EmptyState.tsx +16 -0
- package/src/client/ui/ErrorState.tsx +25 -0
- package/src/client/ui/JsonBlock.tsx +75 -0
- package/src/client/ui/MetricCluster.tsx +78 -0
- package/src/client/ui/Panel.tsx +24 -0
- package/src/client/ui/RequestDrawer.tsx +208 -0
- package/src/client/ui/SegmentedControl.tsx +36 -0
- package/src/client/ui/Skeleton.tsx +17 -0
- package/src/client/ui/StatusPill.tsx +15 -0
- package/src/client/ui/index.ts +11 -0
- package/src/client/useSystemTheme.ts +87 -0
- package/src/db.ts +1702 -0
- package/src/embedded-client.generated.txt +0 -0
- package/src/embedded-client.ts +26 -0
- package/src/gain-aggregator.ts +311 -0
- package/src/index.ts +194 -0
- package/src/parser.ts +499 -0
- package/src/port-conflict.ts +263 -0
- package/src/server.ts +396 -0
- package/src/shared-types.ts +432 -0
- package/src/sync-worker.ts +40 -0
- package/src/types.ts +171 -0
- package/src/usage-windows.ts +304 -0
- package/src/user-metrics.ts +695 -0
- package/tailwind.config.js +40 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Behavioral metrics extracted from a single user message.
|
|
3
|
+
*
|
|
4
|
+
* Pure, side-effect free. Designed for batch use during session ingestion
|
|
5
|
+
* and standalone testing.
|
|
6
|
+
*/
|
|
7
|
+
export interface UserMessageMetrics {
|
|
8
|
+
/** Total characters of analyzed text. */
|
|
9
|
+
chars: number;
|
|
10
|
+
/** Whitespace-delimited word count. */
|
|
11
|
+
words: number;
|
|
12
|
+
/**
|
|
13
|
+
* Number of "yelling" sentences: sentences where more than half of the
|
|
14
|
+
* alphabetic characters are uppercase (and there are enough letters to
|
|
15
|
+
* make the ratio meaningful - short acronyms like "OK" don't count).
|
|
16
|
+
* A sentence also needs either two uppercase runs ("WHAT THE HELL") or
|
|
17
|
+
* one elongated run ("CMOOON") so a lone acronym/env var ("use JSON",
|
|
18
|
+
* "HOME=/tmp") doesn't register.
|
|
19
|
+
*/
|
|
20
|
+
yelling: number;
|
|
21
|
+
/** Profanity hits (word-boundary, case-insensitive). */
|
|
22
|
+
profanity: number;
|
|
23
|
+
/**
|
|
24
|
+
* Catch-all "obviously upset" signal computed on a *prose-only* body
|
|
25
|
+
* (code fences, XML/HTML tags, URLs, file mentions, and quoted lines
|
|
26
|
+
* are stripped first; messages whose remaining prose is >=3 lines score
|
|
27
|
+
* zero because formatted prompts aren't tantrums).
|
|
28
|
+
*
|
|
29
|
+
* Sum of:
|
|
30
|
+
* - drama runs: 3+ `!` / `?` (with `1`-mishit fallout)
|
|
31
|
+
* - interjections, elongated where the short form is ambiguous:
|
|
32
|
+
* `noooo`, `ahhh`, `ugh(h)`, `argh`, `grr`, `stooop`, `whyyy`,
|
|
33
|
+
* `fuuu(ck)`, `wtfff`, `omggg`, `yesss`, `goddd`, `bruhh`
|
|
34
|
+
* - standalone `dude`
|
|
35
|
+
* - sad emoticons: `:(`, `;(`, `:-(((`
|
|
36
|
+
*/
|
|
37
|
+
anguish: number;
|
|
38
|
+
/**
|
|
39
|
+
* Corrective negation: the user is telling us we got it wrong.
|
|
40
|
+
*
|
|
41
|
+
* Counted on the same prose-only body as {@link anguish}.
|
|
42
|
+
*
|
|
43
|
+
* - line-leading `nope` / `nah` / `nvm` / `wrong` / `incorrect`
|
|
44
|
+
* (word-bounded, so `now`, `nobody`, `north` don't match)
|
|
45
|
+
* - line-leading `no` when used as an interjection - followed by
|
|
46
|
+
* punctuation, end-of-text, or a discourse word (`no i meant`,
|
|
47
|
+
* `no, wait`). Determiner `no` (`no extensions to the page`,
|
|
48
|
+
* `no auto start`) doesn't count.
|
|
49
|
+
* - `that(?:'s)? not (what|right|it)` and `not what i (meant|asked|said|wanted)`
|
|
50
|
+
* - `makes (no|zero) sense`
|
|
51
|
+
*/
|
|
52
|
+
negation: number;
|
|
53
|
+
/**
|
|
54
|
+
* The user is repeating themselves - strong signal the previous turn
|
|
55
|
+
* missed the ask. Counts hits for:
|
|
56
|
+
*
|
|
57
|
+
* - `i (meant|said|asked|told you|already (said|told|did|asked|wrote))`
|
|
58
|
+
* - `(like|as) i (said|told you|asked)`
|
|
59
|
+
* - `still (doesn't|isn't|not|broken|wrong|fails|failing|the same|same)`
|
|
60
|
+
*
|
|
61
|
+
* Bare `still` / `again` are too ambiguous to count alone (they show up
|
|
62
|
+
* in normal speech like "try again" or "still works").
|
|
63
|
+
*/
|
|
64
|
+
repetition: number;
|
|
65
|
+
/**
|
|
66
|
+
* Direct second-person reproach pinned on the agent:
|
|
67
|
+
*
|
|
68
|
+
* - `you (didn't|did not|broke|missed|forgot|keep|always|never|still|ignored)`
|
|
69
|
+
* - `why (would|did) (you|u)`
|
|
70
|
+
* - sentence-leading `stop <verb>ing` imperatives
|
|
71
|
+
*/
|
|
72
|
+
blame: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Compute behavioral metrics for a user message.
|
|
76
|
+
*
|
|
77
|
+
* `text` may be empty or whitespace; in that case every metric is 0.
|
|
78
|
+
*/
|
|
79
|
+
export declare function computeUserMessageMetrics(text: string): UserMessageMetrics;
|
|
80
|
+
/** Empty metrics constant for callers that need a default. */
|
|
81
|
+
export declare const EMPTY_USER_METRICS: UserMessageMetrics;
|
package/package.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@linxiraos/pi-stats",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Local observability dashboard for pi AI usage statistics",
|
|
6
|
+
"homepage": "https://linxira-os.github.io",
|
|
7
|
+
"author": "Can Boluk",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/Linxira-OS/linxira-zeta.git",
|
|
12
|
+
"directory": "packages/stats"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/can1357/oh-my-pi/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"observability",
|
|
20
|
+
"metrics",
|
|
21
|
+
"dashboard",
|
|
22
|
+
"llm",
|
|
23
|
+
"statistics"
|
|
24
|
+
],
|
|
25
|
+
"main": "./src/index.ts",
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"bin": {
|
|
28
|
+
"omp-stats": "./src/index.ts"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"gen:stats": "bun scripts/generate-client-bundle.ts --generate",
|
|
32
|
+
"gen:stats:reset": "bun scripts/generate-client-bundle.ts --reset",
|
|
33
|
+
"build": "bun run build.ts",
|
|
34
|
+
"dev": "bun run src/index.ts",
|
|
35
|
+
"check": "biome check . && bun run check:types",
|
|
36
|
+
"check:types": "tsgo -p tsconfig.json --noEmit && tsgo -p tsconfig.client.json --noEmit",
|
|
37
|
+
"lint": "biome lint .",
|
|
38
|
+
"fix": "biome check --write --unsafe .",
|
|
39
|
+
"fmt": "biome format --write ."
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@tailwindcss/node": "^4.3.2",
|
|
43
|
+
"chart.js": "^4.5.1",
|
|
44
|
+
"lucide-react": "^1.24.0",
|
|
45
|
+
"react": "19.2.7",
|
|
46
|
+
"react-chartjs-2": "^5.3.1",
|
|
47
|
+
"react-dom": "19.2.7",
|
|
48
|
+
"tailwindcss": "^4.3.2",
|
|
49
|
+
"@linxiraos/pi-ai": "1.0.0",
|
|
50
|
+
"@linxiraos/pi-catalog": "1.0.0",
|
|
51
|
+
"@linxiraos/pi-utils": "1.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/bun": "^1.3.14",
|
|
55
|
+
"@types/react": "^19.2.17",
|
|
56
|
+
"@types/react-dom": "^19.2.3",
|
|
57
|
+
"postcss": "^8.5.16"
|
|
58
|
+
},
|
|
59
|
+
"engines": {
|
|
60
|
+
"bun": ">=1.3.14"
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"src",
|
|
64
|
+
"build.ts",
|
|
65
|
+
"tailwind.config.js",
|
|
66
|
+
"README.md",
|
|
67
|
+
"CHANGELOG.md",
|
|
68
|
+
"dist/types",
|
|
69
|
+
"dist/client"
|
|
70
|
+
],
|
|
71
|
+
"exports": {
|
|
72
|
+
".": {
|
|
73
|
+
"types": "./dist/types/index.d.ts",
|
|
74
|
+
"import": "./src/index.ts"
|
|
75
|
+
},
|
|
76
|
+
"./*": {
|
|
77
|
+
"types": "./dist/types/*.d.ts",
|
|
78
|
+
"import": "./src/*.ts"
|
|
79
|
+
},
|
|
80
|
+
"./client": {
|
|
81
|
+
"types": "./dist/types/client/index.d.ts",
|
|
82
|
+
"import": "./src/client/index.tsx"
|
|
83
|
+
},
|
|
84
|
+
"./client/*": {
|
|
85
|
+
"types": "./dist/types/client/*.d.ts",
|
|
86
|
+
"import": "./src/client/*.ts"
|
|
87
|
+
},
|
|
88
|
+
"./client/components/*": {
|
|
89
|
+
"types": "./dist/types/client/components/*.d.ts",
|
|
90
|
+
"import": "./src/client/components/*.ts"
|
|
91
|
+
},
|
|
92
|
+
"./*.js": "./src/*.ts"
|
|
93
|
+
}
|
|
94
|
+
}
|