oh-my-opencode 5.1.81 → 5.1.83
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/cli/index.js +443 -276
- package/dist/cli-node/index.js +443 -276
- package/dist/hooks/claude-code-hooks/handlers/empty-hook-config.fixture.d.ts +1 -0
- package/dist/index.js +650 -431
- package/dist/shared/opencode-message-dir.d.ts +1 -1
- package/dist/skills/browser/references/owned-engine/README.md +4 -2
- package/dist/skills/browser/references/owned-engine/frames-and-humans.md +9 -3
- package/dist/skills/browser/runtime/omowright/index.js +8 -8
- package/dist/skills/browser/runtime/omowright/manifest.json +4 -4
- package/dist/skills/frontend/SKILL.md +4 -2
- package/dist/skills/frontend/references/perfection/state-and-flow.md +120 -0
- package/dist/skills/visual-qa/AGENTS.md +2 -1
- package/dist/skills/visual-qa/SKILL.md +43 -11
- package/dist/skills/visual-qa/references/behaviour-evidence.md +189 -0
- package/dist/tui.js +15 -15
- package/package.json +15 -15
- package/packages/lsp-core/src/lsp/client-key.ts +14 -0
- package/packages/lsp-core/src/lsp/client-startup.ts +139 -0
- package/packages/lsp-core/src/lsp/client-wrapper.ts +4 -4
- package/packages/lsp-core/src/lsp/config-loader.ts +15 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics-group-scan.test.ts +388 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics-mixed-typescript.test.ts +124 -0
- package/packages/lsp-core/src/lsp/directory-diagnostics.test.ts +4 -4
- package/packages/lsp-core/src/lsp/directory-diagnostics.ts +38 -41
- package/packages/lsp-core/src/lsp/directory-group-scan.ts +124 -0
- package/packages/lsp-core/src/lsp/directory-server-groups.ts +84 -0
- package/packages/lsp-core/src/lsp/manager-acquisition.test.ts +115 -0
- package/packages/lsp-core/src/lsp/manager-lifecycle.test.ts +9 -9
- package/packages/lsp-core/src/lsp/manager-max-clients.test.ts +41 -16
- package/packages/lsp-core/src/lsp/manager-reaping.test.ts +119 -0
- package/packages/lsp-core/src/lsp/manager-test-support.ts +108 -0
- package/packages/lsp-core/src/lsp/manager.ts +80 -249
- package/packages/lsp-core/src/lsp/native-typescript.ts +88 -0
- package/packages/lsp-core/src/lsp/server-installation.ts +15 -7
- package/packages/lsp-core/src/lsp/server-resolution-typescript-native.test.ts +327 -0
- package/packages/lsp-core/src/lsp/server-resolution.ts +28 -2
- package/packages/lsp-core/src/lsp/timer-provider.ts +17 -0
- package/packages/lsp-core/src/lsp/typescript-project-test-support.ts +52 -0
- package/packages/lsp-daemon/dist/cli.js +486 -310
- package/packages/lsp-daemon/dist/client.js +472 -296
- package/packages/lsp-daemon/dist/index.js +476 -300
- package/packages/lsp-tools-mcp/dist/cli.js +467 -291
- package/packages/lsp-tools-mcp/dist/lsp/manager.js +160 -193
- package/packages/lsp-tools-mcp/dist/mcp.js +467 -291
- package/packages/lsp-tools-mcp/dist/tools.js +467 -291
- package/packages/omo-codex/plugin/.codex-plugin/plugin.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/bootstrap/package.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/comment-checker/package.json +1 -1
- package/packages/omo-codex/plugin/components/git-bash/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/git-bash/package.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/lazycodex-executor-verify/package.json +1 -1
- package/packages/omo-codex/plugin/components/lsp/dist/.omo-runtime-manifest.json +3 -3
- package/packages/omo-codex/plugin/components/lsp/dist/cli.js +478 -313
- package/packages/omo-codex/plugin/components/lsp/hooks/hooks.json +2 -2
- package/packages/omo-codex/plugin/components/lsp/package.json +1 -1
- package/packages/omo-codex/plugin/components/rules/hooks/hooks.json +4 -4
- package/packages/omo-codex/plugin/components/rules/package.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/teammode/package.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/telemetry/package.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ultrawork/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/hooks/hooks.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-execute-continuation/package.json +1 -1
- package/packages/omo-codex/plugin/components/ulw-loop/hooks/hooks.json +5 -5
- package/packages/omo-codex/plugin/components/ulw-loop/package.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-git-bash-mcp-reminder.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-lsp-diagnostics-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-compact-resetting-project-rule-cache.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-comments.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-lsp-diagnostics.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-checking-thread-title-hygiene.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-matching-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/post-tool-use-recording-spawn-admission.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-enforcing-unlimited-goal-budget.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-guarding-ulw-loop-spawns.json +1 -1
- package/packages/omo-codex/plugin/hooks/pre-tool-use-recommending-git-bash-mcp.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-auto-update.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-checking-bootstrap-provisioning.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/hooks/session-start-recording-session-telemetry.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-execute-continuation.json +1 -1
- package/packages/omo-codex/plugin/hooks/stop-checking-ulw-loop-resume.json +1 -1
- package/packages/omo-codex/plugin/hooks/subagent-stop-verifying-lazycodex-executor-evidence.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ultrawork-trigger.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-checking-ulw-loop-steering.json +1 -1
- package/packages/omo-codex/plugin/hooks/user-prompt-submit-loading-project-rules.json +1 -1
- package/packages/omo-codex/plugin/package-lock.json +12 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/README.md +4 -2
- package/packages/omo-codex/plugin/skills/browser/references/owned-engine/frames-and-humans.md +9 -3
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/index.js +8 -8
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/omo-codex/plugin/skills/frontend/SKILL.md +4 -2
- package/packages/omo-codex/plugin/skills/frontend/references/perfection/state-and-flow.md +120 -0
- package/packages/omo-codex/plugin/skills/visual-qa/AGENTS.md +2 -1
- package/packages/omo-codex/plugin/skills/visual-qa/SKILL.md +43 -11
- package/packages/omo-codex/plugin/skills/visual-qa/references/behaviour-evidence.md +189 -0
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +2 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/README.md +4 -2
- package/packages/shared-skills/skills/browser/references/owned-engine/frames-and-humans.md +9 -3
- package/packages/shared-skills/skills/browser/runtime/omowright/index.js +8 -8
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +4 -4
- package/packages/shared-skills/skills/frontend/SKILL.md +4 -2
- package/packages/shared-skills/skills/frontend/references/perfection/state-and-flow.md +120 -0
- package/packages/shared-skills/skills/visual-qa/AGENTS.md +2 -1
- package/packages/shared-skills/skills/visual-qa/SKILL.md +43 -11
- package/packages/shared-skills/skills/visual-qa/references/behaviour-evidence.md +189 -0
|
@@ -21,6 +21,24 @@ var realTimerProvider = {
|
|
|
21
21
|
setTimeout: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
22
22
|
clearTimeout: (handle) => clearTimeout(handle)
|
|
23
23
|
};
|
|
24
|
+
function repeatEvery(timers, intervalMs, tick) {
|
|
25
|
+
let handle = null;
|
|
26
|
+
const arm = () => {
|
|
27
|
+
handle = timers.setTimeout(() => {
|
|
28
|
+
tick();
|
|
29
|
+
if (handle !== null)
|
|
30
|
+
arm();
|
|
31
|
+
}, intervalMs);
|
|
32
|
+
if (typeof handle.unref === "function")
|
|
33
|
+
handle.unref();
|
|
34
|
+
};
|
|
35
|
+
arm();
|
|
36
|
+
return () => {
|
|
37
|
+
if (handle !== null)
|
|
38
|
+
timers.clearTimeout(handle);
|
|
39
|
+
handle = null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
24
42
|
|
|
25
43
|
// ../lsp-core/src/lsp/constants.ts
|
|
26
44
|
var DEFAULT_MAX_REFERENCES = 200;
|
|
@@ -2770,30 +2788,54 @@ function abortError2(signal) {
|
|
|
2770
2788
|
return error;
|
|
2771
2789
|
}
|
|
2772
2790
|
|
|
2773
|
-
// ../lsp-core/src/lsp/
|
|
2774
|
-
function
|
|
2775
|
-
|
|
2776
|
-
const handler = () => {
|
|
2777
|
-
cleanup().catch((error) => {
|
|
2778
|
-
reportBestEffortCleanupError("signal cleanup", error);
|
|
2779
|
-
});
|
|
2780
|
-
};
|
|
2781
|
-
for (const signal of signals) {
|
|
2782
|
-
process.on(signal, handler);
|
|
2783
|
-
}
|
|
2784
|
-
return () => {
|
|
2785
|
-
for (const signal of signals) {
|
|
2786
|
-
process.removeListener(signal, handler);
|
|
2787
|
-
}
|
|
2788
|
-
};
|
|
2791
|
+
// ../lsp-core/src/lsp/client-key.ts
|
|
2792
|
+
function lspClientKey(root, server) {
|
|
2793
|
+
return JSON.stringify([root, server.id, server.command]);
|
|
2789
2794
|
}
|
|
2790
2795
|
|
|
2791
|
-
// ../lsp-core/src/lsp/
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2796
|
+
// ../lsp-core/src/lsp/client-startup.ts
|
|
2797
|
+
class ClientStartups {
|
|
2798
|
+
constructor(now, discard) {
|
|
2799
|
+
this.now = now;
|
|
2800
|
+
this.discard = discard;
|
|
2801
|
+
}
|
|
2802
|
+
begin(request) {
|
|
2803
|
+
const { client } = request;
|
|
2804
|
+
const startedAt = this.now();
|
|
2805
|
+
const initPromise = (async () => {
|
|
2806
|
+
await client.start();
|
|
2807
|
+
await client.initialize();
|
|
2808
|
+
})();
|
|
2809
|
+
const managed = {
|
|
2810
|
+
...request,
|
|
2811
|
+
refCount: 0,
|
|
2812
|
+
pendingWaiters: 0,
|
|
2813
|
+
lastUsedAt: startedAt,
|
|
2814
|
+
initPromise,
|
|
2815
|
+
isInitializing: true,
|
|
2816
|
+
initializingSince: startedAt
|
|
2817
|
+
};
|
|
2818
|
+
initPromise.then(() => {
|
|
2819
|
+
managed.isInitializing = false;
|
|
2820
|
+
managed.initializingSince = null;
|
|
2821
|
+
managed.initPromise = null;
|
|
2822
|
+
managed.lastUsedAt = this.now();
|
|
2823
|
+
}, () => this.discard(managed));
|
|
2824
|
+
return managed;
|
|
2825
|
+
}
|
|
2826
|
+
async wait(managed, initPromise, signal) {
|
|
2827
|
+
managed.pendingWaiters++;
|
|
2828
|
+
try {
|
|
2829
|
+
await awaitWithSignal(initPromise, signal);
|
|
2830
|
+
} catch (error) {
|
|
2831
|
+
this.detach(managed);
|
|
2832
|
+
throw error;
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
detach(managed) {
|
|
2836
|
+
managed.pendingWaiters--;
|
|
2837
|
+
if (managed.pendingWaiters === 0 && managed.refCount === 0 && managed.heldByWaiters)
|
|
2838
|
+
this.discard(managed);
|
|
2797
2839
|
}
|
|
2798
2840
|
}
|
|
2799
2841
|
function awaitWithSignal(promise, signal) {
|
|
@@ -2828,36 +2870,50 @@ function awaitWithSignal(promise, signal) {
|
|
|
2828
2870
|
});
|
|
2829
2871
|
}
|
|
2830
2872
|
|
|
2873
|
+
// ../lsp-core/src/lsp/process-signal-cleanup.ts
|
|
2874
|
+
function installProcessSignalCleanup(cleanup) {
|
|
2875
|
+
const signals = process.platform === "win32" ? ["SIGINT", "SIGTERM", "SIGBREAK"] : ["SIGINT", "SIGTERM"];
|
|
2876
|
+
const handler = () => {
|
|
2877
|
+
cleanup().catch((error) => {
|
|
2878
|
+
reportBestEffortCleanupError("signal cleanup", error);
|
|
2879
|
+
});
|
|
2880
|
+
};
|
|
2881
|
+
for (const signal of signals) {
|
|
2882
|
+
process.on(signal, handler);
|
|
2883
|
+
}
|
|
2884
|
+
return () => {
|
|
2885
|
+
for (const signal of signals) {
|
|
2886
|
+
process.removeListener(signal, handler);
|
|
2887
|
+
}
|
|
2888
|
+
};
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2891
|
+
// ../lsp-core/src/lsp/manager.ts
|
|
2892
|
+
async function stopClientBestEffort(client) {
|
|
2893
|
+
try {
|
|
2894
|
+
await client.stop();
|
|
2895
|
+
} catch (error) {
|
|
2896
|
+
reportBestEffortCleanupError("client stop", error);
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2831
2900
|
class LspManager {
|
|
2832
2901
|
constructor(options = {}) {
|
|
2833
2902
|
this.clients = new Map;
|
|
2834
2903
|
this.pendingStops = new Map;
|
|
2835
2904
|
this.respawnBudgets = new Map;
|
|
2836
|
-
this.reaperHandle = null;
|
|
2837
2905
|
this.signalDisposer = null;
|
|
2838
2906
|
this.disposed = false;
|
|
2839
2907
|
this.idleTimeoutMs = options.idleTimeoutMs ?? IDLE_TIMEOUT_MS;
|
|
2840
2908
|
this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS;
|
|
2841
2909
|
this.maxResidentClients = options.maxResidentClients ?? MAX_RESIDENT_CLIENTS;
|
|
2842
|
-
this.reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
2843
2910
|
this.clientFactory = options.clientFactory ?? ((root, server) => new LspClient(root, server));
|
|
2844
2911
|
this.now = options.now ?? (() => Date.now());
|
|
2845
|
-
this.
|
|
2912
|
+
this.startups = new ClientStartups(this.now, (managed) => this.discard(managed));
|
|
2913
|
+
const reaperIntervalMs = options.reaperIntervalMs ?? REAPER_INTERVAL_MS;
|
|
2914
|
+
this.stopReaper = repeatEvery(options.timers ?? realTimerProvider, reaperIntervalMs, () => this.reapStale());
|
|
2846
2915
|
this.signalDisposer = installProcessSignalCleanup(() => this.stopAll());
|
|
2847
2916
|
}
|
|
2848
|
-
startReaper() {
|
|
2849
|
-
if (this.reaperHandle)
|
|
2850
|
-
return;
|
|
2851
|
-
this.reaperHandle = setInterval(() => {
|
|
2852
|
-
this.reapStale();
|
|
2853
|
-
}, this.reaperIntervalMs);
|
|
2854
|
-
if (typeof this.reaperHandle.unref === "function") {
|
|
2855
|
-
this.reaperHandle.unref();
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2858
|
-
getKey(root, serverId) {
|
|
2859
|
-
return `${root}::${serverId}`;
|
|
2860
|
-
}
|
|
2861
2917
|
tombstoneStop(key, client) {
|
|
2862
2918
|
const stop = stopClientBestEffort(client);
|
|
2863
2919
|
this.pendingStops.set(key, stop);
|
|
@@ -2893,18 +2949,15 @@ class LspManager {
|
|
|
2893
2949
|
budget.deadGenerations = 0;
|
|
2894
2950
|
budget.exhaustedAt = null;
|
|
2895
2951
|
}
|
|
2952
|
+
startupExpired(managed, t) {
|
|
2953
|
+
return managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs;
|
|
2954
|
+
}
|
|
2896
2955
|
reapStale() {
|
|
2897
2956
|
const t = this.now();
|
|
2898
|
-
for (const
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
this.
|
|
2902
|
-
continue;
|
|
2903
|
-
}
|
|
2904
|
-
if (!managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs) {
|
|
2905
|
-
this.clients.delete(key);
|
|
2906
|
-
this.tombstoneStop(key, managed.client);
|
|
2907
|
-
}
|
|
2957
|
+
for (const managed of [...this.clients.values()]) {
|
|
2958
|
+
const idle = !managed.isInitializing && managed.refCount === 0 && managed.pendingWaiters === 0 && t - managed.lastUsedAt > this.idleTimeoutMs;
|
|
2959
|
+
if (idle || this.startupExpired(managed, t))
|
|
2960
|
+
this.discard(managed);
|
|
2908
2961
|
}
|
|
2909
2962
|
}
|
|
2910
2963
|
evictForAdmission() {
|
|
@@ -2912,152 +2965,96 @@ class LspManager {
|
|
|
2912
2965
|
const victim = this.leastRecentlyUsedIdleClient();
|
|
2913
2966
|
if (!victim)
|
|
2914
2967
|
return;
|
|
2915
|
-
this.
|
|
2916
|
-
this.tombstoneStop(victim.key, victim.managed.client);
|
|
2968
|
+
this.discard(victim);
|
|
2917
2969
|
}
|
|
2918
2970
|
}
|
|
2919
2971
|
leastRecentlyUsedIdleClient() {
|
|
2920
2972
|
let candidate = null;
|
|
2921
|
-
for (const
|
|
2973
|
+
for (const managed of this.clients.values()) {
|
|
2922
2974
|
if (managed.refCount > 0 || managed.pendingWaiters > 0 || managed.isInitializing)
|
|
2923
2975
|
continue;
|
|
2924
|
-
if (candidate === null || managed.lastUsedAt < candidate.
|
|
2925
|
-
candidate =
|
|
2926
|
-
}
|
|
2976
|
+
if (candidate === null || managed.lastUsedAt < candidate.lastUsedAt)
|
|
2977
|
+
candidate = managed;
|
|
2927
2978
|
}
|
|
2928
2979
|
return candidate;
|
|
2929
2980
|
}
|
|
2930
|
-
|
|
2931
|
-
if (
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2981
|
+
discard(managed) {
|
|
2982
|
+
if (this.clients.get(managed.key) !== managed)
|
|
2983
|
+
return;
|
|
2984
|
+
this.clients.delete(managed.key);
|
|
2985
|
+
this.tombstoneStop(managed.key, managed.client);
|
|
2935
2986
|
}
|
|
2936
2987
|
async getClient(root, server, signal) {
|
|
2937
|
-
|
|
2938
|
-
throw new Error("LspManager has been disposed");
|
|
2939
|
-
}
|
|
2940
|
-
signal?.throwIfAborted();
|
|
2941
|
-
const key = this.getKey(root, server.id);
|
|
2988
|
+
const key = lspClientKey(root, server);
|
|
2942
2989
|
for (;; ) {
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
await awaitWithSignal(pendingStop, signal);
|
|
2990
|
+
if (this.disposed) {
|
|
2991
|
+
throw new Error("LspManager has been disposed");
|
|
2992
|
+
}
|
|
2947
2993
|
signal?.throwIfAborted();
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
let managed = this.clients.get(key);
|
|
2953
|
-
if (managed) {
|
|
2954
|
-
const t = this.now();
|
|
2955
|
-
if (managed.isInitializing && managed.initializingSince !== null && t - managed.initializingSince > this.initTimeoutMs) {
|
|
2956
|
-
this.clients.delete(key);
|
|
2957
|
-
await this.tombstoneStop(key, managed.client);
|
|
2958
|
-
managed = undefined;
|
|
2994
|
+
const pendingStop = this.pendingStops.get(key);
|
|
2995
|
+
if (pendingStop !== undefined) {
|
|
2996
|
+
await awaitWithSignal(pendingStop, signal);
|
|
2997
|
+
continue;
|
|
2959
2998
|
}
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2999
|
+
let managed = this.clients.get(key);
|
|
3000
|
+
if (managed !== undefined && this.startupExpired(managed, this.now())) {
|
|
3001
|
+
this.discard(managed);
|
|
3002
|
+
continue;
|
|
3003
|
+
}
|
|
3004
|
+
if (managed === undefined) {
|
|
3005
|
+
this.evictForAdmission();
|
|
3006
|
+
this.ensureRespawnAllowed(key, root, server.id);
|
|
3007
|
+
managed = this.startClient(key, root, server, true);
|
|
3008
|
+
}
|
|
3009
|
+
const { initPromise } = managed;
|
|
3010
|
+
if (initPromise !== null) {
|
|
3011
|
+
await this.startups.wait(managed, initPromise, signal);
|
|
3012
|
+
if (signal?.aborted) {
|
|
3013
|
+
this.startups.detach(managed);
|
|
3014
|
+
signal.throwIfAborted();
|
|
2970
3015
|
}
|
|
2971
3016
|
managed.pendingWaiters--;
|
|
2972
3017
|
}
|
|
2973
|
-
if (
|
|
2974
|
-
|
|
2975
|
-
signal.throwIfAborted();
|
|
2976
|
-
}
|
|
3018
|
+
if (this.clients.get(key) !== managed)
|
|
3019
|
+
continue;
|
|
2977
3020
|
if (!managed.client.isAlive()) {
|
|
2978
3021
|
this.recordDeadGeneration(key);
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
}
|
|
2982
|
-
await this.tombstoneStop(key, managed.client);
|
|
2983
|
-
return this.getClient(root, server, signal);
|
|
3022
|
+
this.discard(managed);
|
|
3023
|
+
continue;
|
|
2984
3024
|
}
|
|
2985
3025
|
this.markHealthyGeneration(key);
|
|
2986
3026
|
managed.refCount++;
|
|
2987
3027
|
managed.lastUsedAt = this.now();
|
|
2988
3028
|
return managed.client;
|
|
2989
3029
|
}
|
|
2990
|
-
|
|
2991
|
-
|
|
3030
|
+
}
|
|
3031
|
+
startClient(key, root, server, heldByWaiters) {
|
|
2992
3032
|
const client = this.clientFactory(root, server);
|
|
2993
|
-
const
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
await client.initialize();
|
|
2997
|
-
})();
|
|
2998
|
-
const newManaged = {
|
|
2999
|
-
client,
|
|
3000
|
-
refCount: 0,
|
|
3001
|
-
pendingWaiters: 1,
|
|
3002
|
-
lastUsedAt: initStartedAt,
|
|
3003
|
-
initPromise,
|
|
3004
|
-
isInitializing: true,
|
|
3005
|
-
initializingSince: initStartedAt
|
|
3006
|
-
};
|
|
3007
|
-
this.clients.set(key, newManaged);
|
|
3008
|
-
try {
|
|
3009
|
-
await awaitWithSignal(initPromise, signal);
|
|
3010
|
-
} catch (err) {
|
|
3011
|
-
newManaged.pendingWaiters--;
|
|
3012
|
-
if (this.clients.get(key) === newManaged) {
|
|
3013
|
-
this.clients.delete(key);
|
|
3014
|
-
}
|
|
3015
|
-
await this.tombstoneStop(key, client);
|
|
3016
|
-
throw err;
|
|
3017
|
-
}
|
|
3018
|
-
newManaged.pendingWaiters--;
|
|
3019
|
-
newManaged.isInitializing = false;
|
|
3020
|
-
newManaged.initializingSince = null;
|
|
3021
|
-
newManaged.initPromise = null;
|
|
3022
|
-
if (signal?.aborted) {
|
|
3023
|
-
await this.tryDeleteIfOrphaned(key, newManaged);
|
|
3024
|
-
signal.throwIfAborted();
|
|
3025
|
-
}
|
|
3026
|
-
if (!client.isAlive()) {
|
|
3027
|
-
this.recordDeadGeneration(key);
|
|
3028
|
-
if (this.clients.get(key) === newManaged) {
|
|
3029
|
-
this.clients.delete(key);
|
|
3030
|
-
}
|
|
3031
|
-
await this.tombstoneStop(key, client);
|
|
3032
|
-
return this.getClient(root, server, signal);
|
|
3033
|
-
}
|
|
3034
|
-
this.markHealthyGeneration(key);
|
|
3035
|
-
newManaged.refCount++;
|
|
3036
|
-
newManaged.lastUsedAt = this.now();
|
|
3037
|
-
return client;
|
|
3033
|
+
const managed = this.startups.begin({ key, root, serverId: server.id, client, heldByWaiters });
|
|
3034
|
+
this.clients.set(key, managed);
|
|
3035
|
+
return managed;
|
|
3038
3036
|
}
|
|
3039
|
-
releaseClient(root,
|
|
3040
|
-
const
|
|
3041
|
-
|
|
3037
|
+
releaseClient(root, server, client) {
|
|
3038
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3039
|
+
if (client !== undefined && managed?.client !== client)
|
|
3040
|
+
return;
|
|
3042
3041
|
if (managed && managed.refCount > 0) {
|
|
3043
3042
|
managed.refCount--;
|
|
3044
3043
|
managed.lastUsedAt = this.now();
|
|
3045
3044
|
}
|
|
3046
3045
|
}
|
|
3047
|
-
invalidateClient(root,
|
|
3048
|
-
const
|
|
3049
|
-
const managed = this.clients.get(key);
|
|
3046
|
+
invalidateClient(root, server, client) {
|
|
3047
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3050
3048
|
if (!managed)
|
|
3051
3049
|
return;
|
|
3052
3050
|
if (client && managed.client !== client)
|
|
3053
3051
|
return;
|
|
3054
|
-
this.
|
|
3055
|
-
this.tombstoneStop(key, managed.client);
|
|
3052
|
+
this.discard(managed);
|
|
3056
3053
|
}
|
|
3057
3054
|
warmupClient(root, server) {
|
|
3058
3055
|
if (this.disposed)
|
|
3059
3056
|
return;
|
|
3060
|
-
const key =
|
|
3057
|
+
const key = lspClientKey(root, server);
|
|
3061
3058
|
if (this.clients.has(key) || this.pendingStops.has(key))
|
|
3062
3059
|
return;
|
|
3063
3060
|
this.evictForAdmission();
|
|
@@ -3066,45 +3063,18 @@ class LspManager {
|
|
|
3066
3063
|
} catch {
|
|
3067
3064
|
return;
|
|
3068
3065
|
}
|
|
3069
|
-
|
|
3070
|
-
const initStartedAt = this.now();
|
|
3071
|
-
const initPromise = (async () => {
|
|
3072
|
-
await client.start();
|
|
3073
|
-
await client.initialize();
|
|
3074
|
-
})();
|
|
3075
|
-
const managed = {
|
|
3076
|
-
client,
|
|
3077
|
-
refCount: 0,
|
|
3078
|
-
pendingWaiters: 0,
|
|
3079
|
-
lastUsedAt: initStartedAt,
|
|
3080
|
-
initPromise,
|
|
3081
|
-
isInitializing: true,
|
|
3082
|
-
initializingSince: initStartedAt
|
|
3083
|
-
};
|
|
3084
|
-
this.clients.set(key, managed);
|
|
3085
|
-
initPromise.then(() => {
|
|
3086
|
-
managed.isInitializing = false;
|
|
3087
|
-
managed.initializingSince = null;
|
|
3088
|
-
managed.initPromise = null;
|
|
3089
|
-
managed.lastUsedAt = this.now();
|
|
3090
|
-
}, () => {
|
|
3091
|
-
if (this.clients.get(key) === managed) {
|
|
3092
|
-
this.clients.delete(key);
|
|
3093
|
-
}
|
|
3094
|
-
this.tombstoneStop(key, client);
|
|
3095
|
-
});
|
|
3066
|
+
this.startClient(key, root, server, false);
|
|
3096
3067
|
}
|
|
3097
|
-
isServerInitializing(root,
|
|
3098
|
-
const managed = this.clients.get(
|
|
3068
|
+
isServerInitializing(root, server) {
|
|
3069
|
+
const managed = this.clients.get(lspClientKey(root, server));
|
|
3099
3070
|
return managed?.isInitializing ?? false;
|
|
3100
3071
|
}
|
|
3101
3072
|
getSnapshot() {
|
|
3102
3073
|
const snapshots = [];
|
|
3103
|
-
for (const
|
|
3104
|
-
const [root, serverId] = key.split("::");
|
|
3074
|
+
for (const managed of this.clients.values()) {
|
|
3105
3075
|
snapshots.push({
|
|
3106
|
-
root,
|
|
3107
|
-
serverId,
|
|
3076
|
+
root: managed.root,
|
|
3077
|
+
serverId: managed.serverId,
|
|
3108
3078
|
refCount: managed.refCount,
|
|
3109
3079
|
pendingWaiters: managed.pendingWaiters,
|
|
3110
3080
|
lastUsedAt: managed.lastUsedAt,
|
|
@@ -3115,18 +3085,15 @@ class LspManager {
|
|
|
3115
3085
|
}
|
|
3116
3086
|
return snapshots;
|
|
3117
3087
|
}
|
|
3118
|
-
hasClient(root,
|
|
3119
|
-
return this.clients.has(
|
|
3088
|
+
hasClient(root, server) {
|
|
3089
|
+
return this.clients.has(lspClientKey(root, server));
|
|
3120
3090
|
}
|
|
3121
3091
|
clientCount() {
|
|
3122
3092
|
return this.clients.size;
|
|
3123
3093
|
}
|
|
3124
3094
|
async stopAll() {
|
|
3125
3095
|
this.disposed = true;
|
|
3126
|
-
|
|
3127
|
-
clearInterval(this.reaperHandle);
|
|
3128
|
-
this.reaperHandle = null;
|
|
3129
|
-
}
|
|
3096
|
+
this.stopReaper();
|
|
3130
3097
|
if (this.signalDisposer) {
|
|
3131
3098
|
this.signalDisposer();
|
|
3132
3099
|
this.signalDisposer = null;
|