@narumitw/pi-caffeinate 0.5.0 → 0.6.1

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
@@ -16,7 +16,7 @@ It is designed for long-running coding, refactoring, debugging, web research, an
16
16
  - Provides a single `/caffeinate` command with menu-based controls and direct subcommands.
17
17
  - Persists the selected keep-awake mode in a small JSON settings file.
18
18
  - Allows a custom inhibitor command through environment configuration.
19
- - Allows a custom status icon through environment configuration.
19
+ - Emits plain status text; `@narumitw/pi-statusline` can add or suppress the status icon from JSON config.
20
20
  - Fails safely when no supported inhibitor is available.
21
21
 
22
22
  ## 📦 Install
@@ -128,17 +128,23 @@ PI_CAFFEINATE_COMMAND='systemd-inhibit --what=idle:sleep --why="pi running" --mo
128
128
 
129
129
  The custom command is parsed with shell-like quoting and is run directly without a shell. `PI_CAFFEINATE_COMMAND` takes precedence over the saved mode; `/caffeinate status` reports when a custom command is active.
130
130
 
131
- Customise the status bar icon (default: `💊`):
131
+ Deprecated: `PI_CAFFEINATE_ICON` still works for now. If you use `@narumitw/pi-statusline`, move the icon to `${PI_CODING_AGENT_DIR:-~/.pi/agent}/pi-statusline-settings.json`:
132
132
 
133
- ```bash
134
- PI_CAFFEINATE_ICON='☕️' pi
133
+ ```json
134
+ {
135
+ "extensionStatusIcons": {
136
+ "caffeinate": "☕️"
137
+ }
138
+ }
135
139
  ```
136
140
 
141
+ Without `@narumitw/pi-statusline`, keep using `PI_CAFFEINATE_ICON` during the compatibility window. In `pi-statusline-settings.json`, use an empty string to show the caffeinate status without an icon.
142
+
137
143
  ## 🧠 Why use pi-caffeinate?
138
144
 
139
145
  AI coding agents often run tool-heavy tasks that take several minutes. `pi-caffeinate` keeps your machine awake during active Pi work, helping browser automation, local builds, test runs, code generation, and long prompts finish reliably.
140
146
 
141
- The default display-awake mode prioritizes uninterrupted long-running Pi work across platforms, including Linux desktops that require idle inhibition to prevent automatic suspend. Use sleep-only mode when you prefer normal screen power saving and your system does not need idle inhibition to keep Pi running.
147
+ The default display-awake mode prioritizes uninterrupted long-running Pi work across platforms, including Linux desktops that require idle inhibition to prevent automatic suspend. Use `/caffeinate sleep` (shown as `system-awake` in status output) when you prefer normal screen power saving and your system does not need idle inhibition to keep Pi running.
142
148
 
143
149
  ## 🗂️ Package layout
144
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@narumitw/pi-caffeinate",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Pi extension that keeps the computer awake while the agent is running.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/caffeinate.ts CHANGED
@@ -61,6 +61,7 @@ interface CaffeinateState {
61
61
  mode: CaffeinateMode;
62
62
  settingsLoaded: boolean;
63
63
  settingsError?: string;
64
+ iconWarningShown: boolean;
64
65
  }
65
66
 
66
67
  interface CaffeinateSettings {
@@ -74,10 +75,13 @@ const state: CaffeinateState = {
74
75
  disabled: isDisabled(),
75
76
  mode: DEFAULT_MODE,
76
77
  settingsLoaded: false,
78
+ iconWarningShown: false,
77
79
  };
78
80
 
79
81
  export default function caffeinate(pi: ExtensionAPI) {
80
82
  pi.on("session_start", async (_event, ctx) => {
83
+ state.iconWarningShown = false;
84
+ warnDeprecatedIcon(ctx);
81
85
  await loadSettingsIntoState(ctx);
82
86
  updateStatus(ctx);
83
87
  });
@@ -315,7 +319,7 @@ function startInhibitor(ctx: ExtensionContext) {
315
319
  updateStatus(ctx);
316
320
  });
317
321
 
318
- ctx.ui.notify(`Keeping computer awake with ${command.description}.`, "info");
322
+ ctx.ui.notify(`Keeping computer awake (${statusModeLabel()}).`, "info");
319
323
  updateStatus(ctx);
320
324
  } catch (error) {
321
325
  state.process = undefined;
@@ -527,12 +531,12 @@ function updateStatus(ctx: ExtensionContext) {
527
531
  }
528
532
 
529
533
  if (state.process) {
530
- ctx.ui.setStatus(STATUS_KEY, `${getIcon()} ${statusModeLabel()}`);
534
+ ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon(statusModeLabel()));
531
535
  return;
532
536
  }
533
537
 
534
538
  if (!state.available) {
535
- ctx.ui.setStatus(STATUS_KEY, `${getIcon()} unavailable`);
539
+ ctx.ui.setStatus(STATUS_KEY, withDeprecatedIcon("unavailable"));
536
540
  return;
537
541
  }
538
542
 
@@ -576,11 +580,11 @@ function statusLevel() {
576
580
 
577
581
  function statusModeLabel() {
578
582
  if (state.command?.custom) return "custom";
579
- return state.mode === "sleep" ? "sleep" : "display";
583
+ return formatMode(state.mode);
580
584
  }
581
585
 
582
586
  export function formatMode(mode: CaffeinateMode) {
583
- return mode === "sleep" ? "sleep-only" : "display-awake";
587
+ return mode === "sleep" ? "system-awake" : "display-awake";
584
588
  }
585
589
 
586
590
  async function ensureSettingsLoaded(ctx: ExtensionContext) {
@@ -683,6 +687,16 @@ function hasCustomCommand() {
683
687
  return Boolean(process.env.PI_CAFFEINATE_COMMAND?.trim());
684
688
  }
685
689
 
686
- function getIcon() {
687
- return process.env.PI_CAFFEINATE_ICON?.trim() ?? "💊";
690
+ function withDeprecatedIcon(text: string) {
691
+ const icon = process.env.PI_CAFFEINATE_ICON?.trim();
692
+ return icon ? `${icon} ${text}` : text;
693
+ }
694
+
695
+ function warnDeprecatedIcon(ctx: ExtensionContext) {
696
+ if (state.iconWarningShown || !process.env.PI_CAFFEINATE_ICON?.trim()) return;
697
+ state.iconWarningShown = true;
698
+ ctx.ui.notify(
699
+ "PI_CAFFEINATE_ICON is deprecated but still works for now. If you use @narumitw/pi-statusline, move it to pi-statusline-settings.json (extensionStatusIcons.caffeinate).",
700
+ "warning",
701
+ );
688
702
  }