modelstat 0.0.29 → 0.0.31
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/dist/cli.mjs +64 -10
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +51 -1
- package/vendor/tray-mac/Sources/ModelstatTray/main.swift +115 -18
package/dist/cli.mjs
CHANGED
|
@@ -44378,14 +44378,18 @@ async function summariseSlice(sessionId, slice, adapters2) {
|
|
|
44378
44378
|
Object.keys(first.tool_calls ?? {}).length ? `tool calls: ${Object.keys(first.tool_calls).slice(0, 5).join(", ")}` : null
|
|
44379
44379
|
].filter(Boolean).join("; ");
|
|
44380
44380
|
const excerpts = sampleAndRedactExcerpts(slice);
|
|
44381
|
-
|
|
44382
|
-
|
|
44381
|
+
if (excerpts.length === 0) {
|
|
44382
|
+
throw new Error(
|
|
44383
|
+
`parser produced 0 content excerpts for session ${sessionId} (${slice.length} turns) \u2014 the summariser would only see metadata and produce "${slice.length} turns on ${first.tool}". Check the parser for ${first.tool} (likely extractExcerpt stripped everything as code or the session is pure tool_use).`
|
|
44384
|
+
);
|
|
44385
|
+
}
|
|
44386
|
+
const excerptBlock = excerpts.map((e, i) => ` [turn ${i + 1}] "${e.replace(/\s+/g, " ").trim()}"`).join("\n");
|
|
44387
|
+
const prompt = `Session context: ${promptFacts || "generic coding session"}.
|
|
44383
44388
|
|
|
44384
44389
|
Sampled excerpts from the conversation (already redacted of PII and secrets):
|
|
44385
44390
|
${excerptBlock}
|
|
44386
44391
|
|
|
44387
|
-
Write the SHORTEST keyword-dense paragraph (1-3 sentences, \u2264${ABSTRACT_OUTPUT_MAX_CHARS} chars) naming exactly what was achieved. Lead with an outcome verb. Pack with concrete domain keywords (frameworks, features, components, decisions). Skip narration and filler
|
|
44388
|
-
Write the shortest possible paragraph naming the project + tool + visible action. Skip filler.`;
|
|
44392
|
+
Write the SHORTEST keyword-dense paragraph (1-3 sentences, \u2264${ABSTRACT_OUTPUT_MAX_CHARS} chars) naming exactly what was achieved. Lead with an outcome verb. Pack with concrete domain keywords (frameworks, features, components, decisions). Skip narration and filler.`;
|
|
44389
44393
|
const rawAbstract = await adapters2.summarize({
|
|
44390
44394
|
prompt,
|
|
44391
44395
|
maxTokens: SUMMARISER_MAX_TOKENS
|
|
@@ -47031,6 +47035,26 @@ async function sendHeartbeat() {
|
|
|
47031
47035
|
}
|
|
47032
47036
|
} catch {
|
|
47033
47037
|
}
|
|
47038
|
+
writeLocalStatus(body).catch(() => void 0);
|
|
47039
|
+
}
|
|
47040
|
+
async function writeLocalStatus(snapshot) {
|
|
47041
|
+
const { homedir: homedir9 } = await import("os");
|
|
47042
|
+
const { join: join11 } = await import("path");
|
|
47043
|
+
const { writeFile, mkdir: mkdir2, rename } = await import("fs/promises");
|
|
47044
|
+
if (!lastStatusPath) {
|
|
47045
|
+
const dir = join11(homedir9(), ".modelstat");
|
|
47046
|
+
try {
|
|
47047
|
+
await mkdir2(dir, { recursive: true });
|
|
47048
|
+
} catch {
|
|
47049
|
+
}
|
|
47050
|
+
lastStatusPath = join11(dir, "last-status.json");
|
|
47051
|
+
}
|
|
47052
|
+
const tmp = `${lastStatusPath}.tmp`;
|
|
47053
|
+
try {
|
|
47054
|
+
await writeFile(tmp, JSON.stringify({ ...snapshot, written_at: (/* @__PURE__ */ new Date()).toISOString() }));
|
|
47055
|
+
await rename(tmp, lastStatusPath);
|
|
47056
|
+
} catch {
|
|
47057
|
+
}
|
|
47034
47058
|
}
|
|
47035
47059
|
async function runDiscovery() {
|
|
47036
47060
|
const deviceId = state.deviceId;
|
|
@@ -47174,7 +47198,7 @@ async function runDaemon(opts = {}) {
|
|
|
47174
47198
|
await new Promise(() => {
|
|
47175
47199
|
});
|
|
47176
47200
|
}
|
|
47177
|
-
var import_undici2, AGENT_VERSION2, HEARTBEAT_INTERVAL_MS, SCAN_INTERVAL_MS, status;
|
|
47201
|
+
var import_undici2, AGENT_VERSION2, HEARTBEAT_INTERVAL_MS, SCAN_INTERVAL_MS, status, lastStatusPath;
|
|
47178
47202
|
var init_daemon = __esm({
|
|
47179
47203
|
"src/daemon.ts"() {
|
|
47180
47204
|
"use strict";
|
|
@@ -47214,6 +47238,7 @@ var init_daemon = __esm({
|
|
|
47214
47238
|
stats: {},
|
|
47215
47239
|
lastEventAt: null
|
|
47216
47240
|
};
|
|
47241
|
+
lastStatusPath = null;
|
|
47217
47242
|
}
|
|
47218
47243
|
});
|
|
47219
47244
|
|
|
@@ -47989,15 +48014,34 @@ function fmtTokens(v) {
|
|
|
47989
48014
|
if (n >= 1e3) return `${(n / 1e3).toFixed(0)}K`;
|
|
47990
48015
|
return String(n);
|
|
47991
48016
|
}
|
|
48017
|
+
async function readLocalStatus() {
|
|
48018
|
+
try {
|
|
48019
|
+
const { homedir: homedir9 } = await import("os");
|
|
48020
|
+
const { join: join11 } = await import("path");
|
|
48021
|
+
const { readFile } = await import("fs/promises");
|
|
48022
|
+
const p = join11(homedir9(), ".modelstat", "last-status.json");
|
|
48023
|
+
const txt = await readFile(p, "utf8");
|
|
48024
|
+
return JSON.parse(txt);
|
|
48025
|
+
} catch {
|
|
48026
|
+
return null;
|
|
48027
|
+
}
|
|
48028
|
+
}
|
|
47992
48029
|
async function cmdStats(args) {
|
|
47993
48030
|
const asJson = args.includes("--json");
|
|
47994
48031
|
const claim = state.claimCode;
|
|
48032
|
+
const local = await readLocalStatus();
|
|
47995
48033
|
if (!claim) {
|
|
47996
48034
|
if (asJson) {
|
|
47997
|
-
process.stdout.write(
|
|
47998
|
-
|
|
48035
|
+
process.stdout.write(
|
|
48036
|
+
`${JSON.stringify({
|
|
48037
|
+
paired: false,
|
|
48038
|
+
reason: "no_claim_code",
|
|
48039
|
+
local
|
|
48040
|
+
})}
|
|
48041
|
+
`
|
|
48042
|
+
);
|
|
47999
48043
|
} else {
|
|
48000
|
-
console.log("no claim code on record \u2014 run `modelstat
|
|
48044
|
+
console.log("no claim code on record \u2014 run `npx modelstat@latest` first");
|
|
48001
48045
|
}
|
|
48002
48046
|
return;
|
|
48003
48047
|
}
|
|
@@ -48006,17 +48050,27 @@ async function cmdStats(args) {
|
|
|
48006
48050
|
const dashboard = `${state.apiUrl.replace(/\/$/, "")}/dashboard`;
|
|
48007
48051
|
if (asJson) {
|
|
48008
48052
|
process.stdout.write(
|
|
48009
|
-
`${JSON.stringify({
|
|
48053
|
+
`${JSON.stringify({
|
|
48054
|
+
paired: true,
|
|
48055
|
+
claimed: true,
|
|
48056
|
+
dashboard,
|
|
48057
|
+
local
|
|
48058
|
+
})}
|
|
48010
48059
|
`
|
|
48011
48060
|
);
|
|
48012
48061
|
} else {
|
|
48013
48062
|
console.log("device is claimed \u2014 live stats available at:");
|
|
48014
48063
|
console.log(` ${dashboard}`);
|
|
48064
|
+
if (local) {
|
|
48065
|
+
console.log(`local agent: ${local.status ?? "?"}${local.message ? ` \xB7 ${local.message}` : ""}`);
|
|
48066
|
+
const stats = local.stats ?? {};
|
|
48067
|
+
for (const [k, v] of Object.entries(stats)) console.log(` ${k}: ${v}`);
|
|
48068
|
+
}
|
|
48015
48069
|
}
|
|
48016
48070
|
return;
|
|
48017
48071
|
}
|
|
48018
48072
|
if (asJson) {
|
|
48019
|
-
process.stdout.write(`${JSON.stringify(view)}
|
|
48073
|
+
process.stdout.write(`${JSON.stringify({ ...view, local })}
|
|
48020
48074
|
`);
|
|
48021
48075
|
return;
|
|
48022
48076
|
}
|