chore: rename package and assets to token-contribution

This commit is contained in:
katR 2026-10-11 17:51:39 +05:30
parent a74892e485
commit 6ee09e215e
11 changed files with 50 additions and 46 deletions

View file

@ -1,6 +1,6 @@
# dsh-token-heatmap
# token-contribution
> GitHub-style daily token usage heatmap, model analytics, and timeline trends for [DeepSeek Harness](https://github.com/deepseek-ai/dsh).
> GitHub-style daily token usage contribution calendar, model analytics, and timeline trends for [DeepSeek Harness](https://github.com/deepseek-ai/dsh).
---
@ -9,18 +9,18 @@
Install with a single command via the official DSH CLI:
```bash
dsh plugin --profile web add dsh-token-heatmap
dsh plugin --profile web add token-contribution
```
*(To remove later: `dsh plugin --profile web remove dsh-token-heatmap`)*
*(To remove later: `dsh plugin --profile web remove token-contribution`)*
### Manual Alternative (pnpm)
```bash
cd ~/.dsh/profiles/web
pnpm add dsh-token-heatmap
pnpm add token-contribution
```
Then add `"dsh-token-heatmap"` to `bundles` in `~/.dsh/profiles/web/package.json`.
Then add `"token-contribution"` to `bundles` in `~/.dsh/profiles/web/package.json`.
---

View file

@ -1,4 +1,4 @@
# dsh-token-heatmap bundle patch
# token-contribution bundle patch
- insert:
- id: token-heatmap
name: 'dsh-token-heatmap'
- id: token-contribution
name: 'token-contribution'

View file

@ -1,4 +1,4 @@
window.__ModuleLoader__.load({ id: "dsh-token-heatmap", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
window.__ModuleLoader__.load({ id: "token-contribution", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@ -95,7 +95,7 @@ function HeatmapInnerView() {
}, []);
const fetchStats = () => {
setLoading(true);
fetch("/api/dsh-token-heatmap/stats").then((r) => {
fetch("/api/token-contribution/stats").then((r) => {
if (!r.ok) throw new Error(`HTTP error ${r.status}`);
return r.json();
}).then((res) => {
@ -1117,7 +1117,7 @@ function HeatmapModal({ open, onClose }) {
}
// src/client/index.tsx
var name = "dsh-plugin-token-heatmap-client";
var name = "token-contribution-client";
var inject = ["slots"];
function apply(ctx) {
if (ctx.slots && typeof ctx.slots.inject === "function") {
@ -1125,9 +1125,9 @@ function apply(ctx) {
return ctx.slots.register(
{
name: "settings.section",
id: "token-heatmap",
id: "token-contribution",
order: 14,
label: () => "Token Heatmap",
label: () => "Token Contribution",
icon: "chart"
},
HeatmapView
@ -1140,11 +1140,13 @@ function apply(ctx) {
(0, import_react3.useEffect)(() => {
const handleOpen = () => setIsOpen(true);
const handleClose = () => setIsOpen(false);
window.addEventListener("dsh:open-token-contribution", handleOpen);
window.addEventListener("dsh:open-token-heatmap", handleOpen);
window.addEventListener("keydown", (e) => {
if (e.key === "Escape") handleClose();
});
return () => {
window.removeEventListener("dsh:open-token-contribution", handleOpen);
window.removeEventListener("dsh:open-token-heatmap", handleOpen);
};
}, []);
@ -1165,7 +1167,7 @@ function apply(ctx) {
document.head.appendChild(resizeStyle);
}
const modalContainer = document.createElement("div");
modalContainer.id = "dsh-token-heatmap-modal-root";
modalContainer.id = "token-contribution-modal-root";
document.body.appendChild(modalContainer);
const root = (0, import_client.createRoot)(modalContainer);
root.render(/* @__PURE__ */ import_react3.default.createElement(ModalController, null));
@ -1180,7 +1182,7 @@ function apply(ctx) {
const button = document.createElement("button");
button.className = "dsh-heatmap-trigger-btn";
button.type = "button";
button.innerHTML = "<span>View Token Usage Heatmap \u2192</span>";
button.innerHTML = "<span>View Token Contribution \u2192</span>";
button.style.cssText = `
display: flex;
align-items: center;
@ -1218,16 +1220,16 @@ function apply(ctx) {
settingsTrigger.click();
setTimeout(() => {
const heatmapTab = Array.from(document.querySelectorAll("*")).find(
(el) => el.textContent?.trim() === "Token Heatmap" && (el.tagName === "BUTTON" || el.tagName === "DIV" || el.getAttribute("role") === "tab" || el.classList.contains("ant-list-item"))
(el) => (el.textContent?.trim() === "Token Contribution" || el.textContent?.trim() === "Token Heatmap") && (el.tagName === "BUTTON" || el.tagName === "DIV" || el.getAttribute("role") === "tab" || el.classList.contains("ant-list-item"))
);
if (heatmapTab) {
heatmapTab.click();
} else {
window.dispatchEvent(new CustomEvent("dsh:open-token-heatmap"));
window.dispatchEvent(new CustomEvent("dsh:open-token-contribution"));
}
}, 120);
} else {
window.dispatchEvent(new CustomEvent("dsh:open-token-heatmap"));
window.dispatchEvent(new CustomEvent("dsh:open-token-contribution"));
}
};
dialogContainer.appendChild(button);

File diff suppressed because one or more lines are too long

View file

@ -1,10 +1,10 @@
const name = "dsh-plugin-token-heatmap";
const name = "token-contribution";
const inject = ["webServer"];
function apply(ctx) {
ctx.effect(
() => ctx.webServer.register({
kind: "prefix",
path: "/api/dsh-token-heatmap",
path: "/api/token-contribution",
handler: async (req, res) => {
const url = new URL(req.url, "http://localhost");
const pathname = url.pathname.replace(/\/+$/, "");
@ -16,7 +16,7 @@ function apply(ctx) {
res.end();
return;
}
if (req.method === "GET" && (pathname === "/api/dsh-token-heatmap" || pathname === "/api/dsh-token-heatmap/stats")) {
if (req.method === "GET" && (pathname === "/api/token-contribution" || pathname === "/api/token-contribution/stats" || pathname === "/api/dsh-token-heatmap/stats")) {
try {
const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`);
const data = await aggregateTokens();

View file

@ -1,7 +1,7 @@
{
"version": 3,
"sources": ["../src/server/index.ts"],
"sourcesContent": ["export const name = \"dsh-plugin-token-heatmap\";\nexport const inject = [\"webServer\"];\n\nexport function apply(ctx: any) {\n ctx.effect(() =>\n ctx.webServer.register({\n kind: \"prefix\",\n path: \"/api/dsh-token-heatmap\",\n handler: async (req: any, res: any) => {\n const url = new URL(req.url, \"http://localhost\");\n const pathname = url.pathname.replace(/\\/+$/, \"\");\n\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (req.method === \"GET\" && (pathname === \"/api/dsh-token-heatmap\" || pathname === \"/api/dsh-token-heatmap/stats\")) {\n try {\n const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`);\n const data = await aggregateTokens();\n res.writeHead(200, {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Cache-Control\": \"no-cache\",\n });\n res.end(JSON.stringify(data));\n } catch (err: any) {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: err?.message || \"Failed to aggregate token stats\" }));\n }\n return;\n }\n\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Not found\" }));\n },\n })\n );\n}\n"],
"mappings": "AAAO,MAAM,OAAO;AACb,MAAM,SAAS,CAAC,WAAW;AAE3B,SAAS,MAAM,KAAU;AAC9B,MAAI;AAAA,IAAO,MACT,IAAI,UAAU,SAAS;AAAA,MACrB,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,OAAO,KAAU,QAAa;AACrC,cAAM,MAAM,IAAI,IAAI,IAAI,KAAK,kBAAkB;AAC/C,cAAM,WAAW,IAAI,SAAS,QAAQ,QAAQ,EAAE;AAEhD,YAAI,UAAU,+BAA+B,GAAG;AAChD,YAAI,UAAU,gCAAgC,cAAc;AAC5D,YAAI,UAAU,gCAAgC,cAAc;AAE5D,YAAI,IAAI,WAAW,WAAW;AAC5B,cAAI,UAAU,GAAG;AACjB,cAAI,IAAI;AACR;AAAA,QACF;AAEA,YAAI,IAAI,WAAW,UAAU,aAAa,4BAA4B,aAAa,iCAAiC;AAClH,cAAI;AACF,kBAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,qBAAqB,KAAK,IAAI,CAAC;AACxE,kBAAM,OAAO,MAAM,gBAAgB;AACnC,gBAAI,UAAU,KAAK;AAAA,cACjB,gBAAgB;AAAA,cAChB,iBAAiB;AAAA,YACnB,CAAC;AACD,gBAAI,IAAI,KAAK,UAAU,IAAI,CAAC;AAAA,UAC9B,SAAS,KAAU;AACjB,gBAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,gBAAI,IAAI,KAAK,UAAU,EAAE,OAAO,KAAK,WAAW,kCAAkC,CAAC,CAAC;AAAA,UACtF;AACA;AAAA,QACF;AAEA,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,EAAE,OAAO,YAAY,CAAC,CAAC;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
"sourcesContent": ["export const name = \"token-contribution\";\nexport const inject = [\"webServer\"];\n\nexport function apply(ctx: any) {\n ctx.effect(() =>\n ctx.webServer.register({\n kind: \"prefix\",\n path: \"/api/token-contribution\",\n handler: async (req: any, res: any) => {\n const url = new URL(req.url, \"http://localhost\");\n const pathname = url.pathname.replace(/\\/+$/, \"\");\n\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(204);\n res.end();\n return;\n }\n\n if (req.method === \"GET\" && (pathname === \"/api/token-contribution\" || pathname === \"/api/token-contribution/stats\" || pathname === \"/api/dsh-token-heatmap/stats\")) {\n try {\n const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`);\n const data = await aggregateTokens();\n res.writeHead(200, {\n \"Content-Type\": \"application/json; charset=utf-8\",\n \"Cache-Control\": \"no-cache\",\n });\n res.end(JSON.stringify(data));\n } catch (err: any) {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: err?.message || \"Failed to aggregate token stats\" }));\n }\n return;\n }\n\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Not found\" }));\n },\n })\n );\n}\n"],
"mappings": "AAAO,MAAM,OAAO;AACb,MAAM,SAAS,CAAC,WAAW;AAE3B,SAAS,MAAM,KAAU;AAC9B,MAAI;AAAA,IAAO,MACT,IAAI,UAAU,SAAS;AAAA,MACrB,MAAM;AAAA,MACN,MAAM;AAAA,MACN,SAAS,OAAO,KAAU,QAAa;AACrC,cAAM,MAAM,IAAI,IAAI,IAAI,KAAK,kBAAkB;AAC/C,cAAM,WAAW,IAAI,SAAS,QAAQ,QAAQ,EAAE;AAEhD,YAAI,UAAU,+BAA+B,GAAG;AAChD,YAAI,UAAU,gCAAgC,cAAc;AAC5D,YAAI,UAAU,gCAAgC,cAAc;AAE5D,YAAI,IAAI,WAAW,WAAW;AAC5B,cAAI,UAAU,GAAG;AACjB,cAAI,IAAI;AACR;AAAA,QACF;AAEA,YAAI,IAAI,WAAW,UAAU,aAAa,6BAA6B,aAAa,mCAAmC,aAAa,iCAAiC;AACnK,cAAI;AACF,kBAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,qBAAqB,KAAK,IAAI,CAAC;AACxE,kBAAM,OAAO,MAAM,gBAAgB;AACnC,gBAAI,UAAU,KAAK;AAAA,cACjB,gBAAgB;AAAA,cAChB,iBAAiB;AAAA,YACnB,CAAC;AACD,gBAAI,IAAI,KAAK,UAAU,IAAI,CAAC;AAAA,UAC9B,SAAS,KAAU;AACjB,gBAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,gBAAI,IAAI,KAAK,UAAU,EAAE,OAAO,KAAK,WAAW,kCAAkC,CAAC,CAAC;AAAA,UACtF;AACA;AAAA,QACF;AAEA,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,EAAE,OAAO,YAAY,CAAC,CAAC;AAAA,MAChD;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
"names": []
}

View file

@ -1,7 +1,7 @@
{
"name": "dsh-token-heatmap",
"version": "0.1.2",
"description": "GitHub-style token usage contribution heatmap and analytics for DeepSeek Harness",
"name": "token-contribution",
"version": "0.1.0",
"description": "GitHub-style token usage contribution calendar and analytics for DeepSeek Harness",
"type": "module",
"main": "./lib/index.js",
"exports": {
@ -47,10 +47,10 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "https://git.oiupoyt.space/oiupoyt/dsh-plugin-token-heatmap.git"
"url": "https://git.oiupoyt.space/oiupoyt/token-contribution.git"
},
"bugs": {
"url": "https://git.oiupoyt.space/oiupoyt/dsh-plugin-token-heatmap/issues"
"url": "https://git.oiupoyt.space/oiupoyt/token-contribution/issues"
},
"homepage": "https://git.oiupoyt.space/oiupoyt/dsh-plugin-token-heatmap#readme"
"homepage": "https://git.oiupoyt.space/oiupoyt/token-contribution#readme"
}

View file

@ -4,7 +4,7 @@ console.log("Building server backend...");
execSync("npx esbuild src/server/index.ts src/server/aggregator.ts --outdir=lib --platform=node --format=esm --target=node20 --sourcemap", { stdio: "inherit" });
console.log("Building client frontend bundle...");
const banner = 'window.__ModuleLoader__.load({ id: "dsh-token-heatmap", factory: (require) => { var module = { exports: {} }; var exports = module.exports;';
const banner = 'window.__ModuleLoader__.load({ id: "token-contribution", factory: (require) => { var module = { exports: {} }; var exports = module.exports;';
const footer = 'return module.exports; } });';
execSync(`npx esbuild src/client/index.tsx --outfile=lib/client.js --platform=browser --format=cjs --target=es2022 --bundle --external:react --external:react-dom --external:react-dom/client --banner:js='${banner}' --footer:js='${footer}' --sourcemap`, { stdio: "inherit" });

View file

@ -149,7 +149,7 @@ function HeatmapInnerView() {
const fetchStats = () => {
setLoading(true);
fetch("/api/dsh-token-heatmap/stats")
fetch("/api/token-contribution/stats")
.then((r) => {
if (!r.ok) throw new Error(`HTTP error ${r.status}`);
return r.json();

View file

@ -3,19 +3,19 @@ import { createRoot } from "react-dom/client";
import { HeatmapView } from "./HeatmapView.js";
import { HeatmapModal } from "./HeatmapModal.js";
export const name = "dsh-plugin-token-heatmap-client";
export const name = "token-contribution-client";
export const inject = ["slots"];
export function apply(ctx: any) {
// 1. Register under Settings -> "Token Heatmap"
// 1. Register under Settings -> "Token Contribution"
if (ctx.slots && typeof ctx.slots.inject === "function") {
ctx.slots.inject("settings.section", () => {
return ctx.slots.register(
{
name: "settings.section",
id: "token-heatmap",
id: "token-contribution",
order: 14,
label: () => "Token Heatmap",
label: () => "Token Contribution",
icon: "chart",
},
HeatmapView
@ -42,7 +42,7 @@ export function apply(ctx: any) {
}
const modalContainer = document.createElement("div");
modalContainer.id = "dsh-token-heatmap-modal-root";
modalContainer.id = "token-contribution-modal-root";
document.body.appendChild(modalContainer);
const root = createRoot(modalContainer);
@ -54,12 +54,14 @@ export function apply(ctx: any) {
const handleOpen = () => setIsOpen(true);
const handleClose = () => setIsOpen(false);
window.addEventListener("dsh:open-token-contribution", handleOpen);
window.addEventListener("dsh:open-token-heatmap", handleOpen);
window.addEventListener("keydown", (e) => {
if (e.key === "Escape") handleClose();
});
return () => {
window.removeEventListener("dsh:open-token-contribution", handleOpen);
window.removeEventListener("dsh:open-token-heatmap", handleOpen);
};
}, []);
@ -86,7 +88,7 @@ export function apply(ctx: any) {
const button = document.createElement("button");
button.className = "dsh-heatmap-trigger-btn";
button.type = "button";
button.innerHTML = "<span>View Token Usage Heatmap →</span>";
button.innerHTML = "<span>View Token Contribution →</span>";
button.style.cssText = `
display: flex;
align-items: center;
@ -128,18 +130,18 @@ export function apply(ctx: any) {
setTimeout(() => {
const heatmapTab = Array.from(document.querySelectorAll("*")).find(
(el) =>
el.textContent?.trim() === "Token Heatmap" &&
(el.textContent?.trim() === "Token Contribution" || el.textContent?.trim() === "Token Heatmap") &&
(el.tagName === "BUTTON" || el.tagName === "DIV" || el.getAttribute("role") === "tab" || el.classList.contains("ant-list-item"))
);
if (heatmapTab) {
(heatmapTab as HTMLElement).click();
} else {
window.dispatchEvent(new CustomEvent("dsh:open-token-heatmap"));
window.dispatchEvent(new CustomEvent("dsh:open-token-contribution"));
}
}, 120);
} else {
// Open direct interactive modal
window.dispatchEvent(new CustomEvent("dsh:open-token-heatmap"));
window.dispatchEvent(new CustomEvent("dsh:open-token-contribution"));
}
};

View file

@ -1,11 +1,11 @@
export const name = "dsh-plugin-token-heatmap";
export const name = "token-contribution";
export const inject = ["webServer"];
export function apply(ctx: any) {
ctx.effect(() =>
ctx.webServer.register({
kind: "prefix",
path: "/api/dsh-token-heatmap",
path: "/api/token-contribution",
handler: async (req: any, res: any) => {
const url = new URL(req.url, "http://localhost");
const pathname = url.pathname.replace(/\/+$/, "");
@ -20,7 +20,7 @@ export function apply(ctx: any) {
return;
}
if (req.method === "GET" && (pathname === "/api/dsh-token-heatmap" || pathname === "/api/dsh-token-heatmap/stats")) {
if (req.method === "GET" && (pathname === "/api/token-contribution" || pathname === "/api/token-contribution/stats" || pathname === "/api/dsh-token-heatmap/stats")) {
try {
const { aggregateTokens } = await import(`./aggregator.js?t=${Date.now()}`);
const data = await aggregateTokens();