codeloop-mcp-server 0.1.29 → 0.1.30
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli_cache_warmer.d.ts","sourceRoot":"","sources":["../../src/auth/cli_cache_warmer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli_cache_warmer.d.ts","sourceRoot":"","sources":["../../src/auth/cli_cache_warmer.ts"],"names":[],"mappings":"AAoHA;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAAG,IAAI,CA6DhF;AAED,mGAAmG;AACnG,wBAAgB,wBAAwB,IAAI,IAAI,CAa/C"}
|
|
@@ -37,18 +37,25 @@
|
|
|
37
37
|
* - `NO_UPDATE_NOTIFIER=1`
|
|
38
38
|
* - `CODELOOP_SKIP_UPDATE_CHECK=1`
|
|
39
39
|
* - `CODELOOP_SKIP_CLI_WARM=1` (escape hatch specific to this)
|
|
40
|
-
* 4. Throttle to once per ~
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* 5.
|
|
40
|
+
* 4. Throttle to once per ~1h via a small marker file. Long enough to
|
|
41
|
+
* avoid spamming users who relaunch the editor many times a day,
|
|
42
|
+
* short enough that a freshly-published CLI lands on the user's
|
|
43
|
+
* machine within a single working session.
|
|
44
|
+
* 5. **Marker is written ONLY after the child exits with code 0.**
|
|
45
|
+
* If npx is missing, the network is down, or anything else fails,
|
|
46
|
+
* the next MCP-server bounce retries from scratch instead of
|
|
47
|
+
* waiting out a 1-hour cooldown on a stale state.
|
|
48
|
+
* 6. `CODELOOP_FORCE_CLI_WARM=1` bypasses the throttle entirely —
|
|
49
|
+
* used by `codeloop doctor` and by users debugging Windows
|
|
50
|
+
* edge-cases who want to force a fresh warm without waiting.
|
|
51
|
+
* 7. Best-effort everywhere: any error is swallowed silently. The
|
|
45
52
|
* worst case is the user gets the prompt they'd have got anyway.
|
|
46
53
|
*/
|
|
47
54
|
import { spawn } from "node:child_process";
|
|
48
55
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
49
56
|
import { join } from "node:path";
|
|
50
57
|
import { homedir, platform } from "node:os";
|
|
51
|
-
const THROTTLE_MS =
|
|
58
|
+
const THROTTLE_MS = 60 * 60 * 1_000; // 1 hour
|
|
52
59
|
function userHome() {
|
|
53
60
|
return process.env.HOME ?? process.env.USERPROFILE ?? homedir();
|
|
54
61
|
}
|
|
@@ -77,6 +84,11 @@ function writeMarker() {
|
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
function shouldSkip() {
|
|
87
|
+
// Force flag always wins — used by `codeloop doctor --warm-cli` and
|
|
88
|
+
// by users who want to bypass the 1h cooldown for testing.
|
|
89
|
+
if (process.env.CODELOOP_FORCE_CLI_WARM === "1") {
|
|
90
|
+
return { skip: false };
|
|
91
|
+
}
|
|
80
92
|
if (process.env.CODELOOP_SKIP_CLI_WARM === "1") {
|
|
81
93
|
return { skip: true, reason: "CODELOOP_SKIP_CLI_WARM=1" };
|
|
82
94
|
}
|
|
@@ -90,7 +102,7 @@ function shouldSkip() {
|
|
|
90
102
|
return { skip: true, reason: "CI=true" };
|
|
91
103
|
}
|
|
92
104
|
if (recentlyWarmed()) {
|
|
93
|
-
return { skip: true, reason: "throttled (warmed within last
|
|
105
|
+
return { skip: true, reason: "throttled (warmed within last hour)" };
|
|
94
106
|
}
|
|
95
107
|
return { skip: false };
|
|
96
108
|
}
|
|
@@ -111,14 +123,11 @@ export function warmCliCache(opts = {}) {
|
|
|
111
123
|
// Stay quiet on the happy path (throttled) — only mention explicit
|
|
112
124
|
// opt-outs once so users with `CODELOOP_SKIP_CLI_WARM=1` know it
|
|
113
125
|
// took effect.
|
|
114
|
-
if (decision.reason !== "throttled (warmed within last
|
|
126
|
+
if (decision.reason !== "throttled (warmed within last hour)") {
|
|
115
127
|
log(`skipped: ${decision.reason}`);
|
|
116
128
|
}
|
|
117
129
|
return;
|
|
118
130
|
}
|
|
119
|
-
// Write the marker FIRST. If the child crashes we don't want to retry
|
|
120
|
-
// on every MCP-server bounce — better one missed warm than a hot loop.
|
|
121
|
-
writeMarker();
|
|
122
131
|
// Spawn cross-platform. On Windows the `npx` shim is a .cmd file, so
|
|
123
132
|
// we need `shell: true` (or the explicit `cmd.exe` invocation that
|
|
124
133
|
// child_process.spawn uses under the hood when shell=true).
|
|
@@ -136,8 +145,22 @@ export function warmCliCache(opts = {}) {
|
|
|
136
145
|
log(`spawn failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
137
146
|
return;
|
|
138
147
|
}
|
|
148
|
+
log("warming codeloop CLI cache in the background (npx -y codeloop@latest)");
|
|
139
149
|
child.on("error", (err) => {
|
|
140
|
-
log(`child errored: ${err.message}`);
|
|
150
|
+
log(`child errored: ${err.message} — will retry on next MCP-server launch`);
|
|
151
|
+
});
|
|
152
|
+
// Only mark the warm as "done" if the child exited cleanly. If it
|
|
153
|
+
// failed (network down, npx missing, signal kill) we leave the
|
|
154
|
+
// marker untouched so the very next MCP bounce retries — better
|
|
155
|
+
// than waiting an hour on a known-bad state.
|
|
156
|
+
child.on("exit", (code, signal) => {
|
|
157
|
+
if (code === 0) {
|
|
158
|
+
writeMarker();
|
|
159
|
+
log("CLI cache warm complete — `npx codeloop ...` will skip the install prompt");
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
log(`warm exited code=${code ?? "?"} signal=${signal ?? "?"} — will retry next launch`);
|
|
163
|
+
}
|
|
141
164
|
});
|
|
142
165
|
// Detach so the MCP server can shut down without waiting on the
|
|
143
166
|
// warm-up. After unref(), Node treats the child as if it weren't
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli_cache_warmer.js","sourceRoot":"","sources":["../../src/auth/cli_cache_warmer.ts"],"names":[],"mappings":"A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