@yhong91/vibetime 0.1.15 → 0.1.16

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/bin/vibetime.mjs +44 -25
  2. package/package.json +1 -1
package/bin/vibetime.mjs CHANGED
@@ -1195,7 +1195,7 @@ function countTextLines(text) {
1195
1195
  }
1196
1196
 
1197
1197
  // src/lib/constants.ts
1198
- var PACKAGE_VERSION = true ? "0.1.15" : "0.1.1";
1198
+ var PACKAGE_VERSION = true ? "0.1.16" : "0.1.1";
1199
1199
  var DEFAULT_API_URL = "http://121.196.224.82:3001";
1200
1200
  var DEFAULT_BACKFILL_BATCH_SIZE = 50;
1201
1201
  var DEFAULT_BACKFILL_BATCH_BYTES = 800 * 1024;
@@ -1683,25 +1683,40 @@ function resolveModelName(text) {
1683
1683
  }
1684
1684
  var AGY_USAGE_TIME_MATCH_TOLERANCE_MS = 5 * 60 * 1e3;
1685
1685
  var AGY_RESPONSE_MODEL_ALIASES = {
1686
- "gemini-3-flash-a": "Gemini 3.5 Flash (Medium)",
1687
- "gemini-3-flash-b": "Gemini 3.5 Flash (High)",
1688
- "claude-sonnet-4-6": "Claude Sonnet 4.6 (Thinking)",
1689
- "claude-opus-4-6-thinking": "Claude Opus 4.6 (Thinking)"
1686
+ "gemini-3-flash-a": "Gemini 3.5 Flash",
1687
+ "gemini-3-flash-b": "Gemini 3.5 Flash",
1688
+ "claude-sonnet-4-6": "Claude Sonnet 4.6",
1689
+ "claude-opus-4-6-thinking": "Claude Opus 4.6"
1690
1690
  };
1691
+ var AGY_TIER_PATTERN = /\s*\((Medium|High|Thinking)\)\s*$/i;
1691
1692
  function usageMetadataFromGenerator(item) {
1692
1693
  const usage = item.chatModel?.usage;
1693
1694
  if (!usage) {
1694
1695
  return null;
1695
1696
  }
1696
1697
  const chatModel = item.chatModel;
1697
- const modelDisplayName = typeof chatModel.modelDisplayName === "string" && !chatModel.modelDisplayName.startsWith("MODEL_PLACEHOLDER_") ? chatModel.modelDisplayName : null;
1698
+ const rawDisplayName = typeof chatModel.modelDisplayName === "string" && !chatModel.modelDisplayName.startsWith("MODEL_PLACEHOLDER_") ? chatModel.modelDisplayName : null;
1698
1699
  const responseModel = typeof chatModel.responseModel === "string" && !chatModel.responseModel.startsWith("MODEL_PLACEHOLDER_") ? AGY_RESPONSE_MODEL_ALIASES[chatModel.responseModel] ?? chatModel.responseModel : null;
1699
- const model = modelDisplayName ?? responseModel ?? null;
1700
+ let model = null;
1701
+ let reasoningEffort;
1702
+ if (rawDisplayName) {
1703
+ const tierMatch = rawDisplayName.match(AGY_TIER_PATTERN);
1704
+ if (tierMatch) {
1705
+ model = rawDisplayName.replace(AGY_TIER_PATTERN, "").trim();
1706
+ const tier = tierMatch[1].toLowerCase();
1707
+ reasoningEffort = tier === "thinking" ? "default" : tier;
1708
+ } else {
1709
+ model = rawDisplayName;
1710
+ }
1711
+ } else if (responseModel) {
1712
+ model = responseModel;
1713
+ }
1700
1714
  const occurredAt = Date.parse(chatModel.chatStartMetadata?.createdAt ?? "");
1701
1715
  return {
1702
1716
  usage,
1703
1717
  model,
1704
- occurredAt: Number.isFinite(occurredAt) ? occurredAt : null
1718
+ occurredAt: Number.isFinite(occurredAt) ? occurredAt : null,
1719
+ reasoningEffort
1705
1720
  };
1706
1721
  }
1707
1722
  async function readAgyModelSetting(filePath) {
@@ -1712,7 +1727,8 @@ async function readAgyModelSetting(filePath) {
1712
1727
  stat2(settingsPath)
1713
1728
  ]);
1714
1729
  const configured = JSON.parse(text)?.model;
1715
- const model = typeof configured === "string" ? configured : null;
1730
+ const rawModel = typeof configured === "string" ? configured : null;
1731
+ const model = rawModel ? rawModel.replace(AGY_TIER_PATTERN, "").trim() : null;
1716
1732
  return model ? { model, changedAt: info.mtimeMs } : null;
