@narumitw/pi-caffeinate 0.20.0 → 0.31.0

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/README.md CHANGED
@@ -165,7 +165,8 @@ The default display-awake mode prioritizes uninterrupted long-running Pi work ac
165
165
  ```txt
166
166
  extensions/pi-caffeinate/
167
167
  ├── src/
168
- │ ├── caffeinate.ts # Pi entrypoint and lifecycle orchestration
168
+ │ ├── index.ts # Pi package entrypoint
169
+ │ ├── caffeinate.ts # Extension registration and lifecycle orchestration
169
170
  │ └── *.ts # Package-local inhibitor and settings modules
170
171
  ├── README.md
171
172
  ├── LICENSE
@@ -173,7 +174,7 @@ extensions/pi-caffeinate/
173
174
  └── package.json
174
175
  ```
175
176
 
176
- Only `caffeinate.ts` is a Pi entrypoint; the other source modules are internal.
177
+ `index.ts` is the Pi entrypoint and forwards to `caffeinate.ts`; the other source modules are internal.
177
178
 
178
179
  ## 🔎 Keywords
179
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-caffeinate",
3
- "version": "0.20.0",
3
+ "version": "0.31.0",
4
4
  "description": "Pi extension that keeps the computer awake while the agent is running.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "pi": {
22
22
  "extensions": [
23
- "./src/caffeinate.ts"
23
+ "./src/index.ts"
24
24
  ]
25
25
  },
26
26
  "scripts": {
@@ -29,8 +29,8 @@
29
29
  "typecheck": "tsc --noEmit"
30
30
  },
31
31
  "devDependencies": {
32
- "@biomejs/biome": "2.5.3",
33
- "@earendil-works/pi-coding-agent": "0.80.10",
32
+ "@biomejs/biome": "2.5.5",
33
+ "@earendil-works/pi-coding-agent": "0.82.1",
34
34
  "@types/node": "26.1.1",
35
35
  "typescript": "7.0.2"
36
36
  },
package/src/caffeinate.ts CHANGED
@@ -1,25 +1,13 @@
1
1
  import type { ChildProcess } from "node:child_process";
2
2
  import process from "node:process";
3
- import { startInhibitorProcess, stopInhibitorProcess } from "./inhibitor-process.js";
4
- import {
5
- formatMode,
6
- getInhibitorCommand,
7
- type InhibitorCommand,
8
- splitCommand,
9
- windowsInhibitorScript,
10
- } from "./inhibitors.js";
11
- import {
12
- type CaffeinateMode,
13
- loadSettings,
14
- normalizeCaffeinateSettings,
15
- saveSettings,
16
- settingsFilePath,
17
- } from "./settings.js";
18
3
  import type {
19
4
  ExtensionAPI,
20
5
  ExtensionCommandContext,
21
6
  ExtensionContext,
22
7
  } from "@earendil-works/pi-coding-agent";
8
+ import { startInhibitorProcess, stopInhibitorProcess } from "./inhibitor-process.js";
9
+ import { formatMode, getInhibitorCommand, type InhibitorCommand } from "./inhibitors.js";
10
+ import { type CaffeinateMode, loadSettings, saveSettings, settingsFilePath } from "./settings.js";
23
11
 
24
12
  const STATUS_KEY = "caffeinate";
25
13
  const DISABLED_VALUES = new Set(["1", "true", "yes", "on"]);
@@ -110,7 +98,6 @@ export default function caffeinate(pi: ExtensionAPI) {
110
98
  await handleCaffeinateCommand(args, ctx);
111
99
  },
112
100
  });
113
-
114
101
  }
115
102
 
116
103
  async function handleCaffeinateCommand(args: string, ctx: CommandContext) {
@@ -380,7 +367,9 @@ function describeState() {
380
367
  return lines.join("\n");
381
368
  }
382
369
 
383
- lines.unshift("pi-caffeinate is idle and will keep the computer awake during the next agent run.");
370
+ lines.unshift(
371
+ "pi-caffeinate is idle and will keep the computer awake during the next agent run.",
372
+ );
384
373
  return lines.join("\n");
385
374
  }
386
375
 
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./caffeinate.js";
package/src/inhibitors.ts CHANGED
@@ -18,7 +18,11 @@ export function getInhibitorCommand(mode: CaffeinateMode): InhibitorCommand | un
18
18
  if (command) return { command, args, description: `custom command (${command})`, custom: true };
19
19
  }
20
20
  if (process.platform === "darwin") {
21
- return parentBoundUnixCommand("caffeinate", macCaffeinateArgs(mode), caffeinateDescription(mode));
21
+ return parentBoundUnixCommand(
22
+ "caffeinate",
23
+ macCaffeinateArgs(mode),
24
+ caffeinateDescription(mode),
25
+ );
22
26
  }
23
27
  if (process.platform === "linux") {
24
28
  if (isWsl() && commandExists("powershell.exe")) {
@@ -40,7 +44,11 @@ export function getInhibitorCommand(mode: CaffeinateMode): InhibitorCommand | un
40
44
  );
41
45
  }
42
46
  if (commandExists("caffeinate")) {
43
- return parentBoundUnixCommand("caffeinate", macCaffeinateArgs(mode), caffeinateDescription(mode));
47
+ return parentBoundUnixCommand(
48
+ "caffeinate",
49
+ macCaffeinateArgs(mode),
50
+ caffeinateDescription(mode),
51
+ );
44
52
  }
45
53
  }
46
54
  if (process.platform === "win32") return windowsPowerInhibitorCommand("powershell.exe", mode);
@@ -55,10 +63,21 @@ function caffeinateDescription(mode: CaffeinateMode) {
55
63
  return `caffeinate (${formatMode(mode)})`;
56
64
  }
57
65
 
58
- function parentBoundUnixCommand(command: string, args: string[], description: string): InhibitorCommand {
66
+ function parentBoundUnixCommand(
67
+ command: string,
68
+ args: string[],
69
+ description: string,
70
+ ): InhibitorCommand {
59
71
  return {
60
72
  command: "sh",
61
- args: ["-c", unixParentBoundScript(), "pi-caffeinate-watch", String(process.pid), command, ...args],
73
+ args: [
74
+ "-c",
75
+ unixParentBoundScript(),
76
+ "pi-caffeinate-watch",
77
+ String(process.pid),
78
+ command,
79
+ ...args,
80
+ ],
62
81
  description,
63
82
  };
64
83
  }
package/src/settings.ts CHANGED
@@ -116,7 +116,11 @@ export function normalizeCaffeinateSettings(value: unknown): CaffeinateSettings
116
116
  if (!isCaffeinateMode(settings.mode)) return undefined;
117
117
  if (settings.quiet !== undefined && typeof settings.quiet !== "boolean") return undefined;
118
118
  if (settings.updatedAt !== undefined && typeof settings.updatedAt !== "number") return undefined;
119
- return { mode: settings.mode, quiet: settings.quiet ?? false, updatedAt: settings.updatedAt ?? 0 };
119
+ return {
120
+ mode: settings.mode,
121
+ quiet: settings.quiet ?? false,
122
+ updatedAt: settings.updatedAt ?? 0,
123
+ };
120
124
  }
121
125
 
122
126
  function isCaffeinateMode(value: unknown): value is CaffeinateMode {