Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 48 additions & 13 deletions .claude/hooks/dist/arch-context-inject.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";

// src/daemon-client.ts
import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
import { execSync, spawnSync } from "child_process";
import { execSync, spawn } from "child_process";
import { join, resolve } from "path";
import { tmpdir } from "os";
import * as net from "net";
Expand All @@ -18,8 +18,7 @@ function getLockPath(projectDir) {
}
function getPidPath(projectDir) {
const resolvedPath = resolveProjectDir(projectDir);
const hash = crypto.createHash("md5").update(resolvedPath).digest("hex").substring(0, 8);
return `${tmpdir()}/tldr-${hash}.pid`;
return join(resolvedPath, ".tldr", "daemon.pid");
}
function isDaemonProcessRunning(projectDir) {
const pidPath = getPidPath(projectDir);
Expand All @@ -29,7 +28,12 @@ function isDaemonProcessRunning(projectDir) {
if (isNaN(pid) || pid <= 0) return false;
process.kill(pid, 0);
return true;
} catch {
} catch (e) {
if (e.code === "EPERM") return true;
try {
unlinkSync(pidPath);
} catch {
}
return false;
}
}
Expand Down Expand Up @@ -163,18 +167,32 @@ function tryStartDaemon(projectDir) {
const tldrPath = join(projectDir, "opc", "packages", "tldr-code");
let started = false;
if (existsSync(tldrPath)) {
const result = spawnSync("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
timeout: 1e4,
stdio: "ignore",
cwd: tldrPath
});
started = result.status === 0;
try {
execSync("uv --version", { stdio: "ignore", timeout: 2e3 });
const child = spawn("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: tldrPath
});
child.on("error", () => {
});
if (child.pid !== void 0) {
child.unref();
started = true;
}
} catch {
}
}
if (!started && !process.env.TLDR_DEV) {
spawnSync("tldr", ["daemon", "start", "--project", projectDir], {
timeout: 5e3,
stdio: "ignore"
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
}
const start = Date.now();
while (Date.now() - start < 1e4) {
Expand All @@ -188,6 +206,23 @@ function tryStartDaemon(projectDir) {
while (Date.now() < end) {
}
}
if (started && !isDaemonProcessRunning(projectDir) && !isDaemonReachable(projectDir) && !process.env.TLDR_DEV) {
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
const lrStart = Date.now();
while (Date.now() - lrStart < 3e3) {
if (isDaemonReachable(projectDir)) break;
const wait = Date.now() + 100;
while (Date.now() < wait) {
}
}
}
return isDaemonReachable(projectDir);
} finally {
releaseLock(projectDir);
Expand Down
61 changes: 48 additions & 13 deletions .claude/hooks/dist/daemon-client.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// src/daemon-client.ts
import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
import { execSync, spawnSync } from "child_process";
import { execSync, spawn } from "child_process";
import { join, resolve } from "path";
import { tmpdir } from "os";
import * as net from "net";
Expand All @@ -15,8 +15,7 @@ function getLockPath(projectDir) {
}
function getPidPath(projectDir) {
const resolvedPath = resolveProjectDir(projectDir);
const hash = crypto.createHash("md5").update(resolvedPath).digest("hex").substring(0, 8);
return `${tmpdir()}/tldr-${hash}.pid`;
return join(resolvedPath, ".tldr", "daemon.pid");
}
function isDaemonProcessRunning(projectDir) {
const pidPath = getPidPath(projectDir);
Expand All @@ -26,7 +25,12 @@ function isDaemonProcessRunning(projectDir) {
if (isNaN(pid) || pid <= 0) return false;
process.kill(pid, 0);
return true;
} catch {
} catch (e) {
if (e.code === "EPERM") return true;
try {
unlinkSync(pidPath);
} catch {
}
return false;
}
}
Expand Down Expand Up @@ -165,18 +169,32 @@ function tryStartDaemon(projectDir) {
const tldrPath = join(projectDir, "opc", "packages", "tldr-code");
let started = false;
if (existsSync(tldrPath)) {
const result = spawnSync("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
timeout: 1e4,
stdio: "ignore",
cwd: tldrPath
});
started = result.status === 0;
try {
execSync("uv --version", { stdio: "ignore", timeout: 2e3 });
const child = spawn("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: tldrPath
});
child.on("error", () => {
});
if (child.pid !== void 0) {
child.unref();
started = true;
}
} catch {
}
}
if (!started && !process.env.TLDR_DEV) {
spawnSync("tldr", ["daemon", "start", "--project", projectDir], {
timeout: 5e3,
stdio: "ignore"
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
}
const start = Date.now();
while (Date.now() - start < 1e4) {
Expand All @@ -190,6 +208,23 @@ function tryStartDaemon(projectDir) {
while (Date.now() < end) {
}
}
if (started && !isDaemonProcessRunning(projectDir) && !isDaemonReachable(projectDir) && !process.env.TLDR_DEV) {
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
const lrStart = Date.now();
while (Date.now() - lrStart < 3e3) {
if (isDaemonReachable(projectDir)) break;
const wait = Date.now() + 100;
while (Date.now() < wait) {
}
}
}
return isDaemonReachable(projectDir);
} finally {
releaseLock(projectDir);
Expand Down
61 changes: 48 additions & 13 deletions .claude/hooks/dist/edit-context-inject.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { basename } from "path";

// src/daemon-client.ts
import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
import { execSync, spawnSync } from "child_process";
import { execSync, spawn } from "child_process";
import { join, resolve } from "path";
import { tmpdir } from "os";
import * as net from "net";
Expand All @@ -19,8 +19,7 @@ function getLockPath(projectDir) {
}
function getPidPath(projectDir) {
const resolvedPath = resolveProjectDir(projectDir);
const hash = crypto.createHash("md5").update(resolvedPath).digest("hex").substring(0, 8);
return `${tmpdir()}/tldr-${hash}.pid`;
return join(resolvedPath, ".tldr", "daemon.pid");
}
function isDaemonProcessRunning(projectDir) {
const pidPath = getPidPath(projectDir);
Expand All @@ -30,7 +29,12 @@ function isDaemonProcessRunning(projectDir) {
if (isNaN(pid) || pid <= 0) return false;
process.kill(pid, 0);
return true;
} catch {
} catch (e) {
if (e.code === "EPERM") return true;
try {
unlinkSync(pidPath);
} catch {
}
return false;
}
}
Expand Down Expand Up @@ -164,18 +168,32 @@ function tryStartDaemon(projectDir) {
const tldrPath = join(projectDir, "opc", "packages", "tldr-code");
let started = false;
if (existsSync(tldrPath)) {
const result = spawnSync("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
timeout: 1e4,
stdio: "ignore",
cwd: tldrPath
});
started = result.status === 0;
try {
execSync("uv --version", { stdio: "ignore", timeout: 2e3 });
const child = spawn("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: tldrPath
});
child.on("error", () => {
});
if (child.pid !== void 0) {
child.unref();
started = true;
}
} catch {
}
}
if (!started && !process.env.TLDR_DEV) {
spawnSync("tldr", ["daemon", "start", "--project", projectDir], {
timeout: 5e3,
stdio: "ignore"
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
}
const start = Date.now();
while (Date.now() - start < 1e4) {
Expand All @@ -189,6 +207,23 @@ function tryStartDaemon(projectDir) {
while (Date.now() < end) {
}
}
if (started && !isDaemonProcessRunning(projectDir) && !isDaemonReachable(projectDir) && !process.env.TLDR_DEV) {
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
const lrStart = Date.now();
while (Date.now() - lrStart < 3e3) {
if (isDaemonReachable(projectDir)) break;
const wait = Date.now() + 100;
while (Date.now() < wait) {
}
}
}
return isDaemonReachable(projectDir);
} finally {
releaseLock(projectDir);
Expand Down
61 changes: 48 additions & 13 deletions .claude/hooks/dist/impact-refactor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFileSync as readFileSync2 } from "fs";

// src/daemon-client.ts
import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
import { execSync, spawnSync } from "child_process";
import { execSync, spawn } from "child_process";
import { join, resolve } from "path";
import { tmpdir } from "os";
import * as net from "net";
Expand All @@ -18,8 +18,7 @@ function getLockPath(projectDir) {
}
function getPidPath(projectDir) {
const resolvedPath = resolveProjectDir(projectDir);
const hash = crypto.createHash("md5").update(resolvedPath).digest("hex").substring(0, 8);
return `${tmpdir()}/tldr-${hash}.pid`;
return join(resolvedPath, ".tldr", "daemon.pid");
}
function isDaemonProcessRunning(projectDir) {
const pidPath = getPidPath(projectDir);
Expand All @@ -29,7 +28,12 @@ function isDaemonProcessRunning(projectDir) {
if (isNaN(pid) || pid <= 0) return false;
process.kill(pid, 0);
return true;
} catch {
} catch (e) {
if (e.code === "EPERM") return true;
try {
unlinkSync(pidPath);
} catch {
}
return false;
}
}
Expand Down Expand Up @@ -163,18 +167,32 @@ function tryStartDaemon(projectDir) {
const tldrPath = join(projectDir, "opc", "packages", "tldr-code");
let started = false;
if (existsSync(tldrPath)) {
const result = spawnSync("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
timeout: 1e4,
stdio: "ignore",
cwd: tldrPath
});
started = result.status === 0;
try {
execSync("uv --version", { stdio: "ignore", timeout: 2e3 });
const child = spawn("uv", ["run", "tldr", "daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: tldrPath
});
child.on("error", () => {
});
if (child.pid !== void 0) {
child.unref();
started = true;
}
} catch {
}
}
if (!started && !process.env.TLDR_DEV) {
spawnSync("tldr", ["daemon", "start", "--project", projectDir], {
timeout: 5e3,
stdio: "ignore"
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
}
const start = Date.now();
while (Date.now() - start < 1e4) {
Expand All @@ -188,6 +206,23 @@ function tryStartDaemon(projectDir) {
while (Date.now() < end) {
}
}
if (started && !isDaemonProcessRunning(projectDir) && !isDaemonReachable(projectDir) && !process.env.TLDR_DEV) {
const child = spawn("tldr", ["daemon", "start", "--project", projectDir], {
detached: true,
stdio: "ignore",
windowsHide: true
});
child.on("error", () => {
});
child.unref();
const lrStart = Date.now();
while (Date.now() - lrStart < 3e3) {
if (isDaemonReachable(projectDir)) break;
const wait = Date.now() + 100;
while (Date.now() < wait) {
}
}
}
return isDaemonReachable(projectDir);
} finally {
releaseLock(projectDir);
Expand Down
Loading