@muggleai/works 5.27.0-staging.236 → 5.27.0-staging.237
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/.claude-plugin/marketplace.json +1 -1
- package/README.md +1 -1
- package/dist/{chunk-KR7MX7M5.js → chunk-GCWJMRYJ.js} +91 -12
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-mcp.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/.mcp.json +1 -1
- package/dist/plugin/hooks/README.md +5 -4
- package/dist/plugin/hooks/hooks.json +92 -0
- package/dist/plugin/scripts/gc-state.sh +8 -0
- package/dist/plugin/scripts/guardrail-dispatch.sh +4 -2
- package/dist/plugin/scripts/guardrail-lib.sh +27 -0
- package/dist/plugin/scripts/guardrails.mjs +45 -4
- package/dist/release-manifest.json +3 -3
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-mcp.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/.mcp.json +1 -1
- package/plugin/hooks/README.md +5 -4
- package/plugin/hooks/hooks.json +92 -0
- package/plugin/scripts/gc-state.sh +8 -0
- package/plugin/scripts/guardrail-dispatch.sh +4 -2
- package/plugin/scripts/guardrail-lib.sh +27 -0
- package/plugin/scripts/guardrails.mjs +45 -4
- package/scripts/electron-app-install-dir.mjs +63 -12
- package/scripts/postinstall.mjs +89 -30
- package/scripts/running-studio-installs.mjs +78 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { platform } from "node:os";
|
|
3
|
+
|
|
4
|
+
const PROCESS_LIST_TIMEOUT_MS = 15_000;
|
|
5
|
+
|
|
6
|
+
const WINDOWS_PROCESS_PATHS_COMMAND = "Get-CimInstance Win32_Process | ForEach-Object { $_.ExecutablePath }";
|
|
7
|
+
|
|
8
|
+
const IS_CASE_INSENSITIVE_PLATFORM = platform() === "win32";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Normalize an install directory name for comparison with the names
|
|
12
|
+
* {@link listRunningInstallDirectoryNames} returns.
|
|
13
|
+
* @param {string} directoryName - Directory name under the Electron app directory.
|
|
14
|
+
* @returns {string} The name, lower-cased where paths compare case-insensitively.
|
|
15
|
+
*/
|
|
16
|
+
export function normalizeInstallDirectoryName(directoryName) {
|
|
17
|
+
return IS_CASE_INSENSITIVE_PLATFORM ? directoryName.toLowerCase() : directoryName;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Names of the `appDir` subdirectories that any of the given process paths run from.
|
|
22
|
+
* @param {object} params - Match parameters.
|
|
23
|
+
* @param {string} params.appDir - Base Electron app directory.
|
|
24
|
+
* @param {string[]} params.processPaths - Executable paths or command lines of running processes.
|
|
25
|
+
* @param {boolean} params.isCaseInsensitive - Whether paths compare case-insensitively.
|
|
26
|
+
* @returns {Set<string>} Directory names, lower-cased when `isCaseInsensitive`.
|
|
27
|
+
*/
|
|
28
|
+
export function findInstallDirectoryNamesInProcessPaths({ appDir, processPaths, isCaseInsensitive }) {
|
|
29
|
+
const normalizePath = (pathText) => (isCaseInsensitive ? pathText.toLowerCase() : pathText);
|
|
30
|
+
const appDirPrefix = normalizePath(appDir.replace(/[\\/]+$/, ""));
|
|
31
|
+
const installDirectoryNames = new Set();
|
|
32
|
+
for (const processPath of processPaths) {
|
|
33
|
+
const normalizedProcessPath = normalizePath(processPath);
|
|
34
|
+
let matchIndex = normalizedProcessPath.indexOf(appDirPrefix);
|
|
35
|
+
while (matchIndex !== -1) {
|
|
36
|
+
const afterPrefix = normalizedProcessPath.slice(matchIndex + appDirPrefix.length);
|
|
37
|
+
const [, directoryName] = afterPrefix.match(/^[\\/]([^\\/]+)/) ?? [];
|
|
38
|
+
if (directoryName) {
|
|
39
|
+
installDirectoryNames.add(directoryName);
|
|
40
|
+
}
|
|
41
|
+
matchIndex = normalizedProcessPath.indexOf(appDirPrefix, matchIndex + 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return installDirectoryNames;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function listProcessPaths() {
|
|
48
|
+
const processList = IS_CASE_INSENSITIVE_PLATFORM
|
|
49
|
+
? spawnSync("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", WINDOWS_PROCESS_PATHS_COMMAND], {
|
|
50
|
+
encoding: "utf-8",
|
|
51
|
+
windowsHide: true,
|
|
52
|
+
timeout: PROCESS_LIST_TIMEOUT_MS,
|
|
53
|
+
})
|
|
54
|
+
: spawnSync("ps", ["-A", "-ww", "-o", "command="], { encoding: "utf-8", timeout: PROCESS_LIST_TIMEOUT_MS });
|
|
55
|
+
if (processList.error || processList.status !== 0) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
return processList.stdout.split(/\r?\n/).filter((line) => line.trim() !== "");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Names of the studio install directories a running process executes from, so
|
|
63
|
+
* an install never deletes a runner another session is using.
|
|
64
|
+
* @param {object} params - Lookup parameters.
|
|
65
|
+
* @param {string} params.appDir - Base Electron app directory.
|
|
66
|
+
* @returns {Set<string> | null} Normalized directory names, or null when running processes could not be listed.
|
|
67
|
+
*/
|
|
68
|
+
export function listRunningInstallDirectoryNames({ appDir }) {
|
|
69
|
+
const processPaths = listProcessPaths();
|
|
70
|
+
if (processPaths === null) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
return findInstallDirectoryNamesInProcessPaths({
|
|
74
|
+
appDir: appDir,
|
|
75
|
+
processPaths: processPaths,
|
|
76
|
+
isCaseInsensitive: IS_CASE_INSENSITIVE_PLATFORM,
|
|
77
|
+
});
|
|
78
|
+
}
|