@in-the-loop-labs/pair-review 5.4.0 → 5.4.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/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
- package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
- package/public/index.html +1 -0
- package/public/js/components/AdvancedConfigTab.js +18 -108
- package/public/js/components/VoiceCentricConfigTab.js +18 -108
- package/public/js/index.js +18 -5
- package/public/js/modules/diff-renderer.js +7 -6
- package/public/js/utils/council-timeout.js +203 -0
- package/public/local.html +4 -0
- package/public/pr.html +4 -0
- package/src/ai/copilot-provider.js +21 -2
- package/src/ai/cursor-agent-provider.js +21 -2
- package/src/ai/opencode-provider.js +21 -2
- package/src/database.js +240 -59
- package/src/git/worktree-pool-lifecycle.js +152 -33
- package/src/git/worktree-pool-usage.js +20 -0
- package/src/git/worktree.js +14 -5
- package/src/main.js +18 -6
- package/src/routes/pr.js +11 -14
- package/src/routes/reviews.js +8 -30
- package/src/routes/setup.js +22 -9
- package/src/setup/pr-setup.js +12 -3
- package/src/utils/diff-file-content.js +62 -25
- package/src/utils/json-extractor.js +267 -13
- package/src/utils/pr-file-blob-cache.js +134 -0
- package/src/utils/process-liveness.js +64 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright 2026 Tim Perkins (tjwp) | SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Process liveness helpers.
|
|
6
|
+
*
|
|
7
|
+
* Used to decide whether a pair-review process recorded as the holder of a
|
|
8
|
+
* shared resource (e.g. a worktree_pool row) is still running. Every
|
|
9
|
+
* uncertain answer errs toward "alive": wrongly treating a live holder as
|
|
10
|
+
* dead lets this process reclaim a worktree another process is using, which
|
|
11
|
+
* is far worse than leaving a dead holder's worktree parked until the next
|
|
12
|
+
* startup.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const os = require('os');
|
|
16
|
+
|
|
17
|
+
const defaults = {
|
|
18
|
+
kill: (pid, signal) => process.kill(pid, signal),
|
|
19
|
+
now: () => Date.now(),
|
|
20
|
+
uptime: () => os.uptime(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Return whether a process with the given PID currently exists.
|
|
25
|
+
*
|
|
26
|
+
* Uses signal 0, which performs the existence/permission check without
|
|
27
|
+
* delivering a signal.
|
|
28
|
+
*
|
|
29
|
+
* @param {number} pid - Process ID to probe
|
|
30
|
+
* @param {Object} [_deps] - Dependency overrides for testing ({ kill })
|
|
31
|
+
* @returns {boolean} false for an invalid PID or ESRCH; true otherwise
|
|
32
|
+
* (success, EPERM — exists but owned by another user — and any other error,
|
|
33
|
+
* so an unexpected failure never causes a live holder to be treated as dead)
|
|
34
|
+
*/
|
|
35
|
+
function isProcessAlive(pid, _deps = {}) {
|
|
36
|
+
const deps = { ...defaults, ..._deps };
|
|
37
|
+
if (pid == null || !Number.isInteger(pid) || pid <= 0) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
deps.kill(pid, 0);
|
|
42
|
+
return true;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
if (err && err.code === 'ESRCH') return false;
|
|
45
|
+
// EPERM: the process exists but we may not signal it.
|
|
46
|
+
// Anything else: unknown — fail safe and treat the holder as alive.
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Approximate wall-clock time (ms since epoch) at which the OS booted.
|
|
53
|
+
* A holder claim stamped before this moment cannot belong to a process that
|
|
54
|
+
* is running now, regardless of what PID it recorded.
|
|
55
|
+
*
|
|
56
|
+
* @param {Object} [_deps] - Dependency overrides for testing ({ now, uptime })
|
|
57
|
+
* @returns {number}
|
|
58
|
+
*/
|
|
59
|
+
function getBootTimeMs(_deps = {}) {
|
|
60
|
+
const deps = { ...defaults, ..._deps };
|
|
61
|
+
return deps.now() - deps.uptime() * 1000;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = { isProcessAlive, getBootTimeMs };
|