@devvoid/voidshift-awake 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +94 -2
- package/dist/decide.d.ts +24 -0
- package/dist/decide.js +20 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +145 -0
- package/dist/parse.d.ts +8 -0
- package/dist/parse.js +27 -0
- package/dist/state.d.ts +7 -0
- package/dist/state.js +17 -0
- package/dist/system.d.ts +15 -0
- package/dist/system.js +108 -0
- package/dist/time.d.ts +2 -0
- package/dist/time.js +37 -0
- package/dist/types.d.ts +47 -0
- package/dist/types.js +3 -0
- package/package.json +49 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# VoidShift
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One CLI for the Void dev tools. Install it once, run `voidshift`, pick the
|
|
4
|
+
tools you want, and it sets each one up with good defaults you can change.
|
|
5
|
+
|
|
6
|
+
> Early release. macOS only for now; Windows and Linux are next.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm i -g @devvoid/voidshift
|
|
10
|
+
voidshift # pick tools and set them up
|
|
11
|
+
voidshift --defaults # take every default, ask only what has none
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Tools
|
|
15
|
+
|
|
16
|
+
| Tool | What it does |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `awake` | Keeps your Mac running, on battery and with the lid closed, and puts sleep back when the battery runs low, the Mac gets hot, a timer ends or it restarts |
|
|
19
|
+
| `agents` | Agents for Claude Code and Codex, and workflows that run them in the background off your Linear cards |
|
|
20
|
+
|
|
21
|
+
Memory, a markdown vault recalled into Claude Code and Codex, is coming.
|
|
22
|
+
|
|
23
|
+
### awake
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
voidshift awake on [--until 7am | --for 6h] [--battery 20]
|
|
27
|
+
voidshift awake status
|
|
28
|
+
voidshift awake off
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Setup asks for your Mac password once to add a rule that allows only
|
|
32
|
+
`pmset -a disablesleep 0|1`. A small watchdog checks every minute and turns
|
|
33
|
+
sleep back on when it should. Keep a closed Mac out of a bag: with no airflow
|
|
34
|
+
it runs hot.
|
|
35
|
+
|
|
36
|
+
### agents
|
|
37
|
+
|
|
38
|
+
Five agents, installed into Claude Code (and Codex if you use it):
|
|
39
|
+
|
|
40
|
+
| Agent | What it does |
|
|
41
|
+
|---|---|
|
|
42
|
+
| Plan | plans a Linear card against the code |
|
|
43
|
+
| Plan review | checks a plan before it is published |
|
|
44
|
+
| Publish | posts the plan to the card and hands it over |
|
|
45
|
+
| Dev | implements the plan and opens a draft PR |
|
|
46
|
+
| QA | CI, then code review, then a usability check in a headless browser |
|
|
47
|
+
|
|
48
|
+
Use them yourself (`/vs-plan ENG-123` in Claude Code), or let a **workflow**
|
|
49
|
+
run them. A workflow starts when one of your Linear cards gets a label, runs
|
|
50
|
+
agents in order in a project (a repo on your Mac), and sends work back to the
|
|
51
|
+
step that made it when a check fails:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
when ENG + vs-plan: Dev → QA in tether-relay
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The runner checks Linear every minute, works in its own copy of the repo so
|
|
58
|
+
your checkout is never touched, and labels the card as it goes (`vs-dev-v1`,
|
|
59
|
+
`vs-qa-v1`, then `vs-qa-verified` or `vs-parked` with a comment saying why).
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
voidshift agents status # workflows, projects, runner
|
|
63
|
+
voidshift agents run ENG-123 # run one card now, in this terminal
|
|
64
|
+
voidshift agents start | stop # the background runner
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## What to know
|
|
68
|
+
|
|
69
|
+
- **Your own logins.** Agents run the official `claude` and `codex` CLIs you
|
|
70
|
+
already use, signed in with your own account. VoidShift never reads or
|
|
71
|
+
stores those credentials. The Linear API key for the runner lives in your
|
|
72
|
+
macOS Keychain.
|
|
73
|
+
- **Trust.** The Dev agent can run shell commands inside its copy of the repo
|
|
74
|
+
so it can install and test. Review its pull requests like any other.
|
|
75
|
+
- **Your config** lives in `~/.config/voidshift`.
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
voidshift doctor # check everything is set up
|
|
79
|
+
voidshift tools # list tools
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
pnpm install
|
|
86
|
+
pnpm test
|
|
87
|
+
node packages/cli/src/main.ts
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Node 22.18 or newer runs the TypeScript sources directly. Releases are cut by
|
|
91
|
+
pushing a `v*` tag; CI publishes every package at that version.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
package/dist/decide.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Battery } from './parse.ts';
|
|
2
|
+
export interface AwakeState {
|
|
3
|
+
managed: boolean;
|
|
4
|
+
since?: string;
|
|
5
|
+
until?: string;
|
|
6
|
+
batteryFloor: number;
|
|
7
|
+
lastReason?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SystemReading {
|
|
10
|
+
sleepDisabled: boolean;
|
|
11
|
+
battery: Battery;
|
|
12
|
+
thermalSerious: boolean;
|
|
13
|
+
bootTime: Date | null;
|
|
14
|
+
}
|
|
15
|
+
export type Decision = {
|
|
16
|
+
action: 'keep';
|
|
17
|
+
} | {
|
|
18
|
+
action: 'revert';
|
|
19
|
+
reason: string;
|
|
20
|
+
} | {
|
|
21
|
+
action: 'forget';
|
|
22
|
+
reason: string;
|
|
23
|
+
};
|
|
24
|
+
export declare function decide(state: AwakeState, sys: SystemReading, now: Date): Decision;
|
package/dist/decide.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// What the watchdog should do on each tick. 'revert' turns sleep back on;
|
|
2
|
+
// 'forget' clears our state when someone else already turned sleep back on.
|
|
3
|
+
export function decide(state, sys, now) {
|
|
4
|
+
if (!state.managed)
|
|
5
|
+
return { action: 'keep' };
|
|
6
|
+
if (!sys.sleepDisabled)
|
|
7
|
+
return { action: 'forget', reason: 'sleep was turned back on outside voidshift' };
|
|
8
|
+
const since = state.since ? new Date(state.since) : null;
|
|
9
|
+
if (since && sys.bootTime && sys.bootTime > since)
|
|
10
|
+
return { action: 'revert', reason: 'the Mac restarted' };
|
|
11
|
+
if (state.until && now >= new Date(state.until))
|
|
12
|
+
return { action: 'revert', reason: 'the timer ended' };
|
|
13
|
+
const { onBattery, percent } = sys.battery;
|
|
14
|
+
if (onBattery && percent !== null && percent <= state.batteryFloor) {
|
|
15
|
+
return { action: 'revert', reason: `battery reached ${percent}%` };
|
|
16
|
+
}
|
|
17
|
+
if (sys.thermalSerious)
|
|
18
|
+
return { action: 'revert', reason: 'the Mac is running too hot' };
|
|
19
|
+
return { action: 'keep' };
|
|
20
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { rmSync } from 'node:fs';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { decide } from "./decide.js";
|
|
4
|
+
import { logPath, readState, stateDir, writeState } from "./state.js";
|
|
5
|
+
import { SUDOERS_PATH, installSudoers, loadWatchdog, readSystem, removeSudoers, ruleInstalled, ruleWorks, setSleepDisabled, unloadWatchdog, watchdogLoaded, } from "./system.js";
|
|
6
|
+
import { parseFor, parseUntil } from "./time.js";
|
|
7
|
+
const clock = (d) => d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });
|
|
8
|
+
function ensureWatchdog(ctx) {
|
|
9
|
+
return watchdogLoaded() || loadWatchdog(ctx.home, [...ctx.selfCommand, 'awake', 'tick'], logPath(ctx.configDir));
|
|
10
|
+
}
|
|
11
|
+
async function on(args, ctx) {
|
|
12
|
+
const { values } = parseArgs({
|
|
13
|
+
args,
|
|
14
|
+
options: { until: { type: 'string' }, for: { type: 'string' }, battery: { type: 'string' } },
|
|
15
|
+
});
|
|
16
|
+
const now = new Date();
|
|
17
|
+
let until = null;
|
|
18
|
+
if (values.until && values.for) {
|
|
19
|
+
ctx.log('Use --until or --for, not both.');
|
|
20
|
+
return 2;
|
|
21
|
+
}
|
|
22
|
+
if (values.until)
|
|
23
|
+
until = parseUntil(values.until, now);
|
|
24
|
+
if (values.for)
|
|
25
|
+
until = parseFor(values.for, now);
|
|
26
|
+
if ((values.until || values.for) && !until) {
|
|
27
|
+
ctx.log('Could not read that time. Try --until 7am, --until 19:30 or --for 6h.');
|
|
28
|
+
return 2;
|
|
29
|
+
}
|
|
30
|
+
const floor = values.battery ? Number(values.battery) : readState(ctx.configDir).batteryFloor;
|
|
31
|
+
if (!Number.isInteger(floor) || floor < 5 || floor > 95) {
|
|
32
|
+
ctx.log('--battery takes a whole percentage between 5 and 95.');
|
|
33
|
+
return 2;
|
|
34
|
+
}
|
|
35
|
+
if (!setSleepDisabled(true)) {
|
|
36
|
+
ctx.log('Could not turn sleep off. Run voidshift add awake first.');
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
writeState(ctx.configDir, {
|
|
40
|
+
managed: true,
|
|
41
|
+
since: now.toISOString(),
|
|
42
|
+
until: until?.toISOString(),
|
|
43
|
+
batteryFloor: floor,
|
|
44
|
+
});
|
|
45
|
+
if (!ensureWatchdog(ctx))
|
|
46
|
+
ctx.log('Warning: the watchdog is not running, so guardrails will not act. Run voidshift doctor.');
|
|
47
|
+
const stop = until ? `at ${clock(until)} or at ${floor}% battery` : `at ${floor}% battery`;
|
|
48
|
+
ctx.log(`Awake. The lid can close. Stops ${stop}, or with voidshift awake off.`);
|
|
49
|
+
ctx.log('Keep it out of a bag: a closed Mac with no airflow runs hot.');
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
async function off(_args, ctx) {
|
|
53
|
+
const ok = setSleepDisabled(false);
|
|
54
|
+
writeState(ctx.configDir, { ...readState(ctx.configDir), managed: false, lastReason: 'you turned it off' });
|
|
55
|
+
ctx.log(ok ? 'Sleep restored.' : 'Could not restore sleep. Run: sudo pmset -a disablesleep 0');
|
|
56
|
+
return ok ? 0 : 1;
|
|
57
|
+
}
|
|
58
|
+
async function status(_args, ctx) {
|
|
59
|
+
const state = readState(ctx.configDir);
|
|
60
|
+
const sys = readSystem();
|
|
61
|
+
const power = sys.battery.onBattery ? `on battery, ${sys.battery.percent ?? '?'}%` : 'on power adapter';
|
|
62
|
+
if (state.managed && sys.sleepDisabled) {
|
|
63
|
+
const since = state.since ? clock(new Date(state.since)) : '?';
|
|
64
|
+
const stop = state.until ? `at ${clock(new Date(state.until))} or at ${state.batteryFloor}% battery` : `at ${state.batteryFloor}% battery`;
|
|
65
|
+
ctx.log(`Awake since ${since}. Stops ${stop}. Mac is ${power}.`);
|
|
66
|
+
}
|
|
67
|
+
else if (sys.sleepDisabled) {
|
|
68
|
+
ctx.log(`Sleep is turned off, but not by voidshift. Mac is ${power}.`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const last = state.lastReason ? ` Last session ended because ${state.lastReason}.` : '';
|
|
72
|
+
ctx.log(`Off. The Mac sleeps normally.${last}`);
|
|
73
|
+
}
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
// Run by launchd every minute.
|
|
77
|
+
async function tick(_args, ctx) {
|
|
78
|
+
const state = readState(ctx.configDir);
|
|
79
|
+
if (!state.managed)
|
|
80
|
+
return 0;
|
|
81
|
+
const d = decide(state, readSystem(), new Date());
|
|
82
|
+
if (d.action === 'keep')
|
|
83
|
+
return 0;
|
|
84
|
+
if (d.action === 'revert' && !setSleepDisabled(false)) {
|
|
85
|
+
ctx.log(`${new Date().toISOString()} could not restore sleep (${d.reason})`);
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
writeState(ctx.configDir, { ...state, managed: false, lastReason: d.reason });
|
|
89
|
+
ctx.log(`${new Date().toISOString()} sleep restored: ${d.reason}`);
|
|
90
|
+
return 0;
|
|
91
|
+
}
|
|
92
|
+
const awake = {
|
|
93
|
+
name: 'awake',
|
|
94
|
+
summary: 'Keep the Mac running on battery with the lid closed, with guardrails',
|
|
95
|
+
async install(ctx) {
|
|
96
|
+
if (process.platform !== 'darwin')
|
|
97
|
+
throw new Error('awake runs on macOS only');
|
|
98
|
+
const state = readState(ctx.configDir);
|
|
99
|
+
const floor = await ctx.ui.text('Turn sleep back on at what battery level (%)?', {
|
|
100
|
+
initial: String(state.batteryFloor),
|
|
101
|
+
validate: (v) => (/^\d+$/.test(v) && Number(v) >= 5 && Number(v) <= 95 ? undefined : 'A whole number from 5 to 95'),
|
|
102
|
+
});
|
|
103
|
+
writeState(ctx.configDir, { ...readState(ctx.configDir), batteryFloor: Number(floor) });
|
|
104
|
+
if (!ruleInstalled() || !ruleWorks()) {
|
|
105
|
+
ctx.log('Awake needs your Mac password once, to allow turning sleep off. macOS asks for it next:');
|
|
106
|
+
if (!installSudoers())
|
|
107
|
+
throw new Error('could not install the sleep permission rule');
|
|
108
|
+
}
|
|
109
|
+
if (!ensureWatchdog(ctx))
|
|
110
|
+
throw new Error('could not start the watchdog');
|
|
111
|
+
ctx.log(`Ready. voidshift awake on keeps the Mac running until ${floor}% battery or voidshift awake off.`);
|
|
112
|
+
},
|
|
113
|
+
async uninstall(ctx) {
|
|
114
|
+
const state = readState(ctx.configDir);
|
|
115
|
+
if (state.managed)
|
|
116
|
+
setSleepDisabled(false);
|
|
117
|
+
unloadWatchdog(ctx.home);
|
|
118
|
+
ctx.log('Removing the sleep permission rule needs your password:');
|
|
119
|
+
removeSudoers();
|
|
120
|
+
rmSync(stateDir(ctx.configDir), { recursive: true, force: true });
|
|
121
|
+
},
|
|
122
|
+
async checks(ctx) {
|
|
123
|
+
const checks = [];
|
|
124
|
+
const works = ruleWorks();
|
|
125
|
+
checks.push(ruleInstalled() && works
|
|
126
|
+
? { name: 'awake rule', status: 'ok', detail: SUDOERS_PATH }
|
|
127
|
+
: works
|
|
128
|
+
? { name: 'awake rule', status: 'warn', detail: "works only through another tool's sudoers rule", fix: 'voidshift add awake' }
|
|
129
|
+
: { name: 'awake rule', status: 'fail', detail: 'cannot turn sleep off without a password', fix: 'voidshift add awake' });
|
|
130
|
+
checks.push(watchdogLoaded()
|
|
131
|
+
? { name: 'awake watchdog', status: 'ok', detail: 'running every minute' }
|
|
132
|
+
: { name: 'awake watchdog', status: 'fail', detail: 'not loaded, guardrails will not act', fix: 'voidshift add awake' });
|
|
133
|
+
const state = readState(ctx.configDir);
|
|
134
|
+
const sys = readSystem();
|
|
135
|
+
if (sys.sleepDisabled && !state.managed) {
|
|
136
|
+
checks.push({ name: 'awake state', status: 'warn', detail: 'sleep is off, but not by voidshift', fix: 'Another tool may be holding it. sudo pmset -a disablesleep 0 resets it' });
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
checks.push({ name: 'awake state', status: 'ok', detail: state.managed ? 'on' : 'off' });
|
|
140
|
+
}
|
|
141
|
+
return checks;
|
|
142
|
+
},
|
|
143
|
+
commands: { on, off, status, tick },
|
|
144
|
+
};
|
|
145
|
+
export default awake;
|
package/dist/parse.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Battery {
|
|
2
|
+
onBattery: boolean;
|
|
3
|
+
percent: number | null;
|
|
4
|
+
}
|
|
5
|
+
export declare function parseSleepDisabled(out: string): boolean;
|
|
6
|
+
export declare function parseBattery(out: string): Battery;
|
|
7
|
+
export declare function parseThermalSerious(out: string): boolean;
|
|
8
|
+
export declare function parseBootTime(out: string): Date | null;
|
package/dist/parse.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Parsers for macOS power tool output. Kept pure so they are testable
|
|
2
|
+
// against captured samples.
|
|
3
|
+
// `pmset -g`: " SleepDisabled\t\t1"
|
|
4
|
+
export function parseSleepDisabled(out) {
|
|
5
|
+
const m = out.match(/SleepDisabled\s+(\d)/);
|
|
6
|
+
return m?.[1] === '1';
|
|
7
|
+
}
|
|
8
|
+
// `pmset -g batt`: "Now drawing from 'Battery Power'" then " -InternalBattery-0 ... 89%; discharging"
|
|
9
|
+
export function parseBattery(out) {
|
|
10
|
+
const onBattery = /'Battery Power'/.test(out);
|
|
11
|
+
const m = out.match(/(\d{1,3})%/);
|
|
12
|
+
return { onBattery, percent: m ? Number(m[1]) : null };
|
|
13
|
+
}
|
|
14
|
+
// `pmset -g therm`: nothing recorded on a cool Mac. Under load it reports a
|
|
15
|
+
// thermal warning level and CPU_Speed_Limit (100 = no throttling).
|
|
16
|
+
export function parseThermalSerious(out) {
|
|
17
|
+
const level = out.match(/thermal warning level[^0-9]*(\d+)/i);
|
|
18
|
+
if (level && Number(level[1]) > 0)
|
|
19
|
+
return true;
|
|
20
|
+
const speed = out.match(/CPU_Speed_Limit\s*=\s*(\d+)/);
|
|
21
|
+
return speed ? Number(speed[1]) < 60 : false;
|
|
22
|
+
}
|
|
23
|
+
// `sysctl -n kern.boottime`: "{ sec = 1787598645, usec = 753120 } Mon Aug 24 ..."
|
|
24
|
+
export function parseBootTime(out) {
|
|
25
|
+
const m = out.match(/sec = (\d+)/);
|
|
26
|
+
return m ? new Date(Number(m[1]) * 1000) : null;
|
|
27
|
+
}
|
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AwakeState } from './decide.ts';
|
|
2
|
+
export declare const DEFAULT_BATTERY_FLOOR = 20;
|
|
3
|
+
export declare const stateDir: (configDir: string) => string;
|
|
4
|
+
export declare const statePath: (configDir: string) => string;
|
|
5
|
+
export declare const logPath: (configDir: string) => string;
|
|
6
|
+
export declare function readState(configDir: string): AwakeState;
|
|
7
|
+
export declare function writeState(configDir: string, state: AwakeState): void;
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
export const DEFAULT_BATTERY_FLOOR = 20;
|
|
4
|
+
export const stateDir = (configDir) => join(configDir, 'awake');
|
|
5
|
+
export const statePath = (configDir) => join(stateDir(configDir), 'state.json');
|
|
6
|
+
export const logPath = (configDir) => join(stateDir(configDir), 'watchdog.log');
|
|
7
|
+
export function readState(configDir) {
|
|
8
|
+
const path = statePath(configDir);
|
|
9
|
+
if (!existsSync(path))
|
|
10
|
+
return { managed: false, batteryFloor: DEFAULT_BATTERY_FLOOR };
|
|
11
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
12
|
+
}
|
|
13
|
+
export function writeState(configDir, state) {
|
|
14
|
+
const path = statePath(configDir);
|
|
15
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
16
|
+
writeFileSync(path, JSON.stringify(state, null, 2) + '\n');
|
|
17
|
+
}
|
package/dist/system.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SystemReading } from './decide.ts';
|
|
2
|
+
export declare const SUDOERS_PATH = "/etc/sudoers.d/voidshift-awake";
|
|
3
|
+
export declare const LABEL = "org.devvoid.voidshift.awake";
|
|
4
|
+
export declare function readSystem(): SystemReading;
|
|
5
|
+
export declare function setSleepDisabled(disabled: boolean): boolean;
|
|
6
|
+
export declare function ruleInstalled(): boolean;
|
|
7
|
+
export declare function ruleWorks(): boolean;
|
|
8
|
+
export declare function sudoersRule(user: string): string;
|
|
9
|
+
export declare function installSudoers(): boolean;
|
|
10
|
+
export declare function removeSudoers(): boolean;
|
|
11
|
+
export declare function plistPath(home: string): string;
|
|
12
|
+
export declare function watchdogPlist(program: string[], logPath: string): string;
|
|
13
|
+
export declare function watchdogLoaded(): boolean;
|
|
14
|
+
export declare function loadWatchdog(home: string, program: string[], logPath: string): boolean;
|
|
15
|
+
export declare function unloadWatchdog(home: string): void;
|
package/dist/system.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir, userInfo } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
import { parseBattery, parseBootTime, parseSleepDisabled, parseThermalSerious } from "./parse.js";
|
|
6
|
+
const PMSET = '/usr/bin/pmset';
|
|
7
|
+
export const SUDOERS_PATH = '/etc/sudoers.d/voidshift-awake';
|
|
8
|
+
export const LABEL = 'org.devvoid.voidshift.awake';
|
|
9
|
+
function exec(cmd, args, interactive = false) {
|
|
10
|
+
const r = spawnSync(cmd, args, {
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
stdio: interactive ? 'inherit' : 'pipe',
|
|
13
|
+
timeout: interactive ? undefined : 10_000,
|
|
14
|
+
});
|
|
15
|
+
return { ok: r.status === 0, stdout: (r.stdout ?? '').trim() };
|
|
16
|
+
}
|
|
17
|
+
export function readSystem() {
|
|
18
|
+
return {
|
|
19
|
+
sleepDisabled: parseSleepDisabled(exec(PMSET, ['-g']).stdout),
|
|
20
|
+
battery: parseBattery(exec(PMSET, ['-g', 'batt']).stdout),
|
|
21
|
+
thermalSerious: parseThermalSerious(exec(PMSET, ['-g', 'therm']).stdout),
|
|
22
|
+
bootTime: parseBootTime(exec('/usr/sbin/sysctl', ['-n', 'kern.boottime']).stdout),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Never prompts: relies on the sudoers rule installed at setup.
|
|
26
|
+
export function setSleepDisabled(disabled) {
|
|
27
|
+
return exec('/usr/bin/sudo', ['-n', PMSET, '-a', 'disablesleep', disabled ? '1' : '0']).ok;
|
|
28
|
+
}
|
|
29
|
+
// Another tool's sudoers rule can make ruleWorks() true on its own, so
|
|
30
|
+
// installation and health both key on our own file existing.
|
|
31
|
+
export function ruleInstalled() {
|
|
32
|
+
return existsSync(SUDOERS_PATH);
|
|
33
|
+
}
|
|
34
|
+
export function ruleWorks() {
|
|
35
|
+
return exec('/usr/bin/sudo', ['-n', '-l', PMSET, '-a', 'disablesleep', '1']).ok;
|
|
36
|
+
}
|
|
37
|
+
// Allows exactly the two pmset invocations awake needs, for this user only.
|
|
38
|
+
export function sudoersRule(user) {
|
|
39
|
+
if (!/^[a-z_][a-z0-9_.-]*$/i.test(user) || user.toUpperCase() === 'ALL')
|
|
40
|
+
throw new Error(`unexpected user name: ${user}`);
|
|
41
|
+
return `${user} ALL=(root) NOPASSWD: ${PMSET} -a disablesleep 0, ${PMSET} -a disablesleep 1\n`;
|
|
42
|
+
}
|
|
43
|
+
// Interactive: sudo asks for the user's password once. The rule is checked
|
|
44
|
+
// with visudo before it is installed, so a bad file can never lock sudo.
|
|
45
|
+
export function installSudoers() {
|
|
46
|
+
const dir = mkdtempSync(join(tmpdir(), 'voidshift-'));
|
|
47
|
+
const file = join(dir, 'voidshift-awake');
|
|
48
|
+
try {
|
|
49
|
+
writeFileSync(file, sudoersRule(userInfo().username), { mode: 0o600 });
|
|
50
|
+
if (!exec('/usr/bin/sudo', ['/usr/sbin/visudo', '-cf', file], true).ok)
|
|
51
|
+
return false;
|
|
52
|
+
return exec('/usr/bin/sudo', ['/usr/bin/install', '-m', '0440', '-o', 'root', '-g', 'wheel', file, SUDOERS_PATH], true).ok;
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
rmSync(dir, { recursive: true, force: true });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function removeSudoers() {
|
|
59
|
+
if (!existsSync(SUDOERS_PATH))
|
|
60
|
+
return true;
|
|
61
|
+
return exec('/usr/bin/sudo', ['/bin/rm', '-f', SUDOERS_PATH], true).ok;
|
|
62
|
+
}
|
|
63
|
+
export function plistPath(home) {
|
|
64
|
+
return join(home, 'Library', 'LaunchAgents', `${LABEL}.plist`);
|
|
65
|
+
}
|
|
66
|
+
const xml = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
67
|
+
export function watchdogPlist(program, logPath) {
|
|
68
|
+
const args = program.map((a) => ` <string>${xml(a)}</string>`).join('\n');
|
|
69
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
70
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
71
|
+
<plist version="1.0">
|
|
72
|
+
<dict>
|
|
73
|
+
<key>Label</key>
|
|
74
|
+
<string>${LABEL}</string>
|
|
75
|
+
<key>ProgramArguments</key>
|
|
76
|
+
<array>
|
|
77
|
+
${args}
|
|
78
|
+
</array>
|
|
79
|
+
<key>StartInterval</key>
|
|
80
|
+
<integer>60</integer>
|
|
81
|
+
<key>RunAtLoad</key>
|
|
82
|
+
<true/>
|
|
83
|
+
<key>StandardOutPath</key>
|
|
84
|
+
<string>${xml(logPath)}</string>
|
|
85
|
+
<key>StandardErrorPath</key>
|
|
86
|
+
<string>${xml(logPath)}</string>
|
|
87
|
+
</dict>
|
|
88
|
+
</plist>
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
const domain = () => `gui/${userInfo().uid}`;
|
|
92
|
+
export function watchdogLoaded() {
|
|
93
|
+
return exec('/bin/launchctl', ['print', `${domain()}/${LABEL}`]).ok;
|
|
94
|
+
}
|
|
95
|
+
export function loadWatchdog(home, program, logPath) {
|
|
96
|
+
const path = plistPath(home);
|
|
97
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
98
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
99
|
+
writeFileSync(path, watchdogPlist(program, logPath));
|
|
100
|
+
if (watchdogLoaded())
|
|
101
|
+
exec('/bin/launchctl', ['bootout', `${domain()}/${LABEL}`]);
|
|
102
|
+
return exec('/bin/launchctl', ['bootstrap', domain(), path]).ok;
|
|
103
|
+
}
|
|
104
|
+
export function unloadWatchdog(home) {
|
|
105
|
+
if (watchdogLoaded())
|
|
106
|
+
exec('/bin/launchctl', ['bootout', `${domain()}/${LABEL}`]);
|
|
107
|
+
rmSync(plistPath(home), { force: true });
|
|
108
|
+
}
|
package/dist/time.d.ts
ADDED
package/dist/time.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// "7am", "7:30am", "19:00" -> the next time that clock reading comes round.
|
|
2
|
+
export function parseUntil(input, now) {
|
|
3
|
+
const m = input.trim().match(/^(\d{1,2})(?::(\d{2}))?\s*(am|pm)?$/i);
|
|
4
|
+
if (!m)
|
|
5
|
+
return null;
|
|
6
|
+
let hour = Number(m[1]);
|
|
7
|
+
const minute = Number(m[2] ?? 0);
|
|
8
|
+
const meridiem = m[3]?.toLowerCase();
|
|
9
|
+
if (minute > 59)
|
|
10
|
+
return null;
|
|
11
|
+
if (meridiem) {
|
|
12
|
+
if (hour < 1 || hour > 12)
|
|
13
|
+
return null;
|
|
14
|
+
if (hour === 12)
|
|
15
|
+
hour = 0;
|
|
16
|
+
if (meridiem === 'pm')
|
|
17
|
+
hour += 12;
|
|
18
|
+
}
|
|
19
|
+
else if (hour > 23) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const at = new Date(now);
|
|
23
|
+
at.setHours(hour, minute, 0, 0);
|
|
24
|
+
if (at <= now)
|
|
25
|
+
at.setDate(at.getDate() + 1);
|
|
26
|
+
return at;
|
|
27
|
+
}
|
|
28
|
+
// "6h", "90m", "1h30m" -> now plus that long.
|
|
29
|
+
export function parseFor(input, now) {
|
|
30
|
+
const m = input.trim().match(/^(?:(\d+)h)?(?:(\d+)m)?$/i);
|
|
31
|
+
if (!m || (!m[1] && !m[2]))
|
|
32
|
+
return null;
|
|
33
|
+
const minutes = Number(m[1] ?? 0) * 60 + Number(m[2] ?? 0);
|
|
34
|
+
if (minutes <= 0)
|
|
35
|
+
return null;
|
|
36
|
+
return new Date(now.getTime() + minutes * 60_000);
|
|
37
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type CheckStatus = 'ok' | 'warn' | 'fail';
|
|
2
|
+
export interface Check {
|
|
3
|
+
name: string;
|
|
4
|
+
status: CheckStatus;
|
|
5
|
+
detail: string;
|
|
6
|
+
fix?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Choice<T extends string> {
|
|
9
|
+
value: T;
|
|
10
|
+
label: string;
|
|
11
|
+
hint?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Ui {
|
|
14
|
+
info(line: string): void;
|
|
15
|
+
warn(line: string): void;
|
|
16
|
+
text(message: string, o?: {
|
|
17
|
+
initial?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
validate?: (v: string) => string | undefined;
|
|
20
|
+
}): Promise<string>;
|
|
21
|
+
secret(message: string, validate?: (v: string) => string | undefined): Promise<string>;
|
|
22
|
+
confirm(message: string, initial?: boolean): Promise<boolean>;
|
|
23
|
+
select<T extends string>(message: string, choices: Choice<T>[], initial?: T): Promise<T>;
|
|
24
|
+
multiselect<T extends string>(message: string, choices: Choice<T>[], initial?: T[]): Promise<T[]>;
|
|
25
|
+
search<T extends string>(message: string, choices: Choice<T>[], placeholder?: string, initial?: T): Promise<T>;
|
|
26
|
+
path(message: string, o?: {
|
|
27
|
+
initial?: string;
|
|
28
|
+
validate?: (v: string) => string | undefined;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
export interface ToolContext {
|
|
32
|
+
defaults: boolean;
|
|
33
|
+
home: string;
|
|
34
|
+
configDir: string;
|
|
35
|
+
selfCommand: string[];
|
|
36
|
+
log: (line: string) => void;
|
|
37
|
+
ui: Ui;
|
|
38
|
+
}
|
|
39
|
+
export type ToolCommand = (args: string[], ctx: ToolContext) => Promise<number>;
|
|
40
|
+
export interface Tool {
|
|
41
|
+
name: string;
|
|
42
|
+
summary: string;
|
|
43
|
+
install(ctx: ToolContext): Promise<void>;
|
|
44
|
+
uninstall(ctx: ToolContext): Promise<void>;
|
|
45
|
+
checks(ctx: ToolContext): Promise<Check[]>;
|
|
46
|
+
commands?: Record<string, ToolCommand>;
|
|
47
|
+
}
|
package/dist/types.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvoid/voidshift-awake",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Keep a Mac running on battery with the lid closed, with guardrails.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/EratosVoid/voidshift.git",
|
|
9
|
+
"directory": "tools/awake"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/EratosVoid/voidshift#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/EratosVoid/voidshift/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"claude-code",
|
|
17
|
+
"codex",
|
|
18
|
+
"agents",
|
|
19
|
+
"linear",
|
|
20
|
+
"cli",
|
|
21
|
+
"macos"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"main": "dist/index.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"LICENSE",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"os": [
|
|
32
|
+
"darwin"
|
|
33
|
+
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=22.18"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"provenance": true
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsc -p tsconfig.json",
|
|
43
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
44
|
+
"test": "node --test test/*.test.ts",
|
|
45
|
+
"prepublishOnly": "tsc -p tsconfig.json"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/node": "^22.18.0",
|
|
49
|
+
"typescript": "^5.9.0"
|
|
50
|
+
}
|
|
51
|
+
}
|