@narumitw/pi-caffeinate 0.28.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/package.json +3 -3
- package/src/caffeinate.ts +6 -17
- package/src/inhibitors.ts +23 -4
- package/src/settings.ts +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-caffeinate",
|
|
3
|
-
"version": "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",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"typecheck": "tsc --noEmit"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@biomejs/biome": "2.5.
|
|
33
|
-
"@earendil-works/pi-coding-agent": "0.
|
|
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(
|
|
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/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(
|
|
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(
|
|
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(
|
|
66
|
+
function parentBoundUnixCommand(
|
|
67
|
+
command: string,
|
|
68
|
+
args: string[],
|
|
69
|
+
description: string,
|
|
70
|
+
): InhibitorCommand {
|
|
59
71
|
return {
|
|
60
72
|
command: "sh",
|
|
61
|
-
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 {
|
|
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 {
|