1717
1733
  } catch {
1718
1734
  return null;
@@ -1938,7 +1954,8 @@ async function parseAgySessionFile(filePath, options) {
1938
1954
  tokensTotal: inputTokens + cacheRead + outputTokens,
1939
1955
  tokensCachedInput: cacheRead || void 0,
1940
1956
  tokensCacheReadInput: cacheRead || void 0,
1941
- tokensReasoningOutput: reasoning || void 0
1957
+ tokensReasoningOutput: reasoning || void 0,
1958
+ reasoningEffort: usageMetadata.reasoningEffort
1942
1959
  }
1943
1960
  }), lineNumber, raw.type);
1944
1961
  } else {
@@ -2101,7 +2118,8 @@ async function parseAgySessionFile(filePath, options) {
2101
2118
  tokensTotal: inputTokens + cacheRead + outputTokens,
2102
2119
  tokensCachedInput: cacheRead || void 0,
2103
2120
  tokensCacheReadInput: cacheRead || void 0,
2104
- tokensReasoningOutput: reasoning || void 0
2121
+ tokensReasoningOutput: reasoning || void 0,
2122
+ reasoningEffort: usageMetadata.reasoningEffort
2105
2123
  }
2106
2124
  }), rawEvents.length + index + 1, "trajectory_metadata");
2107
2125
  }
@@ -5090,8 +5108,9 @@ function opencodePluginContent() {
5090
5108
 
5091
5109
  export const AgentTime = async ({ $, directory }) => {
5092
5110
  const report = async (payload) => {
5111
+ const json = JSON.stringify(payload)
5093
5112
  try {
5094
- await $\`vibetime hook --agent opencode\`.stdin(JSON.stringify(payload)).quiet()
5113
+ await $\`echo \${json} | vibetime hook --agent opencode\`
5095
5114
  } catch {}
5096
5115
  }
5097
5116
 
@@ -5100,11 +5119,12 @@ export const AgentTime = async ({ $, directory }) => {
5100
5119
  const type = event?.type
5101
5120
  const props = event?.properties || {}
5102
5121
 
5103
- if (type === "session.created") {
5122
+ if (type === "session.updated") {
5123
+ const info = props.info || {}
5104
5124
  await report({
5105
5125
  hook_event_name: "SessionStart",
5106
- session_id: event?.sessionID || event?.sessionId || props?.session?.id || event?.id,
5107
- cwd: directory
5126
+ session_id: props.sessionID || info.id || event?.id,
5127
+ cwd: info.directory || directory
5108
5128
  })
5109
5129
  return
5110
5130
  }
@@ -5112,25 +5132,24 @@ export const AgentTime = async ({ $, directory }) => {
5112
5132
  if (type === "session.idle") {
5113
5133
  await report({
5114
5134
  hook_event_name: "SessionEnd",
5115
- session_id: event?.sessionID || event?.sessionId || props?.session?.id || event?.id,
5135
+ session_id: props.sessionID || event?.id,
5116
5136
  cwd: directory
5117
5137
  })
5118
5138
  return
5119
5139
  }
5120
5140
 
5121
- if (type === "tool.execute.after") {
5122
- const toolName = props?.tool || event?.tool || "unknown"
5123
- const toolCallId = props?.toolCallId || event?.toolCallId
5124
- const toolInput = props?.args || props?.input || {}
5125
- const command = toolInput?.command
5126
- const filePath = toolInput?.file_path || toolInput?.filePath
5141
+ if (type === "message.part.updated") {
5142
+ const part = props.part || {}
5143
+ if (part.type !== "tool") return
5144
+ const state = part.state || {}
5145
+ if (state.status !== "completed") return
5127
5146
 
5128
5147
  await report({
5129
5148
  hook_event_name: "PostToolUse",
5130
- tool_name: toolName,
5131
- tool_use_id: toolCallId,
5149
+ tool_name: part.tool || "unknown",
5150
+ tool_use_id: part.callID || part.id,
5132
5151
  cwd: directory,
5133
- tool_input: { command, file_path: filePath }
5152
+ tool_input: {}
5134
5153
  })
5135
5154
  }
5136
5155
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yhong91/vibetime",
3
3
  "type": "module",
4
- "version": "0.1.15",
4
+ "version": "0.1.16",
5
5
  "description": "vibetime CLI — install AI-agent hooks (Claude Code, Codex, OpenCode, Pi) and report activity to vibetime.",
6
6
  "license": "MIT",
7
7
  "publishConfig": {