nairon-bench 0.0.29 → 0.0.30

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.
Files changed (2) hide show
  1. package/dist/index.js +123 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14894,7 +14894,128 @@ function parseClaudeTranscript(filePath, fileName) {
14894
14894
  };
14895
14895
  }
14896
14896
  function collectOpenCodeSessions2(openCodeDir, since, until) {
14897
- return [];
14897
+ const sessions = [];
14898
+ const sessionDir = join7(openCodeDir, "storage", "session");
14899
+ const messageDir = join7(openCodeDir, "storage", "message");
14900
+ const partDir = join7(openCodeDir, "storage", "part");
14901
+ if (!existsSync7(sessionDir))
14902
+ return sessions;
14903
+ try {
14904
+ const projectDirs = readdirSync3(sessionDir, { withFileTypes: true }).filter((d2) => d2.isDirectory()).map((d2) => join7(sessionDir, d2.name));
14905
+ for (const projectDir of projectDirs) {
14906
+ const sessionFiles = readdirSync3(projectDir).filter((f3) => f3.endsWith(".json"));
14907
+ for (const sessionFile of sessionFiles) {
14908
+ try {
14909
+ const sessionPath = join7(projectDir, sessionFile);
14910
+ const sessionData = JSON.parse(readFileSync6(sessionPath, "utf-8"));
14911
+ const createdAt = new Date(sessionData.time?.created || 0);
14912
+ const updatedAt = new Date(sessionData.time?.updated || sessionData.time?.created || 0);
14913
+ if (updatedAt < since || createdAt > until)
14914
+ continue;
14915
+ const sessionId = sessionData.id;
14916
+ const sessionMsgDir = join7(messageDir, sessionId);
14917
+ const prompts = [];
14918
+ const responses = [];
14919
+ const toolsUsed = new Set;
14920
+ const filesModified = new Set;
14921
+ let totalTokens = 0;
14922
+ let inputTokens = 0;
14923
+ let outputTokens = 0;
14924
+ let model = "unknown";
14925
+ let startTime = createdAt;
14926
+ let endTime = updatedAt;
14927
+ if (existsSync7(sessionMsgDir)) {
14928
+ const msgFiles = readdirSync3(sessionMsgDir).filter((f3) => f3.endsWith(".json")).sort();
14929
+ for (const msgFile of msgFiles) {
14930
+ try {
14931
+ const msgPath = join7(sessionMsgDir, msgFile);
14932
+ const msgData = JSON.parse(readFileSync6(msgPath, "utf-8"));
14933
+ const msgId = msgData.id;
14934
+ if (msgData.model?.modelID) {
14935
+ model = msgData.model.modelID;
14936
+ }
14937
+ const msgTime = new Date(msgData.time?.created || createdAt);
14938
+ if (msgTime < startTime)
14939
+ startTime = msgTime;
14940
+ if (msgTime > endTime)
14941
+ endTime = msgTime;
14942
+ const msgPartDir = join7(partDir, msgId);
14943
+ let messageText = "";
14944
+ if (existsSync7(msgPartDir)) {
14945
+ const partFiles = readdirSync3(msgPartDir).filter((f3) => f3.endsWith(".json")).sort();
14946
+ for (const partFile of partFiles) {
14947
+ try {
14948
+ const partPath = join7(msgPartDir, partFile);
14949
+ const partData = JSON.parse(readFileSync6(partPath, "utf-8"));
14950
+ if (partData.type === "text" && partData.text && !partData.synthetic) {
14951
+ messageText += partData.text + `
14952
+ `;
14953
+ }
14954
+ if (partData.type === "tool-invocation" || partData.type === "tool-result") {
14955
+ const toolName = partData.toolName || partData.name;
14956
+ if (toolName)
14957
+ toolsUsed.add(toolName);
14958
+ }
14959
+ } catch {}
14960
+ }
14961
+ }
14962
+ if (msgData.role === "user" && messageText.trim()) {
14963
+ const prompt2 = analyzePrompt(messageText, sessionId, prompts.length, msgTime);
14964
+ prompts.push(prompt2);
14965
+ }
14966
+ if (msgData.role === "assistant" && messageText.trim()) {
14967
+ const response = analyzeResponse(messageText, sessionId, responses.length, prompts[prompts.length - 1]?.id ?? "", msgTime);
14968
+ responses.push(response);
14969
+ if (messageText.includes("Write ") || messageText.includes("Created ")) {
14970
+ const fileMatches = messageText.match(/(?:Write|Created|Updated)\s+(\S+\.\w+)/g);
14971
+ if (fileMatches) {
14972
+ fileMatches.forEach((m2) => {
14973
+ const file = m2.split(/\s+/)[1];
14974
+ if (file)
14975
+ filesModified.add(file);
14976
+ });
14977
+ }
14978
+ }
14979
+ }
14980
+ if (msgData.usage) {
14981
+ totalTokens += msgData.usage.totalTokens || 0;
14982
+ inputTokens += msgData.usage.inputTokens || 0;
14983
+ outputTokens += msgData.usage.outputTokens || 0;
14984
+ }
14985
+ } catch {}
14986
+ }
14987
+ }
14988
+ if (prompts.length === 0)
14989
+ continue;
14990
+ const correctionCount = prompts.filter((p) => p.isCorrection).length;
14991
+ const frustrationCount = prompts.filter((p) => p.isFrustrated).length;
14992
+ if (sessionData.summary?.files) {
14993
+ filesModified.add(`${sessionData.summary.files} files changed`);
14994
+ }
14995
+ sessions.push({
14996
+ id: sessionId,
14997
+ agent: "opencode",
14998
+ model,
14999
+ startTime,
15000
+ endTime,
15001
+ durationMinutes: Math.round((endTime.getTime() - startTime.getTime()) / 60000),
15002
+ promptCount: prompts.length,
15003
+ totalTokens,
15004
+ inputTokens,
15005
+ outputTokens,
15006
+ prompts,
15007
+ responses,
15008
+ toolsUsed: Array.from(toolsUsed),
15009
+ filesModified: Array.from(filesModified),
15010
+ hadCompaction: false,
15011
+ correctionCount,
15012
+ frustrationCount
15013
+ });
15014
+ } catch {}
15015
+ }
15016
+ }
15017
+ } catch {}
15018
+ return sessions;
14898
15019
  }
14899
15020
  function analyzePrompt(text, sessionId, index, timestamp) {
14900
15021
  const lower = text.toLowerCase();
@@ -22876,7 +22997,7 @@ var setupCommand = defineCommand2({
22876
22997
  // package.json
22877
22998
  var package_default = {
22878
22999
  name: "nairon-bench",
22879
- version: "0.0.29",
23000
+ version: "0.0.30",
22880
23001
  description: "AI workflow benchmarking CLI",
22881
23002
  type: "module",
22882
23003
  bin: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nairon-bench",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "description": "AI workflow benchmarking CLI",
5
5
  "type": "module",
6
6
  "bin": {