token-stats-timer 1.0.3 → 1.0.4

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/notify.ts +16 -17
  2. package/package.json +1 -1
package/notify.ts CHANGED
@@ -75,11 +75,6 @@ function truncate(s: string, max = 80): string {
75
75
  return s.length > max ? s.slice(0, max) + "…" : s;
76
76
  }
77
77
 
78
- function cwdName(): string {
79
- const parts = process.cwd().split("/").filter(Boolean);
80
- return parts.pop() || process.cwd();
81
- }
82
-
83
78
  export function createNotifier(pi: ExtensionAPI): void {
84
79
  let config: NotifyConfig = loadConfig();
85
80
 
@@ -147,18 +142,22 @@ export function createNotifier(pi: ExtensionAPI): void {
147
142
 
148
143
  const dur = startMs !== undefined ? ` · ${formatDuration(durationMs)}` : "";
149
144
 
150
- if (runFailed && config.onFailure) {
151
- notify(
152
- "❌ pi 执行失败",
153
- `耗时:${dur}\n${truncate(runErrorMsg || "未知错误")}`,
154
- config.sound,
155
- );
156
- } else if (runAborted && config.onAbort) {
157
- notify(
158
- "⏹ pi 已中止",
159
- `耗时:${dur}\n${truncate(runErrorMsg || "执行被中止")}`,
160
- config.sound,
161
- );
145
+ if (runFailed) {
146
+ if (config.onFailure) {
147
+ notify(
148
+ "❌ pi 执行失败",
149
+ `耗时:${dur}\n${truncate(runErrorMsg || "未知错误")}`,
150
+ config.sound,
151
+ );
152
+ }
153
+ } else if (runAborted) {
154
+ if (config.onAbort) {
155
+ notify(
156
+ "⏹ pi 已中止",
157
+ `耗时:${dur}\n${truncate(runErrorMsg || "执行被中止")}`,
158
+ config.sound,
159
+ );
160
+ }
162
161
  } else if (config.onSuccess) {
163
162
  notify(
164
163
  "✅ pi 执行完成",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "token-stats-timer",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "pi extension to display token usage and time spend.",
5
5
  "keywords": [
6
6
  "pi-package",