@monotykamary/localterm-server 2.2.3 → 2.4.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/dist/caffeinate-battery.d.ts +10 -0
- package/dist/caffeinate-battery.d.ts.map +1 -0
- package/dist/caffeinate-battery.js +47 -0
- package/dist/caffeinate-battery.js.map +1 -0
- package/dist/caffeinate-manager.d.ts +17 -0
- package/dist/caffeinate-manager.d.ts.map +1 -1
- package/dist/caffeinate-manager.js +194 -4
- package/dist/caffeinate-manager.js.map +1 -1
- package/dist/caffeinate-preferences-store.d.ts +2 -0
- package/dist/caffeinate-preferences-store.d.ts.map +1 -1
- package/dist/caffeinate-preferences-store.js +31 -2
- package/dist/caffeinate-preferences-store.js.map +1 -1
- package/dist/constants.d.ts +8 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +29 -1
- package/dist/constants.js.map +1 -1
- package/dist/git-worktrees.d.ts +9 -2
- package/dist/git-worktrees.d.ts.map +1 -1
- package/dist/git-worktrees.js +288 -53
- package/dist/git-worktrees.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +3 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +2 -2
- package/dist/protocol.js.map +1 -1
- package/dist/schemas.d.ts +34 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +77 -3
- package/dist/schemas.js.map +1 -1
- package/dist/types.d.ts +4 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/worktree-names.d.ts +2 -0
- package/dist/utils/worktree-names.d.ts.map +1 -0
- package/dist/utils/worktree-names.js +155 -0
- package/dist/utils/worktree-names.js.map +1 -0
- package/package.json +1 -1
package/dist/constants.js
CHANGED
|
@@ -20,7 +20,7 @@ export const CAFFEINATE_AUTO_DEFAULT_COMMANDS = [
|
|
|
20
20
|
"opencode",
|
|
21
21
|
"pi",
|
|
22
22
|
];
|
|
23
|
-
export const CAFFEINATE_PREFERENCES_FILE_VERSION =
|
|
23
|
+
export const CAFFEINATE_PREFERENCES_FILE_VERSION = 3;
|
|
24
24
|
// Automatic detection is event-driven (no timer): a `ps` snapshot is taken only
|
|
25
25
|
// in response to a foreground change or a session connect/disconnect. This
|
|
26
26
|
// debounce window coalesces a burst of such events into a single snapshot; it
|
|
@@ -34,6 +34,34 @@ export const CAFFEINATE_AUTO_POKE_DEBOUNCE_MS = 150;
|
|
|
34
34
|
export const CAFFEINATE_ACTIVITY_GATE_DEBOUNCE_MS = 5_000;
|
|
35
35
|
export const MAX_CAFFEINATE_COMMANDS = 50;
|
|
36
36
|
export const MAX_CAFFEINATE_COMMAND_LENGTH = 128;
|
|
37
|
+
// Battery floor for keep-awake: when the machine is on battery power and at or
|
|
38
|
+
// below this percent, the daemon refuses to hold the power assertion (it stops
|
|
39
|
+
// caffeinate without changing the selected mode). The default is on, so a
|
|
40
|
+
// machine left unplugged stops keeping itself awake before it dies. `null`
|
|
41
|
+
// (selectable in the menu as "Off") disables the guard entirely.
|
|
42
|
+
export const CAFFEINATE_BATTERY_LOW_WATER_PERCENT_DEFAULT = 20;
|
|
43
|
+
export const CAFFEINATE_BATTERY_LOW_WATER_MIN_PERCENT = 5;
|
|
44
|
+
export const CAFFEINATE_BATTERY_LOW_WATER_MAX_PERCENT = 50;
|
|
45
|
+
// The battery floor is enforced by reading `pmset -g batt` on an adaptive
|
|
46
|
+
// schedule rather than a fixed heartbeat. `pmset` reports the charge percent
|
|
47
|
+
// and an EWMA "time to empty" estimate; the next delay is 1/TIME_FRACTION of the
|
|
48
|
+
// interpolated time-to-threshold (estimate × charge fraction still above the
|
|
49
|
+
// floor), so polling tightens as the floor approaches and stays lax far from
|
|
50
|
+
// it. Halving (not subtracting a fixed margin) scales the buffer with the
|
|
51
|
+
// estimate: the EWMA lags real discharge and the active program drains faster
|
|
52
|
+
// than the idle minutes it averaged, so a 2× buffer absorbs a stale-high
|
|
53
|
+
// estimate without overshooting. Clamped to [MIN, MAX]: MIN keeps a
|
|
54
|
+
// near-threshold reading from busy-looping and drives fast recovery while
|
|
55
|
+
// suppressed; MAX bounds the far-from-threshold and on-AC cases. The floor is
|
|
56
|
+
// a courtesy guard — macOS still forces low-battery sleep at ~5% regardless of
|
|
57
|
+
// caffeinate — so a multi-minute MAX is an acceptable worst-case latency for
|
|
58
|
+
// noticing an unplug or a stalled estimate.
|
|
59
|
+
export const CAFFEINATE_BATTERY_POLL_MIN_INTERVAL_MS = 5_000;
|
|
60
|
+
export const CAFFEINATE_BATTERY_POLL_MAX_INTERVAL_MS = 15 * 60_000;
|
|
61
|
+
// Poll at 1/N of the interpolated time-to-threshold. N=2 gives a 2× buffer
|
|
62
|
+
// against the OS estimate being stale-high.
|
|
63
|
+
export const CAFFEINATE_BATTERY_POLL_TIME_FRACTION = 2;
|
|
64
|
+
export const CAFFEINATE_BATTERY_READ_TIMEOUT_MS = 2_000;
|
|
37
65
|
export const TITLE_MAX_PATH_SEGMENTS = 1;
|
|
38
66
|
/**
|
|
39
67
|
* Strip terminal-emulator identity env vars inherited from the daemon's parent.
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;AACxC,MAAM,CAAC,MAAM,iBAAiB,GAAG,qBAAqB,CAAC;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAChC,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAC/B,MAAM,CAAC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEhD,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAC1C,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW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AG,GAAG,CAAC;AAChD,8EAA8E;AAC9E,wEAAwE;AACxE,6EAA6E;AAC7E,2EAA2E;AAC3E,2EAA2E;AAC3E,oEAAoE;AACpE,MAAM,CAAC,MAAM,kCAAkC,GAAG,KAAK,CAAC;AACxD,iFAAiF;AACjF,2EAA2E;AAC3E,sEAAsE;AACtE,6EAA6E;AAC7E,mBAAmB;AACnB,MAAM,CAAC,MAAM,4BAA4B,GAAG,GAAG,CAAC;AAChD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CAAC;AACzD,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAEtD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAC9C,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,CAAC"}
|
package/dist/git-worktrees.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { GitWorktreeListResponse } from "./types.js";
|
|
2
|
-
export declare
|
|
3
|
-
|
|
2
|
+
export declare class WorktreeError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare const listGitWorktrees: (cwd: string) => Promise<GitWorktreeListResponse>;
|
|
6
|
+
export declare const createGitWorktree: (cwd: string) => Promise<{
|
|
7
|
+
path: string;
|
|
8
|
+
branch: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const removeGitWorktree: (cwd: string, targetPath: string) => Promise<void>;
|
|
4
11
|
//# sourceMappingURL=git-worktrees.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-worktrees.d.ts","sourceRoot":"","sources":["../src/git-worktrees.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git-worktrees.d.ts","sourceRoot":"","sources":["../src/git-worktrees.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAe,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAMvE,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAsND,eAAO,MAAM,gBAAgB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC,uBAAuB,CAsBnF,CAAC;AAOF,eAAO,MAAM,iBAAiB,GAAU,KAAK,MAAM,KAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAuB7F,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,KAAK,MAAM,EAAE,YAAY,MAAM,KAAG,OAAO,CAAC,IAAI,CAoBrF,CAAC"}
|
package/dist/git-worktrees.js
CHANGED
|
@@ -1,59 +1,294 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
1
5
|
import { runGit } from "./utils/run-git.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
6
|
+
import { generateWorktreeName } from "./utils/worktree-names.js";
|
|
7
|
+
// A user-facing git failure (path exists, branch checked out elsewhere, the
|
|
8
|
+
// main worktree can't be removed, …). The route catches this and surfaces
|
|
9
|
+
// `message` (git's own stderr) so the client can show something actionable
|
|
10
|
+
// instead of an opaque code.
|
|
11
|
+
export class WorktreeError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "WorktreeError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const HOME = os.homedir();
|
|
18
|
+
const PATH_SEPARATOR = path.sep;
|
|
19
|
+
// Auto-created worktrees live under the localterm state dir (~/.localterm/),
|
|
20
|
+
// next to the daemon's other per-project state (automations.json, server.log).
|
|
21
|
+
const WORKTREES_PARENT_DIR = path.join(HOME, ".localterm", "worktrees");
|
|
22
|
+
// Marker file placed in each project folder so a second repo with the same
|
|
23
|
+
// project name (but a different main worktree path) gets its own folder instead
|
|
24
|
+
// of colliding with the first repo's worktrees.
|
|
25
|
+
const REPO_MARKER_FILENAME = ".localterm-repo-id";
|
|
26
|
+
const REPO_ID_HASH_LENGTH = 12;
|
|
27
|
+
const PROJECT_FOLDER_HASH_LENGTH = 6;
|
|
28
|
+
const MAX_PROJECT_FOLDER_ATTEMPTS = 100;
|
|
29
|
+
const MAX_WORKTREE_NAME_ATTEMPTS = 50;
|
|
30
|
+
// Tildify an absolute path against the daemon's home. The browser can't resolve
|
|
31
|
+
// the home dir itself, so the server does it for display strings (the absolute
|
|
32
|
+
// `path` is always sent back unchanged for actions like opening a shell).
|
|
33
|
+
const tildifyHome = (absolutePath) => {
|
|
34
|
+
const resolved = path.resolve(absolutePath);
|
|
35
|
+
if (resolved === HOME)
|
|
36
|
+
return "~";
|
|
37
|
+
if (resolved.startsWith(`${HOME}${PATH_SEPARATOR}`))
|
|
38
|
+
return `~${resolved.slice(HOME.length)}`;
|
|
39
|
+
return resolved;
|
|
40
|
+
};
|
|
41
|
+
// Stable per-repo identity: a short hash of the main worktree's absolute path.
|
|
42
|
+
// Two repos with the same project name but different paths get different ids, so
|
|
43
|
+
// their worktree folders don't collide.
|
|
44
|
+
const repoId = (mainRoot) => crypto.createHash("sha256").update(mainRoot).digest("hex").slice(0, REPO_ID_HASH_LENGTH);
|
|
45
|
+
const readRepoMarker = (dir) => {
|
|
46
|
+
try {
|
|
47
|
+
const content = fs.readFileSync(path.join(dir, REPO_MARKER_FILENAME), "utf8").trim();
|
|
48
|
+
return content || null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const writeRepoMarker = (dir, id) => {
|
|
55
|
+
try {
|
|
56
|
+
fs.writeFileSync(path.join(dir, REPO_MARKER_FILENAME), id);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// A marker write failure isn't fatal — the folder still works; we just
|
|
60
|
+
// can't disambiguate a future same-named repo.
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// Read-only resolution of the project folder NAME (for display). Mirrors
|
|
64
|
+
// ensureProjectFolder's logic without creating dirs or writing markers, so
|
|
65
|
+
// listGitWorktrees stays side-effect-free.
|
|
66
|
+
const resolveProjectFolderName = (projectName, id) => {
|
|
67
|
+
const preferred = path.join(WORKTREES_PARENT_DIR, projectName);
|
|
68
|
+
if (!fs.existsSync(preferred))
|
|
69
|
+
return projectName;
|
|
70
|
+
if (readRepoMarker(preferred) === id)
|
|
71
|
+
return projectName;
|
|
72
|
+
return `${projectName}-${id.slice(0, PROJECT_FOLDER_HASH_LENGTH)}`;
|
|
73
|
+
};
|
|
74
|
+
// Resolve + create the project folder, claiming it with the repo marker so a
|
|
75
|
+
// later same-named repo from a different path gets its own folder. Idempotent:
|
|
76
|
+
// re-uses an existing folder owned by this repo.
|
|
77
|
+
const ensureProjectFolder = (projectName, id) => {
|
|
78
|
+
const preferred = path.join(WORKTREES_PARENT_DIR, projectName);
|
|
79
|
+
if (!fs.existsSync(preferred)) {
|
|
80
|
+
fs.mkdirSync(preferred, { recursive: true });
|
|
81
|
+
writeRepoMarker(preferred, id);
|
|
82
|
+
return preferred;
|
|
83
|
+
}
|
|
84
|
+
if (readRepoMarker(preferred) === id) {
|
|
85
|
+
writeRepoMarker(preferred, id);
|
|
86
|
+
return preferred;
|
|
87
|
+
}
|
|
88
|
+
// Bare name is owned by a different repo. Fall back to a hashed name, then a
|
|
89
|
+
// counter if even that is taken by a third repo (near-impossible at 6 hex).
|
|
90
|
+
const hashedName = `${projectName}-${id.slice(0, PROJECT_FOLDER_HASH_LENGTH)}`;
|
|
91
|
+
let candidate = path.join(WORKTREES_PARENT_DIR, hashedName);
|
|
92
|
+
for (let attempt = 0; attempt < MAX_PROJECT_FOLDER_ATTEMPTS; attempt++) {
|
|
93
|
+
if (!fs.existsSync(candidate)) {
|
|
94
|
+
fs.mkdirSync(candidate, { recursive: true });
|
|
95
|
+
writeRepoMarker(candidate, id);
|
|
96
|
+
return candidate;
|
|
97
|
+
}
|
|
98
|
+
if (readRepoMarker(candidate) === id) {
|
|
99
|
+
writeRepoMarker(candidate, id);
|
|
100
|
+
return candidate;
|
|
101
|
+
}
|
|
102
|
+
candidate = path.join(WORKTREES_PARENT_DIR, `${hashedName}-${attempt + 2}`);
|
|
103
|
+
}
|
|
104
|
+
throw new WorktreeError("couldn't find a free project folder");
|
|
105
|
+
};
|
|
106
|
+
const isGitRepo = async (cwd) => {
|
|
107
|
+
const result = await runGit(cwd, ["rev-parse", "--is-inside-work-tree"]);
|
|
108
|
+
return result.exitCode === 0;
|
|
109
|
+
};
|
|
110
|
+
// The worktree the caller's cwd lives in (its toplevel root), so the matching
|
|
111
|
+
// entry can be flagged `isCurrent`. Cheaper than asking git to mark it: a single
|
|
112
|
+
// rev-parse vs a porcelain walk that already happened.
|
|
113
|
+
const currentWorktreeRoot = async (cwd) => {
|
|
114
|
+
const result = await runGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
115
|
+
if (result.exitCode !== 0)
|
|
116
|
+
return null;
|
|
117
|
+
const root = result.stdout.toString("utf8").trim();
|
|
118
|
+
return root || null;
|
|
119
|
+
};
|
|
120
|
+
// The main worktree's root — the parent of the shared common .git dir. Stable
|
|
121
|
+
// across linked worktrees (they all share it), so the derived project name and
|
|
122
|
+
// repo id don't depend on which worktree the caller's cwd happens to be in: a
|
|
123
|
+
// worktree created from inside a linked worktree still lands under the repo's
|
|
124
|
+
// own project folder. Resolved through realpath so it matches the paths git
|
|
125
|
+
// prints in `worktree list --porcelain` (git resolves symlinks; a naive
|
|
126
|
+
// path.resolve against a symlinked cwd would not).
|
|
127
|
+
const mainWorktreeRoot = async (cwd) => {
|
|
128
|
+
const result = await runGit(cwd, ["rev-parse", "--git-common-dir"]);
|
|
129
|
+
if (result.exitCode !== 0)
|
|
130
|
+
return null;
|
|
131
|
+
const commonDir = result.stdout.toString("utf8").trim();
|
|
132
|
+
if (!commonDir)
|
|
133
|
+
return null;
|
|
134
|
+
const root = path.dirname(path.resolve(cwd, commonDir));
|
|
135
|
+
try {
|
|
136
|
+
return fs.realpathSync(root);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return root;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
// `git worktree list --porcelain` emits one block per worktree, fields on their
|
|
143
|
+
// own lines, blocks separated by a blank line:
|
|
144
|
+
//
|
|
145
|
+
// worktree /abs/path/to/main
|
|
146
|
+
// HEAD <sha>
|
|
147
|
+
// branch refs/heads/main
|
|
148
|
+
//
|
|
149
|
+
// worktree /abs/path/to/feature
|
|
150
|
+
// HEAD <sha>
|
|
151
|
+
// detached
|
|
152
|
+
// locked
|
|
153
|
+
// prunable
|
|
154
|
+
//
|
|
155
|
+
// The leading "worktree" line carries the path; HEAD/branch/detached/locked/
|
|
156
|
+
// prunable are optional flags. Parse defensively: unknown fields are ignored
|
|
157
|
+
// so future git output doesn't break the list.
|
|
158
|
+
const parseWorktreePorcelain = (raw) => {
|
|
159
|
+
const entries = [];
|
|
160
|
+
let current = null;
|
|
161
|
+
for (const line of raw.split("\n")) {
|
|
162
|
+
if (line === "") {
|
|
163
|
+
if (current) {
|
|
164
|
+
entries.push(current);
|
|
165
|
+
current = null;
|
|
35
166
|
}
|
|
167
|
+
continue;
|
|
36
168
|
}
|
|
37
|
-
|
|
169
|
+
const spaceIndex = line.indexOf(" ");
|
|
170
|
+
const field = spaceIndex === -1 ? line : line.slice(0, spaceIndex);
|
|
171
|
+
const value = spaceIndex === -1 ? "" : line.slice(spaceIndex + 1);
|
|
172
|
+
if (field === "worktree") {
|
|
173
|
+
current = {
|
|
174
|
+
path: value,
|
|
175
|
+
head: null,
|
|
176
|
+
branch: null,
|
|
177
|
+
detached: false,
|
|
178
|
+
locked: false,
|
|
179
|
+
prunable: false,
|
|
180
|
+
};
|
|
38
181
|
continue;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
182
|
+
}
|
|
183
|
+
if (!current)
|
|
184
|
+
continue;
|
|
185
|
+
if (field === "HEAD") {
|
|
186
|
+
current.head = value || null;
|
|
187
|
+
}
|
|
188
|
+
else if (field === "branch") {
|
|
189
|
+
// refs/heads/<name> -> <name>. Keep the raw value if it isn't a ref
|
|
190
|
+
// (it never is in porcelain output, but be tolerant).
|
|
191
|
+
current.branch = value.startsWith("refs/heads/")
|
|
192
|
+
? value.slice("refs/heads/".length)
|
|
193
|
+
: value || null;
|
|
194
|
+
}
|
|
195
|
+
else if (field === "detached") {
|
|
196
|
+
current.detached = true;
|
|
197
|
+
}
|
|
198
|
+
else if (field === "locked") {
|
|
199
|
+
current.locked = true;
|
|
200
|
+
}
|
|
201
|
+
else if (field === "prunable") {
|
|
202
|
+
current.prunable = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (current)
|
|
206
|
+
entries.push(current);
|
|
207
|
+
return entries;
|
|
208
|
+
};
|
|
209
|
+
const toWorktree = (parsed, currentRoot, mainRoot) => ({
|
|
210
|
+
path: parsed.path,
|
|
211
|
+
displayPath: tildifyHome(parsed.path),
|
|
212
|
+
branch: parsed.detached ? null : parsed.branch,
|
|
213
|
+
head: parsed.head,
|
|
214
|
+
isCurrent: currentRoot !== null && path.resolve(parsed.path) === path.resolve(currentRoot),
|
|
215
|
+
isMain: mainRoot !== null && path.resolve(parsed.path) === path.resolve(mainRoot),
|
|
216
|
+
isLocked: parsed.locked,
|
|
217
|
+
isPrunable: parsed.prunable,
|
|
218
|
+
});
|
|
219
|
+
export const listGitWorktrees = async (cwd) => {
|
|
220
|
+
if (!(await isGitRepo(cwd)))
|
|
221
|
+
return { isRepo: false, worktrees: [], displayBaseDir: null };
|
|
222
|
+
const [listResult, currentRoot, mainRoot] = await Promise.all([
|
|
223
|
+
runGit(cwd, ["worktree", "list", "--porcelain"]),
|
|
224
|
+
currentWorktreeRoot(cwd),
|
|
225
|
+
mainWorktreeRoot(cwd),
|
|
226
|
+
]);
|
|
227
|
+
if (listResult.exitCode !== 0) {
|
|
228
|
+
throw new WorktreeError(listResult.stderr.trim() || "git worktree list failed");
|
|
229
|
+
}
|
|
230
|
+
const parsed = parseWorktreePorcelain(listResult.stdout.toString("utf8"));
|
|
231
|
+
const worktrees = parsed.map((entry) => toWorktree(entry, currentRoot, mainRoot));
|
|
232
|
+
let displayBaseDir = null;
|
|
233
|
+
if (mainRoot) {
|
|
234
|
+
const projectName = path.basename(mainRoot);
|
|
235
|
+
if (projectName) {
|
|
236
|
+
displayBaseDir = tildifyHome(path.join(WORKTREES_PARENT_DIR, resolveProjectFolderName(projectName, repoId(mainRoot))));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { isRepo: true, worktrees, displayBaseDir };
|
|
240
|
+
};
|
|
241
|
+
// Create a worktree under ~/.localterm/worktrees/<project>/ on a memorable
|
|
242
|
+
// auto-generated branch (adjective-noun) from HEAD. The branch and folder name
|
|
243
|
+
// match, so the folder is self-describing. A collision (branch or folder
|
|
244
|
+
// already exists) retries with a fresh phrase; any other git failure is
|
|
245
|
+
// surfaced immediately.
|
|
246
|
+
export const createGitWorktree = async (cwd) => {
|
|
247
|
+
const mainRoot = await mainWorktreeRoot(cwd);
|
|
248
|
+
if (!mainRoot)
|
|
249
|
+
throw new WorktreeError("couldn't resolve the repository's main worktree");
|
|
250
|
+
const projectName = path.basename(mainRoot);
|
|
251
|
+
if (!projectName)
|
|
252
|
+
throw new WorktreeError("couldn't resolve the repository's project name");
|
|
253
|
+
const projectDir = ensureProjectFolder(projectName, repoId(mainRoot));
|
|
254
|
+
let lastError = null;
|
|
255
|
+
const attempted = new Set();
|
|
256
|
+
for (let attempt = 0; attempt < MAX_WORKTREE_NAME_ATTEMPTS; attempt++) {
|
|
257
|
+
const name = generateWorktreeName(attempted);
|
|
258
|
+
attempted.add(name);
|
|
259
|
+
const targetPath = path.join(projectDir, name);
|
|
260
|
+
const result = await runGit(cwd, ["worktree", "add", "-b", name, targetPath]);
|
|
261
|
+
if (result.exitCode === 0)
|
|
262
|
+
return { path: targetPath, branch: name };
|
|
263
|
+
const stderr = result.stderr.trim();
|
|
264
|
+
if (/already exists/i.test(stderr)) {
|
|
265
|
+
lastError = new WorktreeError(stderr);
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
throw new WorktreeError(stderr || "git worktree add failed");
|
|
269
|
+
}
|
|
270
|
+
throw lastError ?? new WorktreeError("couldn't find a free worktree name");
|
|
271
|
+
};
|
|
272
|
+
export const removeGitWorktree = async (cwd, targetPath) => {
|
|
273
|
+
// The main worktree is never removable — not from itself, not from a linked
|
|
274
|
+
// worktree. Guard server-side so a crafted DELETE can't try it (git itself
|
|
275
|
+
// would also refuse, but this gives a clear message before spawning git).
|
|
276
|
+
const mainRoot = await mainWorktreeRoot(cwd);
|
|
277
|
+
if (mainRoot) {
|
|
278
|
+
let realTarget = targetPath;
|
|
279
|
+
try {
|
|
280
|
+
realTarget = fs.realpathSync(targetPath);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
realTarget = path.resolve(targetPath);
|
|
284
|
+
}
|
|
285
|
+
if (realTarget === mainRoot) {
|
|
286
|
+
throw new WorktreeError("can't remove the main worktree");
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
const result = await runGit(cwd, ["worktree", "remove", targetPath]);
|
|
290
|
+
if (result.exitCode !== 0) {
|
|
291
|
+
throw new WorktreeError(result.stderr.trim() || "git worktree remove failed");
|
|
292
|
+
}
|
|
58
293
|
};
|
|
59
294
|
//# sourceMappingURL=git-worktrees.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-worktrees.js","sourceRoot":"","sources":["../src/git-worktrees.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE,CAC7C,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAExE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAA2B,EAAE;IAC5E,MAAM,MAAM,GAAG,IAAI;SAChB,KAAK,CAAC,QAAQ,CAAC;SACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,OAAO,CAAC,CAAC;IACnB,MAAM,SAAS,GAAkB,EAAE,CAAC;IAEpC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAkB,IAAI,CAAC;QACjC,IAAI,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CAAC,CAAC,CAAC;IACrE,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,4BAA4B,CAAC,CAAC;IAChF,CAAC;AACH,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BatteryProbe } from "./caffeinate-battery.js";
|
|
1
2
|
import { CaffeinateController } from "./caffeinate-controller.js";
|
|
2
3
|
import type { SnapshotProcesses } from "./caffeinate-process-match.js";
|
|
3
4
|
import { SessionRegistry } from "./session-registry.js";
|
|
@@ -26,6 +27,12 @@ export interface ServerOptions {
|
|
|
26
27
|
* deterministically without spawning processes.
|
|
27
28
|
*/
|
|
28
29
|
caffeinateSnapshotProcesses?: SnapshotProcesses;
|
|
30
|
+
/**
|
|
31
|
+
* Override how keep-awake reads the machine's battery. Defaults to a real
|
|
32
|
+
* `pmset -g batt` read. Injectable so tests can drive the battery floor
|
|
33
|
+
* deterministically without shelling out.
|
|
34
|
+
*/
|
|
35
|
+
caffeinateBatteryProbe?: BatteryProbe;
|
|
29
36
|
}
|
|
30
37
|
/** Opens and (optionally) closes the browser tab for an automation run. */
|
|
31
38
|
export interface AutomationTabController {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AA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,4BAA4B,CAAC;AACpC,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import { getGitBranchInfo, getGitBranchPr, getGitDiff, getGitDiffFilePatch, getG
|
|
|
21
21
|
import { GitDiffWatcher, GIT_DIFF_WATCHER_EVENT_NAMES, } from "./git-diff-watcher.js";
|
|
22
22
|
import { HeartbeatStore } from "./heartbeat-store.js";
|
|
23
23
|
import { parseCronExpression } from "./cron-expression.js";
|
|
24
|
+
import { createGitWorktree, listGitWorktrees, removeGitWorktree } from "./git-worktrees.js";
|
|
24
25
|
import { clientToServerMessageSchema, createAutomationInputSchema, resetAutomationInputSchema, updateAutomationInputSchema, } from "./schemas.js";
|
|
25
26
|
import { Session } from "./session.js";
|
|
26
27
|
import { createNetworkPolicyMiddleware, isAllowedSourceIp, isLoopbackHost } from "./security.js";
|
|
@@ -137,6 +138,7 @@ export const createServer = async (options = {}) => {
|
|
|
137
138
|
store: caffeinatePreferencesStore,
|
|
138
139
|
listSessionPids: () => registry.pids(),
|
|
139
140
|
snapshotProcesses: options.caffeinateSnapshotProcesses,
|
|
141
|
+
batteryProbe: options.caffeinateBatteryProbe,
|
|
140
142
|
hasRecentOutput: (pids, withinMs) => registry.hasRecentOutput(pids, withinMs),
|
|
141
143
|
});
|
|
142
144
|
const clientSockets = new Set();
|
|
@@ -210,6 +212,7 @@ export const createServer = async (options = {}) => {
|
|
|
210
212
|
active: caffeinateManager.active,
|
|
211
213
|
mode: caffeinateManager.mode,
|
|
212
214
|
activityGate: caffeinateManager.activityGate,
|
|
215
|
+
batteryThreshold: caffeinateManager.batteryThreshold,
|
|
213
216
|
defaultCommands: [...caffeinateManager.defaultCommands],
|
|
214
217
|
commands: caffeinateManager.commands,
|
|
215
218
|
activeTrigger: caffeinateManager.activeTrigger,
|
|
@@ -422,6 +425,61 @@ export const createServer = async (options = {}) => {
|
|
|
422
425
|
return undefined;
|
|
423
426
|
}
|
|
424
427
|
};
|
|
428
|
+
// Resolve a worktree path (create target / remove target). Relative paths are
|
|
429
|
+
// anchored to the caller's cwd so the client can pass a project-relative name;
|
|
430
|
+
// absolute paths pass through. No traversal/containment check — the daemon
|
|
431
|
+
// already hands out unrestricted shells, so creating a worktree elsewhere is
|
|
432
|
+
// not an escalation.
|
|
433
|
+
const resolveWorktreePath = (cwd, rawPath) => {
|
|
434
|
+
if (!rawPath)
|
|
435
|
+
return null;
|
|
436
|
+
const trimmed = rawPath.trim();
|
|
437
|
+
if (!trimmed)
|
|
438
|
+
return null;
|
|
439
|
+
return path.resolve(cwd, trimmed);
|
|
440
|
+
};
|
|
441
|
+
const worktreeErrorMessage = (error) => error instanceof Error ? error.message : "git operation failed";
|
|
442
|
+
// Every worktree sharing the caller's repo. `git worktree list` returns the
|
|
443
|
+
// whole linked set from any worktree, so this single read is the complete
|
|
444
|
+
// project view — no store, no per-worktree tracking.
|
|
445
|
+
api.get("/git/worktrees", async (context) => {
|
|
446
|
+
const cwd = resolveCwdQuery(context.req.query("cwd"));
|
|
447
|
+
if (!cwd)
|
|
448
|
+
return context.json({ error: "invalid_cwd" }, HTTP_STATUS_BAD_REQUEST);
|
|
449
|
+
try {
|
|
450
|
+
return context.json(await listGitWorktrees(cwd));
|
|
451
|
+
}
|
|
452
|
+
catch (error) {
|
|
453
|
+
return context.json({ error: "git_failed", message: worktreeErrorMessage(error) }, HTTP_STATUS_BAD_REQUEST);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
api.post("/git/worktrees", async (context) => {
|
|
457
|
+
const cwd = resolveCwdQuery(context.req.query("cwd"));
|
|
458
|
+
if (!cwd)
|
|
459
|
+
return context.json({ error: "invalid_cwd" }, HTTP_STATUS_BAD_REQUEST);
|
|
460
|
+
try {
|
|
461
|
+
const result = await createGitWorktree(cwd);
|
|
462
|
+
return context.json(result, HTTP_STATUS_CREATED);
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
return context.json({ error: "git_failed", message: worktreeErrorMessage(error) }, HTTP_STATUS_BAD_REQUEST);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
api.delete("/git/worktrees", async (context) => {
|
|
469
|
+
const cwd = resolveCwdQuery(context.req.query("cwd"));
|
|
470
|
+
if (!cwd)
|
|
471
|
+
return context.json({ error: "invalid_cwd" }, HTTP_STATUS_BAD_REQUEST);
|
|
472
|
+
const targetPath = resolveWorktreePath(cwd, context.req.query("path"));
|
|
473
|
+
if (!targetPath)
|
|
474
|
+
return context.json({ error: "invalid_path" }, HTTP_STATUS_BAD_REQUEST);
|
|
475
|
+
try {
|
|
476
|
+
await removeGitWorktree(cwd, targetPath);
|
|
477
|
+
return context.json({ ok: true });
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
return context.json({ error: "git_failed", message: worktreeErrorMessage(error) }, HTTP_STATUS_BAD_REQUEST);
|
|
481
|
+
}
|
|
482
|
+
});
|
|
425
483
|
// A trigger is valid iff a schedule trigger compiles to ≥1 parseable cron;
|
|
426
484
|
// watch and event triggers are always valid (their cwd is validated
|
|
427
485
|
// separately).
|
|
@@ -833,6 +891,9 @@ export const createServer = async (options = {}) => {
|
|
|
833
891
|
else if (parsed.data.type === "caffeinate-activity-gate") {
|
|
834
892
|
caffeinateManager.setActivityGate(parsed.data.enabled);
|
|
835
893
|
}
|
|
894
|
+
else if (parsed.data.type === "caffeinate-battery-threshold") {
|
|
895
|
+
caffeinateManager.setBatteryThreshold(parsed.data.percent);
|
|
896
|
+
}
|
|
836
897
|
else {
|
|
837
898
|
session.resize(parsed.data.cols, parsed.data.rows, parsed.data.pixelWidth, parsed.data.pixelHeight);
|
|
838
899
|
}
|