lazycodex-ai 5.1.42 → 5.1.43
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 +109 -26
- package/dist/cli/service-auth/cli-keystore.fixture.d.ts +1 -7
- package/dist/cli/service-auth/index.d.ts +1 -1
- package/dist/cli/service-auth/keystore.d.ts +8 -2
- package/dist/cli/service-auth/secret-service-lock.d.ts +4 -0
- package/dist/cli/service-auth/session.d.ts +7 -1
- package/dist/cli-node/index.js +109 -26
- package/package.json +1 -1
- package/packages/lsp-daemon/dist/cli.js +363 -35
- package/packages/lsp-daemon/dist/client.js +341 -13
- package/packages/lsp-daemon/dist/index.js +344 -16
- package/packages/lsp-tools-mcp/dist/cli.js +333 -5
- package/packages/lsp-tools-mcp/dist/mcp.js +333 -5
- package/packages/lsp-tools-mcp/dist/tools.js +333 -5
- 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 +358 -36
- 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/dist/cli.js +2 -0
- package/packages/omo-codex/plugin/components/telemetry/dist/posthog.js +2 -0
- 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 +17 -12
- package/packages/omo-codex/plugin/package.json +1 -1
- package/packages/omo-codex/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
- package/packages/omo-codex/scripts/install-dist/install-local.mjs +4 -2
- package/packages/shared-skills/skills/browser/runtime/omowright/manifest.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { spawn as
|
|
4
|
+
import { spawn as spawn4 } from "node:child_process";
|
|
5
5
|
import { argv, execPath as execPath2, stderr } from "node:process";
|
|
6
6
|
|
|
7
7
|
// src/codex-hook-cli.ts
|
|
8
8
|
import { stdin as processStdin } from "node:process";
|
|
9
9
|
|
|
10
10
|
// src/codex-hook.ts
|
|
11
|
-
import { readFileSync as
|
|
12
|
-
import { homedir as
|
|
13
|
-
import { join as
|
|
11
|
+
import { readFileSync as readFileSync10, realpathSync as realpathSync7 } from "node:fs";
|
|
12
|
+
import { homedir as homedir4 } from "node:os";
|
|
13
|
+
import { join as join12, resolve as resolve13 } from "node:path";
|
|
14
14
|
|
|
15
15
|
// ../../../../lsp-daemon/dist/client.js
|
|
16
|
-
import { statSync as
|
|
16
|
+
import { statSync as statSync6 } from "node:fs";
|
|
17
17
|
import { isAbsolute as isAbsolute6 } from "node:path";
|
|
18
18
|
import { connect } from "node:net";
|
|
19
19
|
import { setTimeout as delay } from "node:timers/promises";
|
|
@@ -77,7 +77,12 @@ import { join as join6, resolve as resolve9 } from "node:path";
|
|
|
77
77
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
78
78
|
import { lstatSync as lstatSync6, readdirSync as readdirSync4 } from "node:fs";
|
|
79
79
|
import { join as join7 } from "node:path";
|
|
80
|
-
import {
|
|
80
|
+
import { resolve as resolve10 } from "node:path";
|
|
81
|
+
import { spawn as spawn3 } from "node:child_process";
|
|
82
|
+
import { existsSync as existsSync13, mkdtempSync, readFileSync as readFileSync6, rmSync as rmSync2, statSync as statSync5, writeFileSync as writeFileSync3 } from "node:fs";
|
|
83
|
+
import { homedir as homedir3, tmpdir as tmpdir2 } from "node:os";
|
|
84
|
+
import { dirname as dirname11, join as join8, resolve as resolve11 } from "node:path";
|
|
85
|
+
import { readFileSync as readFileSync7, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync4 } from "node:fs";
|
|
81
86
|
|
|
82
87
|
class LspRequestContextParseError extends Error {
|
|
83
88
|
constructor(code, message) {
|
|
@@ -5008,6 +5013,310 @@ function missingDependencyAvailability(error) {
|
|
|
5008
5013
|
}
|
|
5009
5014
|
}
|
|
5010
5015
|
}
|
|
5016
|
+
var TSC_LINE = /^(.+?)\((\d+),(\d+)\): (error|warning|message) (TS\d+): (.*)$/;
|
|
5017
|
+
var TSC_SEVERITY = { error: 1, warning: 2, message: 3 };
|
|
5018
|
+
function parseBunCheckOutput(stdout, cwd) {
|
|
5019
|
+
const results = [];
|
|
5020
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
5021
|
+
const match = TSC_LINE.exec(line);
|
|
5022
|
+
if (match) {
|
|
5023
|
+
const [, path, lineNumber, column, severity, code, message] = match;
|
|
5024
|
+
const start = { line: Number(lineNumber) - 1, character: Number(column) - 1 };
|
|
5025
|
+
results.push({
|
|
5026
|
+
file: resolve10(cwd, path ?? ""),
|
|
5027
|
+
diagnostic: {
|
|
5028
|
+
range: { start, end: start },
|
|
5029
|
+
severity: TSC_SEVERITY[severity ?? "error"] ?? 1,
|
|
5030
|
+
code: code ?? "",
|
|
5031
|
+
source: "bun check",
|
|
5032
|
+
message: message ?? ""
|
|
5033
|
+
}
|
|
5034
|
+
});
|
|
5035
|
+
continue;
|
|
5036
|
+
}
|
|
5037
|
+
const previous = results[results.length - 1];
|
|
5038
|
+
if (previous !== undefined && /^\s+\S/.test(line)) {
|
|
5039
|
+
previous.diagnostic.message = `${previous.diagnostic.message}
|
|
5040
|
+
${line.trim()}`;
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
return results;
|
|
5044
|
+
}
|
|
5045
|
+
function parseBunLintJson(stdout) {
|
|
5046
|
+
let parsed;
|
|
5047
|
+
try {
|
|
5048
|
+
parsed = JSON.parse(stdout);
|
|
5049
|
+
} catch {
|
|
5050
|
+
return;
|
|
5051
|
+
}
|
|
5052
|
+
if (!Array.isArray(parsed))
|
|
5053
|
+
return;
|
|
5054
|
+
const results = [];
|
|
5055
|
+
for (const entry of parsed) {
|
|
5056
|
+
if (entry === null || typeof entry !== "object")
|
|
5057
|
+
continue;
|
|
5058
|
+
const filePath = entry.filePath;
|
|
5059
|
+
const messages = entry.messages;
|
|
5060
|
+
if (typeof filePath !== "string" || !Array.isArray(messages))
|
|
5061
|
+
continue;
|
|
5062
|
+
for (const raw of messages) {
|
|
5063
|
+
const start = { line: Math.max(0, (raw.line ?? 1) - 1), character: Math.max(0, (raw.column ?? 1) - 1) };
|
|
5064
|
+
const end = {
|
|
5065
|
+
line: raw.endLine === undefined ? start.line : Math.max(0, raw.endLine - 1),
|
|
5066
|
+
character: raw.endColumn === undefined ? start.character : Math.max(0, raw.endColumn - 1)
|
|
5067
|
+
};
|
|
5068
|
+
results.push({
|
|
5069
|
+
file: filePath,
|
|
5070
|
+
diagnostic: {
|
|
5071
|
+
range: { start, end },
|
|
5072
|
+
severity: raw.severity === 2 ? 1 : 2,
|
|
5073
|
+
...raw.ruleId ? { code: raw.ruleId } : {},
|
|
5074
|
+
source: "bun lint",
|
|
5075
|
+
message: raw.message ?? ""
|
|
5076
|
+
}
|
|
5077
|
+
});
|
|
5078
|
+
}
|
|
5079
|
+
}
|
|
5080
|
+
return results;
|
|
5081
|
+
}
|
|
5082
|
+
var BUN_LOCKFILES = ["bun.lock", "bun.lockb", "bunfig.toml"];
|
|
5083
|
+
var RUNNABLE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".cts", ".cjs", ".js", ".mjs", ".mts"];
|
|
5084
|
+
var BIN_SUFFIXES = process.platform === "win32" ? [".exe", ".bunx", ".cmd", ""] : [""];
|
|
5085
|
+
var PROBE_TIMEOUT_MS2 = 1e4;
|
|
5086
|
+
var UNFORMATTED_PROBE = `const a=1
|
|
5087
|
+
`;
|
|
5088
|
+
var probeCache = new Map;
|
|
5089
|
+
function findBunProjectRoot(start, home = homedir3()) {
|
|
5090
|
+
const stopAt = resolve11(home);
|
|
5091
|
+
let dir = resolve11(start);
|
|
5092
|
+
for (;; ) {
|
|
5093
|
+
if (dir === stopAt)
|
|
5094
|
+
return;
|
|
5095
|
+
if (BUN_LOCKFILES.some((name) => existsSync13(join8(dir, name))))
|
|
5096
|
+
return dir;
|
|
5097
|
+
if (packageManagerIsBun(join8(dir, "package.json")))
|
|
5098
|
+
return dir;
|
|
5099
|
+
if (existsSync13(join8(dir, ".git")))
|
|
5100
|
+
return;
|
|
5101
|
+
const parent = dirname11(dir);
|
|
5102
|
+
if (parent === dir)
|
|
5103
|
+
return;
|
|
5104
|
+
dir = parent;
|
|
5105
|
+
}
|
|
5106
|
+
}
|
|
5107
|
+
function packageManagerIsBun(packageJsonPath) {
|
|
5108
|
+
const manifest = readJsonObject(packageJsonPath);
|
|
5109
|
+
const packageManager = manifest?.["packageManager"];
|
|
5110
|
+
return typeof packageManager === "string" && packageManager.startsWith("bun@");
|
|
5111
|
+
}
|
|
5112
|
+
function readJsonObject(path) {
|
|
5113
|
+
if (!existsSync13(path))
|
|
5114
|
+
return;
|
|
5115
|
+
try {
|
|
5116
|
+
const parsed = JSON.parse(readFileSync6(path, "utf8"));
|
|
5117
|
+
return parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : undefined;
|
|
5118
|
+
} catch {
|
|
5119
|
+
return;
|
|
5120
|
+
}
|
|
5121
|
+
}
|
|
5122
|
+
function isFile(path) {
|
|
5123
|
+
try {
|
|
5124
|
+
return statSync5(path).isFile();
|
|
5125
|
+
} catch {
|
|
5126
|
+
return false;
|
|
5127
|
+
}
|
|
5128
|
+
}
|
|
5129
|
+
function isDirectory(path) {
|
|
5130
|
+
try {
|
|
5131
|
+
return statSync5(path).isDirectory();
|
|
5132
|
+
} catch {
|
|
5133
|
+
return false;
|
|
5134
|
+
}
|
|
5135
|
+
}
|
|
5136
|
+
function projectShadowsBunCommand(command, cwd) {
|
|
5137
|
+
const packageJsonDir = nearestPackageJsonDir(cwd);
|
|
5138
|
+
if (packageJsonDir !== undefined) {
|
|
5139
|
+
const scripts = readJsonObject(join8(packageJsonDir, "package.json"))?.["scripts"];
|
|
5140
|
+
if (scripts !== null && typeof scripts === "object" && typeof scripts[command] === "string") {
|
|
5141
|
+
return true;
|
|
5142
|
+
}
|
|
5143
|
+
}
|
|
5144
|
+
if (command === "check")
|
|
5145
|
+
return false;
|
|
5146
|
+
const base = join8(cwd, command);
|
|
5147
|
+
if (isFile(base) || RUNNABLE_EXTENSIONS.some((extension) => isFile(`${base}${extension}`)))
|
|
5148
|
+
return true;
|
|
5149
|
+
if (isDirectory(base) && (isFile(join8(base, "package.json")) || RUNNABLE_EXTENSIONS.some((extension) => isFile(join8(base, `index${extension}`))))) {
|
|
5150
|
+
return true;
|
|
5151
|
+
}
|
|
5152
|
+
let dir = resolve11(cwd);
|
|
5153
|
+
for (;; ) {
|
|
5154
|
+
if (BIN_SUFFIXES.some((suffix) => existsSync13(join8(dir, "node_modules", ".bin", `${command}${suffix}`))))
|
|
5155
|
+
return true;
|
|
5156
|
+
const parent = dirname11(dir);
|
|
5157
|
+
if (parent === dir)
|
|
5158
|
+
return false;
|
|
5159
|
+
dir = parent;
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
function nearestPackageJsonDir(start) {
|
|
5163
|
+
let dir = resolve11(start);
|
|
5164
|
+
for (;; ) {
|
|
5165
|
+
if (existsSync13(join8(dir, "package.json")))
|
|
5166
|
+
return dir;
|
|
5167
|
+
const parent = dirname11(dir);
|
|
5168
|
+
if (parent === dir)
|
|
5169
|
+
return;
|
|
5170
|
+
dir = parent;
|
|
5171
|
+
}
|
|
5172
|
+
}
|
|
5173
|
+
function binaryIdentity(bunPath) {
|
|
5174
|
+
try {
|
|
5175
|
+
const stats = statSync5(bunPath);
|
|
5176
|
+
return `${stats.mtimeMs}:${stats.size}`;
|
|
5177
|
+
} catch {
|
|
5178
|
+
return "missing";
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
function bunHasCommand(bunPath, command, timeoutMs = PROBE_TIMEOUT_MS2) {
|
|
5182
|
+
const key = `${bunPath}\x00${binaryIdentity(bunPath)}\x00${command}`;
|
|
5183
|
+
const cached = probeCache.get(key);
|
|
5184
|
+
if (cached !== undefined)
|
|
5185
|
+
return cached;
|
|
5186
|
+
const probe = probeOnce(bunPath, command, timeoutMs).then((answer) => {
|
|
5187
|
+
if (answer === undefined)
|
|
5188
|
+
probeCache.delete(key);
|
|
5189
|
+
return answer === true;
|
|
5190
|
+
});
|
|
5191
|
+
probeCache.set(key, probe);
|
|
5192
|
+
return probe;
|
|
5193
|
+
}
|
|
5194
|
+
async function probeOnce(bunPath, command, timeoutMs) {
|
|
5195
|
+
const emptyDir = mkdtempSync(join8(tmpdir2(), "omo-bun-probe-"));
|
|
5196
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
5197
|
+
try {
|
|
5198
|
+
const help = await runBunCommand(bunPath, [command, "--help"], emptyDir, timeout);
|
|
5199
|
+
if (help.exitCode === null)
|
|
5200
|
+
return;
|
|
5201
|
+
if (help.exitCode !== 0)
|
|
5202
|
+
return false;
|
|
5203
|
+
if (command !== "format")
|
|
5204
|
+
return true;
|
|
5205
|
+
const probeFile = join8(emptyDir, "probe.ts");
|
|
5206
|
+
writeFileSync3(probeFile, UNFORMATTED_PROBE);
|
|
5207
|
+
const write = await runBunCommand(bunPath, ["format", "--write", "probe.ts"], emptyDir, timeout);
|
|
5208
|
+
if (write.exitCode === null)
|
|
5209
|
+
return;
|
|
5210
|
+
return write.exitCode === 0 && readFileSync6(probeFile, "utf8") !== UNFORMATTED_PROBE;
|
|
5211
|
+
} catch {
|
|
5212
|
+
return;
|
|
5213
|
+
} finally {
|
|
5214
|
+
rmSync2(emptyDir, { recursive: true, force: true });
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5217
|
+
async function resolveBunProjectCommand(command, cwd, options = {}) {
|
|
5218
|
+
if (findBunProjectRoot(cwd, options.homeDir) === undefined)
|
|
5219
|
+
return;
|
|
5220
|
+
if (projectShadowsBunCommand(command, cwd))
|
|
5221
|
+
return;
|
|
5222
|
+
const bunPath = (options.resolveBun ?? defaultResolveBun)(cwd);
|
|
5223
|
+
if (!bunPath)
|
|
5224
|
+
return;
|
|
5225
|
+
return await bunHasCommand(bunPath, command) ? bunPath : undefined;
|
|
5226
|
+
}
|
|
5227
|
+
function defaultResolveBun(cwd) {
|
|
5228
|
+
return resolveServerBinary(["bun"], cwd);
|
|
5229
|
+
}
|
|
5230
|
+
function runBunCommand(bunPath, args, cwd, signal) {
|
|
5231
|
+
signal?.throwIfAborted();
|
|
5232
|
+
const prepared = createSpawnCommand([bunPath, ...args]);
|
|
5233
|
+
return new Promise((resolvePromise, reject) => {
|
|
5234
|
+
const child = spawn3(prepared.command, prepared.args, {
|
|
5235
|
+
cwd,
|
|
5236
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
5237
|
+
shell: prepared.shell,
|
|
5238
|
+
windowsHide: true,
|
|
5239
|
+
detached: process.platform !== "win32"
|
|
5240
|
+
});
|
|
5241
|
+
const stdout = [];
|
|
5242
|
+
const stderr = [];
|
|
5243
|
+
const onAbort = () => killProcessTree(child, "SIGKILL");
|
|
5244
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
5245
|
+
child.stdout?.on("data", (chunk) => stdout.push(chunk));
|
|
5246
|
+
child.stderr?.on("data", (chunk) => stderr.push(chunk));
|
|
5247
|
+
child.once("error", (error) => {
|
|
5248
|
+
signal?.removeEventListener("abort", onAbort);
|
|
5249
|
+
reject(error);
|
|
5250
|
+
});
|
|
5251
|
+
child.once("close", (exitCode) => {
|
|
5252
|
+
signal?.removeEventListener("abort", onAbort);
|
|
5253
|
+
if (signal?.aborted) {
|
|
5254
|
+
reject(signal.reason);
|
|
5255
|
+
return;
|
|
5256
|
+
}
|
|
5257
|
+
resolvePromise({
|
|
5258
|
+
exitCode,
|
|
5259
|
+
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
5260
|
+
stderr: Buffer.concat(stderr).toString("utf8")
|
|
5261
|
+
});
|
|
5262
|
+
});
|
|
5263
|
+
});
|
|
5264
|
+
}
|
|
5265
|
+
var TYPESCRIPT_EXTENSIONS = new Set([".ts", ".tsx", ".mts", ".cts"]);
|
|
5266
|
+
async function runBunDirectoryDiagnostics(absDir, extension, severity, signal, options = {}) {
|
|
5267
|
+
if (!TYPESCRIPT_EXTENSIONS.has(extension))
|
|
5268
|
+
return;
|
|
5269
|
+
const checkBun = await resolveBunProjectCommand("check", absDir, options);
|
|
5270
|
+
if (checkBun === undefined)
|
|
5271
|
+
return;
|
|
5272
|
+
let typecheck;
|
|
5273
|
+
try {
|
|
5274
|
+
const run = await runBunCommand(checkBun, ["check", "--no-pretty", "."], absDir, signal);
|
|
5275
|
+
typecheck = parseBunCheckOutput(run.stdout, absDir);
|
|
5276
|
+
const failedWithoutDiagnostics = run.exitCode === 1 && typecheck.length === 0;
|
|
5277
|
+
if (run.exitCode !== 0 && run.exitCode !== 1 || failedWithoutDiagnostics)
|
|
5278
|
+
return;
|
|
5279
|
+
} catch (error) {
|
|
5280
|
+
if (signal?.aborted)
|
|
5281
|
+
throw error;
|
|
5282
|
+
return;
|
|
5283
|
+
}
|
|
5284
|
+
const header = [`Directory: ${absDir}`, "Typecheck: bun check (files in this directory and everything they import)"];
|
|
5285
|
+
const projectCommands = ["bun check"];
|
|
5286
|
+
const collected = [...typecheck];
|
|
5287
|
+
const lintBun = await resolveBunProjectCommand("lint", absDir, options);
|
|
5288
|
+
if (lintBun !== undefined) {
|
|
5289
|
+
const lint = await runBunLint(lintBun, absDir, signal);
|
|
5290
|
+
header.push(lint.status);
|
|
5291
|
+
projectCommands.push("bun lint");
|
|
5292
|
+
collected.push(...lint.diagnostics);
|
|
5293
|
+
}
|
|
5294
|
+
const diagnostics = collected.filter(({ diagnostic }) => filterDiagnosticsBySeverity([diagnostic], severity).length > 0);
|
|
5295
|
+
const lines = [...header, `Total diagnostics: ${diagnostics.length}`];
|
|
5296
|
+
const shown = diagnostics.slice(0, DEFAULT_MAX_DIAGNOSTICS);
|
|
5297
|
+
if (shown.length > 0) {
|
|
5298
|
+
lines.push("", ...shown.map(({ file, diagnostic }) => `${file}: ${formatDiagnostic(diagnostic)}`));
|
|
5299
|
+
if (diagnostics.length > shown.length) {
|
|
5300
|
+
lines.push("", `... (${diagnostics.length - shown.length} more diagnostics not shown)`);
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
return { output: lines.join(`
|
|
5304
|
+
`), diagnostics, projectCommands };
|
|
5305
|
+
}
|
|
5306
|
+
async function runBunLint(bunPath, absDir, signal) {
|
|
5307
|
+
try {
|
|
5308
|
+
const run = await runBunCommand(bunPath, ["lint", "-f", "json", "."], absDir, signal);
|
|
5309
|
+
const diagnostics = run.exitCode === 0 || run.exitCode === 1 ? parseBunLintJson(run.stdout) : undefined;
|
|
5310
|
+
if (diagnostics !== undefined)
|
|
5311
|
+
return { status: "Lint: bun lint", diagnostics };
|
|
5312
|
+
const reason = run.stderr.trim().split(/\r?\n/)[0] ?? "";
|
|
5313
|
+
return { status: `Lint: bun lint could not lint (exit ${run.exitCode ?? "signal"})${reason ? `: ${reason}` : ""}`, diagnostics: [] };
|
|
5314
|
+
} catch (error) {
|
|
5315
|
+
if (signal?.aborted)
|
|
5316
|
+
throw error;
|
|
5317
|
+
return { status: `Lint: bun lint could not run: ${error instanceof Error ? error.message : String(error)}`, diagnostics: [] };
|
|
5318
|
+
}
|
|
5319
|
+
}
|
|
5011
5320
|
function requireString(params, key) {
|
|
5012
5321
|
const value = params[key];
|
|
5013
5322
|
if (typeof value !== "string" || value.length === 0) {
|
|
@@ -5054,7 +5363,7 @@ function asDiagnosticArray(result) {
|
|
|
5054
5363
|
return result;
|
|
5055
5364
|
return result.items ?? [];
|
|
5056
5365
|
}
|
|
5057
|
-
async function executeLspDiagnostics(params, signal) {
|
|
5366
|
+
async function executeLspDiagnostics(params, signal, bunOptions = {}) {
|
|
5058
5367
|
const filePath = requireString(params, "filePath");
|
|
5059
5368
|
const severity = severityFilter(params);
|
|
5060
5369
|
try {
|
|
@@ -5075,6 +5384,19 @@ async function executeLspDiagnostics(params, signal) {
|
|
|
5075
5384
|
};
|
|
5076
5385
|
return text(message, details);
|
|
5077
5386
|
}
|
|
5387
|
+
const bun = await runBunDirectoryDiagnostics(absPath, extension, severity, signal, bunOptions);
|
|
5388
|
+
if (bun !== undefined) {
|
|
5389
|
+
const details = {
|
|
5390
|
+
filePath,
|
|
5391
|
+
severity,
|
|
5392
|
+
mode: "directory",
|
|
5393
|
+
diagnostics: [...bun.diagnostics],
|
|
5394
|
+
totalDiagnostics: bun.diagnostics.length,
|
|
5395
|
+
truncated: bun.diagnostics.length > DEFAULT_MAX_DIAGNOSTICS,
|
|
5396
|
+
projectCommands: [...bun.projectCommands]
|
|
5397
|
+
};
|
|
5398
|
+
return text(bun.output, details);
|
|
5399
|
+
}
|
|
5078
5400
|
const output = await aggregateDiagnosticsForDirectory(absPath, extension, severity, undefined, signal === undefined ? {} : { signal });
|
|
5079
5401
|
const details = {
|
|
5080
5402
|
filePath,
|
|
@@ -5148,7 +5470,7 @@ async function formatDocumentWithClient(client, filePath, options = {}) {
|
|
|
5148
5470
|
return { status: "unavailable", reason: "capability_not_advertised" };
|
|
5149
5471
|
if (edits.length === 0)
|
|
5150
5472
|
return UNCHANGED;
|
|
5151
|
-
const before =
|
|
5473
|
+
const before = readFileSync7(filePath, "utf-8");
|
|
5152
5474
|
const normalized = normalizeTextEdits(before, edits, 0);
|
|
5153
5475
|
if (normalized.text === before)
|
|
5154
5476
|
return UNCHANGED;
|
|
@@ -5171,7 +5493,7 @@ function lineDelta(edits) {
|
|
|
5171
5493
|
}
|
|
5172
5494
|
function writeAtomically(filePath, content) {
|
|
5173
5495
|
const tempPath = `${filePath}.omo-format.tmp`;
|
|
5174
|
-
|
|
5496
|
+
writeFileSync4(tempPath, content, "utf-8");
|
|
5175
5497
|
try {
|
|
5176
5498
|
renameSync3(tempPath, filePath);
|
|
5177
5499
|
} catch (error) {
|
|
@@ -5460,7 +5782,7 @@ var LSP_MCP_TOOLS = [
|
|
|
5460
5782
|
name: "diagnostics",
|
|
5461
5783
|
aliases: ["lsp_diagnostics"],
|
|
5462
5784
|
title: "LSP Diagnostics",
|
|
5463
|
-
description: "Get errors, warnings, and hints for a source file or directory.",
|
|
5785
|
+
description: "Get errors, warnings, and hints for a source file or directory. In a Bun project, a TypeScript directory is typechecked with `bun check`, plus `bun lint` when the installed Bun has it.",
|
|
5464
5786
|
inputSchema: objectSchema({
|
|
5465
5787
|
filePath: { type: "string", description: "File or directory path to check." },
|
|
5466
5788
|
severity: {
|
|
@@ -5780,7 +6102,7 @@ function resolveDaemonRuntime2(env, defaults) {
|
|
|
5780
6102
|
if (!isAbsolute6(cliOverride)) {
|
|
5781
6103
|
throw new InvalidRuntimeOverrideError2("cli_must_be_absolute", `${OMO_LSP_DAEMON_CLI2} must be an absolute path to an existing regular file`);
|
|
5782
6104
|
}
|
|
5783
|
-
const stat =
|
|
6105
|
+
const stat = statSync6(cliOverride, { throwIfNoEntry: false });
|
|
5784
6106
|
if (!stat) {
|
|
5785
6107
|
throw new InvalidRuntimeOverrideError2("cli_not_found", `${OMO_LSP_DAEMON_CLI2} points to a missing file`);
|
|
5786
6108
|
}
|
|
@@ -5807,8 +6129,8 @@ var WORKSPACE_MARKERS2 = [GIT_WORKSPACE_MARKER2, ...PROJECT_WORKSPACE_MARKERS2];
|
|
|
5807
6129
|
|
|
5808
6130
|
// ../../../../lsp-core/src/request-context.ts
|
|
5809
6131
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
5810
|
-
import { existsSync as
|
|
5811
|
-
import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute7, join as
|
|
6132
|
+
import { existsSync as existsSync14, realpathSync as realpathSync6, statSync as statSync7 } from "node:fs";
|
|
6133
|
+
import { basename as basename4, delimiter as delimiter4, dirname as dirname2, isAbsolute as isAbsolute7, join as join9, relative as relative5, resolve as resolve12 } from "node:path";
|
|
5812
6134
|
|
|
5813
6135
|
class LspRequestContextParseError2 extends Error {
|
|
5814
6136
|
constructor(code, message) {
|
|
@@ -5849,19 +6171,19 @@ function parseLspRequestContext2(value) {
|
|
|
5849
6171
|
};
|
|
5850
6172
|
}
|
|
5851
6173
|
function canonicalCwd2(cwd) {
|
|
5852
|
-
const resolved =
|
|
5853
|
-
if (!
|
|
6174
|
+
const resolved = resolve12(cwd);
|
|
6175
|
+
if (!existsSync14(resolved) || !statSync7(resolved).isDirectory()) {
|
|
5854
6176
|
throw new LspRequestContextParseError2("invalid_cwd", `LSP request cwd must be an existing directory: ${cwd}`);
|
|
5855
6177
|
}
|
|
5856
6178
|
return realpathSync6(resolved);
|
|
5857
6179
|
}
|
|
5858
6180
|
function canonicalizeExistingOrNearestAncestor2(path) {
|
|
5859
|
-
let current =
|
|
6181
|
+
let current = resolve12(path);
|
|
5860
6182
|
const suffix = [];
|
|
5861
6183
|
while (true) {
|
|
5862
6184
|
try {
|
|
5863
6185
|
const existing = realpathSync6(current);
|
|
5864
|
-
return suffix.length === 0 ? existing :
|
|
6186
|
+
return suffix.length === 0 ? existing : join9(existing, ...suffix);
|
|
5865
6187
|
} catch (error) {
|
|
5866
6188
|
if (!isMissingPathError2(error))
|
|
5867
6189
|
throw error;
|
|
@@ -5904,7 +6226,7 @@ function requireAbsolutePath2(path, field) {
|
|
|
5904
6226
|
}
|
|
5905
6227
|
}
|
|
5906
6228
|
function isPathInside2(parent, child) {
|
|
5907
|
-
const childPath =
|
|
6229
|
+
const childPath = resolve12(child);
|
|
5908
6230
|
const relativePath = relative5(parent, childPath);
|
|
5909
6231
|
return relativePath === "" || !relativePath.startsWith("..") && !isAbsolute7(relativePath);
|
|
5910
6232
|
}
|
|
@@ -6057,9 +6379,9 @@ function extensionKey(filePath) {
|
|
|
6057
6379
|
return extension.length === 0 ? undefined : extension;
|
|
6058
6380
|
}
|
|
6059
6381
|
// src/daemon-cli-path.ts
|
|
6060
|
-
import { existsSync as
|
|
6382
|
+
import { existsSync as existsSync15, readFileSync as readFileSync8 } from "node:fs";
|
|
6061
6383
|
import { createRequire as createRequire2 } from "node:module";
|
|
6062
|
-
import { dirname as
|
|
6384
|
+
import { dirname as dirname12, join as join10 } from "node:path";
|
|
6063
6385
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
6064
6386
|
var requireFromHere2 = createRequire2(import.meta.url);
|
|
6065
6387
|
var PACKAGE_LSP_DAEMON_CLI = "@code-yeongyu/lsp-daemon/cli";
|
|
@@ -6081,7 +6403,7 @@ function resolveLspDaemonCli() {
|
|
|
6081
6403
|
if (packageCli !== null)
|
|
6082
6404
|
return resolveConfiguredLspDaemonCli(packageCli);
|
|
6083
6405
|
const bundledCli = fileURLToPath4(new URL("../../lsp-daemon/dist/cli.js", import.meta.url));
|
|
6084
|
-
if (
|
|
6406
|
+
if (existsSync15(bundledCli))
|
|
6085
6407
|
return resolveConfiguredLspDaemonCli(bundledCli);
|
|
6086
6408
|
return resolveConfiguredLspDaemonCli(bundledCli);
|
|
6087
6409
|
}
|
|
@@ -6106,7 +6428,7 @@ function resolveConfiguredLspDaemonCli(cliPath) {
|
|
|
6106
6428
|
}
|
|
6107
6429
|
function readDaemonPackageVersion(cliPath) {
|
|
6108
6430
|
try {
|
|
6109
|
-
const parsed = JSON.parse(
|
|
6431
|
+
const parsed = JSON.parse(readFileSync8(join10(dirname12(cliPath), "package.json"), "utf8"));
|
|
6110
6432
|
if (isRecord8(parsed) && typeof parsed["version"] === "string" && parsed["version"].length > 0) {
|
|
6111
6433
|
return parsed["version"];
|
|
6112
6434
|
}
|
|
@@ -6121,9 +6443,9 @@ function isRecord8(value) {
|
|
|
6121
6443
|
}
|
|
6122
6444
|
|
|
6123
6445
|
// src/lsp-session-state.ts
|
|
6124
|
-
import { mkdirSync as mkdirSync4, readFileSync as
|
|
6446
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6125
6447
|
import { homedir } from "node:os";
|
|
6126
|
-
import { dirname as
|
|
6448
|
+
import { dirname as dirname13, join as join11 } from "node:path";
|
|
6127
6449
|
function sessionIdFrom(input) {
|
|
6128
6450
|
return typeof input.session_id === "string" && input.session_id.length > 0 ? input.session_id : undefined;
|
|
6129
6451
|
}
|
|
@@ -6149,12 +6471,12 @@ function isLspDaemonUnreachableDiagnostics(diagnostics) {
|
|
|
6149
6471
|
return diagnostics.includes("LSP daemon unreachable");
|
|
6150
6472
|
}
|
|
6151
6473
|
function sessionStatePath(sessionId) {
|
|
6152
|
-
const root = process.env["PLUGIN_DATA"] ??
|
|
6153
|
-
return
|
|
6474
|
+
const root = process.env["PLUGIN_DATA"] ?? join11(homedir(), ".codex", "codex-lsp");
|
|
6475
|
+
return join11(root, "sessions", `${safePathSegment(sessionId)}.json`);
|
|
6154
6476
|
}
|
|
6155
6477
|
function readSessionState(path) {
|
|
6156
6478
|
try {
|
|
6157
|
-
const parsed = JSON.parse(
|
|
6479
|
+
const parsed = JSON.parse(readFileSync9(path, "utf8"));
|
|
6158
6480
|
if (isRecord9(parsed) && isLspSessionState(parsed))
|
|
6159
6481
|
return normalizeSessionState(parsed);
|
|
6160
6482
|
return emptyState();
|
|
@@ -6165,8 +6487,8 @@ function readSessionState(path) {
|
|
|
6165
6487
|
}
|
|
6166
6488
|
}
|
|
6167
6489
|
function writeSessionState(path, state) {
|
|
6168
|
-
mkdirSync4(
|
|
6169
|
-
|
|
6490
|
+
mkdirSync4(dirname13(path), { recursive: true });
|
|
6491
|
+
writeFileSync5(path, `${JSON.stringify(state)}
|
|
6170
6492
|
`);
|
|
6171
6493
|
}
|
|
6172
6494
|
function emptyState() {
|
|
@@ -6320,13 +6642,13 @@ function notInstalledOutcome(availability, text) {
|
|
|
6320
6642
|
return decision === "declined" || decision === "allowed" ? { ...base, decision } : base;
|
|
6321
6643
|
}
|
|
6322
6644
|
function codexLspRequestContext(env = process.env, cwd = process.cwd()) {
|
|
6323
|
-
const canonicalCwd = realpathSync7(
|
|
6324
|
-
const codexHome =
|
|
6645
|
+
const canonicalCwd = realpathSync7(resolve13(cwd));
|
|
6646
|
+
const codexHome = resolve13(env["CODEX_HOME"]?.trim() || join12(homedir4(), ".codex"));
|
|
6325
6647
|
return parseLspRequestContext2({
|
|
6326
6648
|
cwd: canonicalCwd,
|
|
6327
|
-
projectConfigPaths: [
|
|
6328
|
-
userConfigPath:
|
|
6329
|
-
installDecisionsPath:
|
|
6649
|
+
projectConfigPaths: [join12(canonicalCwd, ".codex", "lsp-client.json")],
|
|
6650
|
+
userConfigPath: join12(codexHome, "lsp-client.json"),
|
|
6651
|
+
installDecisionsPath: join12(codexHome, "lsp-install-decisions.json"),
|
|
6330
6652
|
capabilities: { installDecisionTool: true }
|
|
6331
6653
|
});
|
|
6332
6654
|
}
|
|
@@ -6419,7 +6741,7 @@ function isContextPressureTranscript(transcriptPath) {
|
|
|
6419
6741
|
if (typeof transcriptPath !== "string")
|
|
6420
6742
|
return false;
|
|
6421
6743
|
try {
|
|
6422
|
-
return hasContextPressureMarker(
|
|
6744
|
+
return hasContextPressureMarker(readFileSync10(transcriptPath, "utf8"));
|
|
6423
6745
|
} catch (error) {
|
|
6424
6746
|
if (error instanceof Error)
|
|
6425
6747
|
return false;
|
|
@@ -6501,7 +6823,7 @@ main().catch((error) => {
|
|
|
6501
6823
|
});
|
|
6502
6824
|
async function runPackageLspMcpCli() {
|
|
6503
6825
|
const cliPath = resolveLspDaemonCliPath();
|
|
6504
|
-
const child =
|
|
6826
|
+
const child = spawn4(execPath2, [cliPath, "mcp"], { stdio: "inherit", windowsHide: true });
|
|
6505
6827
|
await new Promise((resolve, reject) => {
|
|
6506
6828
|
child.once("error", reject);
|
|
6507
6829
|
child.once("exit", (code, signal) => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "command",
|
|
9
9
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-tool-use",
|
|
10
10
|
"timeout": 60,
|
|
11
|
-
"statusMessage": "(OmO 5.1.
|
|
11
|
+
"statusMessage": "(OmO 5.1.43) Checking LSP Diagnostics"
|
|
12
12
|
}
|
|
13
13
|
]
|
|
14
14
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"type": "command",
|
|
22
22
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-compact",
|
|
23
23
|
"timeout": 5,
|
|
24
|
-
"statusMessage": "(OmO 5.1.
|
|
24
|
+
"statusMessage": "(OmO 5.1.43) Resetting LSP Diagnostics Cache"
|
|
25
25
|
}
|
|
26
26
|
]
|
|
27
27
|
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"type": "command",
|
|
8
8
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook session-start",
|
|
9
9
|
"timeout": 10,
|
|
10
|
-
"statusMessage": "(OmO 5.1.
|
|
10
|
+
"statusMessage": "(OmO 5.1.43) Loading Project Rules"
|
|
11
11
|
}
|
|
12
12
|
]
|
|
13
13
|
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"type": "command",
|
|
20
20
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook user-prompt-submit",
|
|
21
21
|
"timeout": 10,
|
|
22
|
-
"statusMessage": "(OmO 5.1.
|
|
22
|
+
"statusMessage": "(OmO 5.1.43) Loading Project Rules"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
}
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"type": "command",
|
|
33
33
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-tool-use",
|
|
34
34
|
"timeout": 10,
|
|
35
|
-
"statusMessage": "(OmO 5.1.
|
|
35
|
+
"statusMessage": "(OmO 5.1.43) Matching Project Rules"
|
|
36
36
|
}
|
|
37
37
|
]
|
|
38
38
|
}
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"type": "command",
|
|
46
46
|
"command": "node \"${PLUGIN_ROOT}/dist/cli.js\" hook post-compact",
|
|
47
47
|
"timeout": 10,
|
|
48
|
-
"statusMessage": "(OmO 5.1.
|
|
48
|
+
"statusMessage": "(OmO 5.1.43) Resetting Project Rule Cache"
|
|
49
49
|
}
|
|
50
50
|
]
|
|
51
51
|
}
|
|
@@ -270,6 +270,8 @@ function toDiagnosticRecord(input, now) {
|
|
|
270
270
|
timestamp: now.toISOString(),
|
|
271
271
|
event: input.event,
|
|
272
272
|
source: input.source,
|
|
273
|
+
...input.entryKind === undefined ? {} : { entry_kind: input.entryKind },
|
|
274
|
+
...input.errorCode === undefined ? {} : { error_code: input.errorCode },
|
|
273
275
|
...input.count === undefined ? {} : { count: input.count },
|
|
274
276
|
...serializeError(input.error, input.errorKind)
|
|
275
277
|
};
|
|
@@ -265,6 +265,8 @@ function toDiagnosticRecord(input, now) {
|
|
|
265
265
|
timestamp: now.toISOString(),
|
|
266
266
|
event: input.event,
|
|
267
267
|
source: input.source,
|
|
268
|
+
...input.entryKind === undefined ? {} : { entry_kind: input.entryKind },
|
|
269
|
+
...input.errorCode === undefined ? {} : { error_code: input.errorCode },
|
|
268
270
|
...input.count === undefined ? {} : { count: input.count },
|
|
269
271
|
...serializeError(input.error, input.errorKind)
|
|
270
272
|
};
|